Skip to content

Commit

Permalink
add test for ctor args fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Dec 30, 2023
1 parent 2c87299 commit b51da8c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions testsrc/org/mozilla/javascript/tests/es6/NativeReflectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@ public void constructNoConstructorFunction() {
// found no way to check a function for constructor
}

@Test
public void constructorArgs() {
final String script =
" var res = '';\n"
+ "function foo(a, b) {\n"
+ " res += 'foo - ';\n"
+ " for (let i = 0; i < arguments.length; i++) {\n"
+ " res += arguments[i] + ' ';\n"
+ " }\n"
+ "}\n"
+ "Reflect.construct(foo, [1, 2]);\n"
+ "res;";

testString("foo - 1 2 ", script);
}

@Test
public void constructorArgsWithTarget() {
final String script =
" var res = '';\n"
+ "function foo(a, b) {\n"
+ " res += 'foo - ';\n"
+ " for (let i = 0; i < arguments.length; i++) {\n"
+ " res += arguments[i] + ' ';\n"
+ " }\n"
+ "}\n"
+ "function bar(a, b) {\n"
+ " res += 'bar - ';\n"
+ " for (let i = 0; i < arguments.length; i++) {\n"
+ " res += arguments[i] + ' ';\n"
+ " }\n"
+ "}\n"
+ "Reflect.construct(foo, [6, 7, 8], bar);\n"
+ "res;";

testString("foo - 6 7 8 ", script);
}

@Test
public void defineProperty() {
String js =
Expand Down

0 comments on commit b51da8c

Please sign in to comment.