summaryrefslogtreecommitdiff
path: root/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/jsinterop/FunctionTest.scala
blob: 4973e643d42307cd8aaae22b7ed8221cf886b219 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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))
    }

  }
}