diff --git a/src/Esprima/JavaScriptParser.cs b/src/Esprima/JavaScriptParser.cs index 5e1f7c9a..2809ff8c 100644 --- a/src/Esprima/JavaScriptParser.cs +++ b/src/Esprima/JavaScriptParser.cs @@ -1739,16 +1739,18 @@ private ImportExpression ParseImportCall() _context.IsAssignmentTarget = previousIsAssignmentTarget; - if (!this.Match(")") && _tolerant) - { - this.TolerateUnexpectedToken(this.NextToken()); - } - else + if (!this.Match(")")) { if (Match(",")) + { NextToken(); + } this.Expect(")"); } + else + { + NextToken(); + } return Finalize(node, new ImportExpression(source, attributes)); } diff --git a/test/Esprima.Tests.Test262/Program.cs b/test/Esprima.Tests.Test262/Program.cs index 1aa8bc1b..33f57803 100644 --- a/test/Esprima.Tests.Test262/Program.cs +++ b/test/Esprima.Tests.Test262/Program.cs @@ -82,7 +82,18 @@ public static async Task Main(string[] args) }, IsIgnored = file => file.Features.IndexOfAny(excludedFeatures.AsSpan()) != -1 || knownFailing.Contains(file.ToString()), IsParseError = exception => exception is ParserException, - ShouldThrow = file => file.NegativeTestCase?.Type == ExpectedErrorType.SyntaxError || file.NegativeTestCase?.Phase == TestingPhase.Parse, + ShouldThrow = file => + { + var negativeTestCase = file.NegativeTestCase; + if (negativeTestCase is null) + { + return false; + } + + return negativeTestCase.Type == ExpectedErrorType.SyntaxError + && negativeTestCase.Phase != TestingPhase.Resolution + && negativeTestCase.Phase != TestingPhase.Runtime; + }, OnTestExecuted = _ => testTask.Increment(1) }; diff --git a/test/Esprima.Tests.Test262/Test262Harness.settings.json b/test/Esprima.Tests.Test262/Test262Harness.settings.json index 69d5ec0c..c759eb6d 100644 --- a/test/Esprima.Tests.Test262/Test262Harness.settings.json +++ b/test/Esprima.Tests.Test262/Test262Harness.settings.json @@ -1,5 +1,5 @@ { - "SuiteGitSha": "83a46bfe0e79aed8274a1b9f4beb0a2efa0b3533", + "SuiteGitSha": "2060494f280ba89d71a0f51d4ff171bafe476a05", //"SuiteDirectory": "//mnt/c/work/test262", "TargetPath": "./Generated", "Namespace": "Esprima.Tests.Test262", diff --git a/test/Esprima.Tests.Test262/Test262Test.cs b/test/Esprima.Tests.Test262/Test262Test.cs index 3fc5df67..6f1ad1fe 100644 --- a/test/Esprima.Tests.Test262/Test262Test.cs +++ b/test/Esprima.Tests.Test262/Test262Test.cs @@ -6,10 +6,7 @@ public abstract partial class Test262Test { private JavaScriptParser BuildTestExecutor(Test262File file) { - var options = new ParserOptions() - { - Tolerant = false - }; + var options = new ParserOptions() { Tolerant = false }; return new JavaScriptParser(options); } @@ -27,6 +24,15 @@ private static void ExecuteTest(JavaScriptParser parser, Test262File file) private partial bool ShouldThrow(Test262File testCase, bool strict) { - return testCase.NegativeTestCase?.Type == ExpectedErrorType.SyntaxError || testCase.NegativeTestCase?.Phase == TestingPhase.Parse; + var negativeTestCase = testCase.NegativeTestCase; + + if (negativeTestCase is null) + { + return false; + } + + return negativeTestCase.Type == ExpectedErrorType.SyntaxError + && negativeTestCase.Phase != TestingPhase.Resolution + && negativeTestCase.Phase != TestingPhase.Runtime; } } diff --git a/test/Esprima.Tests.Test262/allow-list.txt b/test/Esprima.Tests.Test262/allow-list.txt index f0fc6f9e..e1edea64 100644 --- a/test/Esprima.Tests.Test262/allow-list.txt +++ b/test/Esprima.Tests.Test262/allow-list.txt @@ -962,10 +962,6 @@ test/language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-g test/language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-generator.js(strict mode) test/language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-let.js(default) test/language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-let.js(strict mode) -test/language/eval-code/direct/strict-caller-global.js(strict mode) -test/language/eval-code/direct/var-env-global-lex-non-strict.js(default) -test/language/eval-code/indirect/parse-failure-2.js(default) -test/language/eval-code/indirect/parse-failure-2.js(strict mode) test/language/export/escaped-as-export-specifier.js(strict mode) test/language/export/escaped-from.js(strict mode) test/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-ary.js(default) @@ -1234,8 +1230,6 @@ test/language/expressions/tagged-template/invalid-escape-sequences.js(default) test/language/expressions/tagged-template/invalid-escape-sequences.js(strict mode) test/language/expressions/yield/rhs-template-middle.js(default) test/language/expressions/yield/rhs-template-middle.js(strict mode) -test/language/global-code/decl-lex-restricted-global.js(default) -test/language/global-code/decl-lex-restricted-global.js(strict mode) test/language/global-code/new.target-arrow.js(default) test/language/global-code/new.target-arrow.js(strict mode) test/language/identifier-resolution/static-init-invalid-await.js(default) @@ -1244,6 +1238,11 @@ test/language/import/dup-bound-names.js(strict mode) test/language/import/escaped-as-import-specifier.js(strict mode) test/language/import/escaped-as-namespace-import.js(strict mode) test/language/import/escaped-from.js(strict mode) +test/language/import/import-attributes/json-invalid.js(strict mode) +test/language/import/import-attributes/json-named-bindings.js(strict mode) +test/language/literals/boolean/false-with-unicode.js(default) +test/language/literals/boolean/true-with-unicode.js(default) +test/language/literals/null/null-with-unicode.js(default) test/language/literals/regexp/named-groups/forward-reference.js(default) test/language/literals/regexp/named-groups/forward-reference.js(strict mode) test/language/module-code/comment-multi-line-html-close.js(strict mode) @@ -1276,28 +1275,6 @@ test/language/module-code/export-expname-from-unpaired-surrogate.js(strict mode) test/language/module-code/export-expname-import-unpaired-surrogate.js(strict mode) test/language/module-code/export-expname-string-binding.js(strict mode) test/language/module-code/export-expname-unpaired-surrogate.js(strict mode) -test/language/module-code/instn-iee-err-ambiguous-as.js(strict mode) -test/language/module-code/instn-iee-err-ambiguous.js(strict mode) -test/language/module-code/instn-iee-err-circular-as.js(strict mode) -test/language/module-code/instn-iee-err-circular.js(strict mode) -test/language/module-code/instn-iee-err-dflt-thru-star-as.js(strict mode) -test/language/module-code/instn-iee-err-dflt-thru-star.js(strict mode) -test/language/module-code/instn-iee-err-not-found-as.js(strict mode) -test/language/module-code/instn-iee-err-not-found.js(strict mode) -test/language/module-code/instn-named-err-ambiguous-as.js(strict mode) -test/language/module-code/instn-named-err-ambiguous.js(strict mode) -test/language/module-code/instn-named-err-dflt-thru-star-as.js(strict mode) -test/language/module-code/instn-named-err-dflt-thru-star-dflt.js(strict mode) -test/language/module-code/instn-named-err-not-found-as.js(strict mode) -test/language/module-code/instn-named-err-not-found-dflt.js(strict mode) -test/language/module-code/instn-named-err-not-found.js(strict mode) -test/language/module-code/instn-resolve-empty-export.js(strict mode) -test/language/module-code/instn-resolve-empty-import.js(strict mode) -test/language/module-code/instn-resolve-err-syntax-1.js(strict mode) -test/language/module-code/instn-resolve-err-syntax-2.js(strict mode) -test/language/module-code/instn-resolve-order-depth.js(strict mode) -test/language/module-code/instn-resolve-order-src.js(strict mode) -test/language/module-code/instn-star-err-not-found.js(strict mode) test/language/module-code/parse-err-decl-pos-export-block-stmt-list.js(strict mode) test/language/module-code/parse-err-decl-pos-export-block-stmt.js(strict mode) test/language/module-code/parse-err-decl-pos-export-switch-case-dflt.js(strict mode)