Skip to content

Commit

Permalink
WIP: Uncomment 262 cases that pass
Browse files Browse the repository at this point in the history
  • Loading branch information
0xe committed Jun 3, 2024
1 parent 6900073 commit e22db83
Show file tree
Hide file tree
Showing 6 changed files with 626 additions and 699 deletions.
3 changes: 3 additions & 0 deletions src/org/mozilla/javascript/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ private AstNode parseFunctionBody(int type, FunctionNode fnNode) throws IOExcept
if (directive == null) {
inDirectivePrologue = false;
} else if (directive.equals("use strict")) {
if (fnNode.getDefaultParams() != null) {
reportError("msg.default.args.use.strict");
}
inUseStrictDirective = true;
fnNode.setInStrictMode(true);
if (!savedStrictMode) {
Expand Down
17 changes: 10 additions & 7 deletions src/org/mozilla/javascript/resources/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ msg.mult.index =\
msg.bad.for.in.destruct =\
Left hand side of for..in loop must be an array of length 2 to accept \
key/value pair.

msg.cant.convert =\
Can''t convert to type "{0}".

Expand Down Expand Up @@ -267,7 +267,7 @@ msg.var.redecl =\

msg.const.redecl =\
TypeError: redeclaration of const {0}.

msg.let.redecl =\
TypeError: redeclaration of variable {0}.

Expand Down Expand Up @@ -377,7 +377,7 @@ msg.no.semi.for =\

msg.no.semi.for.cond =\
missing ; after for-loop condition

msg.in.after.for.name =\
missing in after for

Expand All @@ -389,7 +389,7 @@ msg.no.paren.with =\

msg.no.paren.after.with =\
missing ) after with-statement object

msg.no.with.strict =\
with statements not allowed in strict mode

Expand Down Expand Up @@ -539,7 +539,7 @@ msg.no.unary.expr.on.left.exp =\

# ScriptRuntime

# is there a better message for this?
# is there a better message for this?
# it's currently only used as a poison pill for caller, caller and arguments properties
msg.op.not.allowed =\
This operation is not allowed.
Expand Down Expand Up @@ -884,7 +884,7 @@ msg.send.newborn =\

msg.already.exec.gen =\
Already executing generator

msg.StopIteration.invalid =\
StopIteration may not be changed to an arbitrary object.

Expand All @@ -911,6 +911,9 @@ msg.arguments.not.access.strict =\
msg.object.cyclic.prototype =\
Cyclic prototype "{0}" value not allowed.

msg.default.args.use.strict =\
A function cannot have "use strict" directive with default arguments

# Symbol support
msg.object.not.symbolscriptable =\
Object {0} does not support Symbol keys
Expand Down Expand Up @@ -959,4 +962,4 @@ msg.promise.capability.state =\
Invalid promise capability state

msg.promise.all.toobig =\
Too many inputs to Promise.all
Too many inputs to Promise.all
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Ignore;
import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.EcmaError;
Expand Down Expand Up @@ -44,6 +45,7 @@ public void functionDefaultArgsUsage() throws Exception {
}

@Test
@Ignore("temporal-dead-zone")
public void functionDefaultArgsMultiFollowUsage() throws Exception {
final String script =
"function f(a = go()) {\n"
Expand All @@ -54,14 +56,15 @@ public void functionDefaultArgsMultiFollowUsage() throws Exception {
+ "}\n"
+ "\n";
assertIntEvaluates(24, script + "\nf(24)");
assertThrows("ReferenceError: \"go\" is not defined.", "function f() { go() }; var f1 = f()");
assertThrows(
"ReferenceError: \"go\" is not defined.", "function f() { go() }; var f1 = f()");
assertThrows("ReferenceError: \"go\" is not defined.", script + "\nf()");
}

@Test
@Ignore("temporal-dead-zone")
public void functionDefaultArgsMultiReferEarlier() throws Exception {
final String script =
"var f = function(a = b * 2, b = 3) { return a * b; }\n";
final String script = "var f = function(a = b * 2, b = 3) { return a * b; }\n";
assertThrows("ReferenceError: \"b\" is not defined.", script + "\nf()");
}

Expand Down
2 changes: 1 addition & 1 deletion testsrc/org/mozilla/javascript/tests/FunctionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/** */
package org.mozilla.javascript.tests;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.mozilla.javascript.Scriptable;
Expand Down
1 change: 0 additions & 1 deletion testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public class Test262SuiteTest {
"class-fields-public",
"computed-property-names",
"default-arg",
"default-parameters",
"new.target",
"object-rest",
"regexp-dotall",
Expand Down
Loading

0 comments on commit e22db83

Please sign in to comment.