Skip to content

Commit fc0f981

Browse files
committed
Simplify the test InteroperabilityTest.handleDefaultParameters().
1 parent 0aa3542 commit fc0f981

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

test-suite/js/src/test/scala/org/scalajs/testsuite/compiler/InteroperabilityTest.scala

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -530,39 +530,19 @@ class InteroperabilityTest {
530530
@Test def handleDefaultParameters(): Unit = {
531531
val obj = js.eval("""
532532
var interoperabilityTestDefaultParam = {
533-
fun: function() { return arguments; }
533+
fun: function() { return Array.prototype.slice.call(arguments); }
534534
};
535535
interoperabilityTestDefaultParam;
536536
""").asInstanceOf[InteroperabilityTestDefaultParam]
537537

538-
// Helpers
539-
val keys = js.Dynamic.global.Object.keys
540-
val undef = js.undefined
538+
assertJSArrayEquals[Any](js.Array(1), obj.simple(1))
539+
assertJSArrayEquals[Any](js.Array(1, 5), obj.simple(1, 5))
541540

542-
assertEquals(1, keys(obj.simple(1)).length)
543-
assertEquals(1, obj.simple(1)("0"))
541+
assertJSArrayEquals[Any](js.Array(js.undefined, 5), obj.named(y = 5))
542+
assertJSArrayEquals[Any](js.Array(5), obj.named(x = 5))
544543

545-
assertEquals(2, keys(obj.simple(1, 5)).length)
546-
assertEquals(1, obj.simple(1, 5)("0"))
547-
assertEquals(5, obj.simple(1, 5)("1"))
548-
549-
assertEquals(2, keys(obj.named(y = 5)).length)
550-
assertEquals(undef, obj.named(y = 5)("0"))
551-
assertEquals(5, obj.named(y = 5)("1"))
552-
553-
assertEquals(1, keys(obj.named(x = 5)).length)
554-
assertEquals(5, obj.named(x = 5)("0"))
555-
556-
assertEquals(5, keys(obj.multi()(1,2,3,4)()).length)
557-
assertEquals(undef, obj.multi()(1,2,3,4)()("0"))
558-
assertEquals(1, obj.multi()(1,2,3,4)()("1"))
559-
assertEquals(2, obj.multi()(1,2,3,4)()("2"))
560-
assertEquals(3, obj.multi()(1,2,3,4)()("3"))
561-
assertEquals(4, obj.multi()(1,2,3,4)()("4"))
562-
563-
assertEquals(2, keys(obj.multi(2)()(5)).length)
564-
assertEquals(2, obj.multi(2)()(5)("0"))
565-
assertEquals(5, obj.multi(2)()(5)("1"))
544+
assertJSArrayEquals[Any](js.Array(js.undefined, 1, 2, 3, 4), obj.multi()(1, 2, 3, 4)())
545+
assertJSArrayEquals[Any](js.Array(2, 5), obj.multi(2)()(5))
566546
}
567547

568548
@Test def defaultParametersForConstructors_Issue791(): Unit = {
@@ -808,11 +788,11 @@ object InteroperabilityTest {
808788
@js.native
809789
trait InteroperabilityTestDefaultParam extends js.Object {
810790
@JSName("fun")
811-
def simple(x: Int, y: Int = 5): js.Dictionary[Any] = js.native
791+
def simple(x: Int, y: Int = 5): js.Array[Any] = js.native
812792
@JSName("fun")
813-
def named(x: Int = 1, y: Int = 1, z: Int = 1): js.Dictionary[Any] = js.native
793+
def named(x: Int = 1, y: Int = 1, z: Int = 1): js.Array[Any] = js.native
814794
@JSName("fun")
815-
def multi(x: Int = 1)(ys: Int*)(z: Int = 1): js.Dictionary[Any] = js.native
795+
def multi(x: Int = 1)(ys: Int*)(z: Int = 1): js.Array[Any] = js.native
816796
}
817797

818798
@js.native

0 commit comments

Comments
 (0)