summaryrefslogtreecommitdiff
path: root/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala')
-rw-r--r--examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala b/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala
new file mode 100644
index 0000000..4973e64
--- /dev/null
+++ b/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala
@@ -0,0 +1,41 @@
+/* __ *\
+** ________ ___ / / ___ __ ____ Scala.js Test Suite **
+** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
+** /____/\___/_/ |_/____/_/ | |__/ /____/ **
+** |/____/ **
+\* */
+package scala.scalajs.testsuite.jsinterop
+
+import scala.scalajs.js
+import org.scalajs.jasminetest.JasmineTest
+
+object FunctionTest extends JasmineTest {
+
+ import js.Dynamic.{literal => lit}
+
+ describe("scala.scalajs.js.Function") {
+
+ it("should support call() with expanded arguments") {
+ val f = js.eval("""
+ var f = function() { return arguments; }; f;
+ """).asInstanceOf[js.Function]
+
+ expect(f.call(null, 42, true)).toEqual(lit(
+ `0` = 42,
+ `1` = true))
+ }
+
+ it("should support call() with the :_* notation to expand a Seq") {
+ val f = js.eval("""
+ var f = function() { return arguments; }; f;
+ """).asInstanceOf[js.Function]
+
+ val args = Seq[js.Any](42, true)
+ expect(f.call(null, args: _*)).toEqual(lit(
+ `0` = 42,
+ `1` = true))
+ }
+
+ }
+}