diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 582974de8d..1a3e8ddd32 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,7 +103,7 @@ single line comment syntax. This means the test is expected to throw an error of the given type. If no error is thrown, a test failure is reported. - **type**- If an error is thrown, it is implicitly converted to a string. In order for the test to pass, this value must match the name of the error constructor. -- **phase** - Negative tests whose **phase** value is "parse" must produce the specified error prior to executing code. The value "runtime" dictates that the error is expected to be produced as a result of executing the test code. +- **phase** - Negative tests whose **phase** value is "parse" must produce the specified error prior to executing code. The value "resolution" indicates that the error is expected to result while performing ES2015 module resolution. The value "runtime" dictates that the error is expected to be produced as a result of executing the test code. For best practices on how to use the negative tag please see [Handling Errors and Negative Test Cases](#handling-errors-and-negative-test-cases), below. diff --git a/INTERPRETING.md b/INTERPRETING.md index c3a31bb652..0a10c7fd24 100644 --- a/INTERPRETING.md +++ b/INTERPRETING.md @@ -162,8 +162,9 @@ attribute is a YAML dictonary with two keys: - `phase` - the stage of the test interpretation process that the error is expected to be produced; either "parse" (meaning, "while parsing the source - text"), "early" (meaning, "prior to evaluation") or "runtime" (meaning, - "during evaluation") + text"), "early" (meaning, "prior to evaluation"), "resolution" (meaining, + "during ES2015 module resolution"), or "runtime" (meaning, "during + evaluation") - `type` - the name of the constructor of the expected error If a test configured with the `negative` attribute completes without throwing diff --git a/test/language/module-code/instn-resolve-empty-export.js b/test/language/module-code/instn-resolve-empty-export.js index d602d809ad..86b03d3b43 100644 --- a/test/language/module-code/instn-resolve-empty-export.js +++ b/test/language/module-code/instn-resolve-empty-export.js @@ -30,7 +30,7 @@ info: | { ExportsList } { ExportsList , } negative: - phase: early + phase: resolution type: ReferenceError flags: [module] ---*/ diff --git a/test/language/module-code/instn-resolve-empty-import.js b/test/language/module-code/instn-resolve-empty-import.js index 5dccc354e5..3a5b07f4ea 100644 --- a/test/language/module-code/instn-resolve-empty-import.js +++ b/test/language/module-code/instn-resolve-empty-import.js @@ -36,7 +36,7 @@ info: | { ImportsList } { ImportsList , } negative: - phase: early + phase: resolution type: ReferenceError flags: [module] ---*/ diff --git a/test/language/module-code/instn-resolve-err-reference.js b/test/language/module-code/instn-resolve-err-reference.js index 9e7e458fbd..1e6126f577 100644 --- a/test/language/module-code/instn-resolve-err-reference.js +++ b/test/language/module-code/instn-resolve-err-reference.js @@ -11,7 +11,7 @@ info: | b. Let requiredModule be ? HostResolveImportedModule(module, required). [...] negative: - phase: early + phase: resolution type: ReferenceError flags: [module] ---*/ diff --git a/test/language/module-code/instn-resolve-err-syntax.js b/test/language/module-code/instn-resolve-err-syntax.js index ab35934419..e26e5e9de7 100644 --- a/test/language/module-code/instn-resolve-err-syntax.js +++ b/test/language/module-code/instn-resolve-err-syntax.js @@ -11,7 +11,7 @@ info: | b. Let requiredModule be ? HostResolveImportedModule(module, required). [...] negative: - phase: early + phase: resolution type: SyntaxError flags: [module] ---*/ diff --git a/test/language/module-code/instn-resolve-order-depth.js b/test/language/module-code/instn-resolve-order-depth.js index e50de90b3f..ae889b5a60 100644 --- a/test/language/module-code/instn-resolve-order-depth.js +++ b/test/language/module-code/instn-resolve-order-depth.js @@ -4,7 +4,7 @@ description: Module dependencies are resolved following a depth-first strategy esid: sec-moduledeclarationinstantiation negative: - phase: early + phase: resolution type: ReferenceError flags: [module] ---*/ diff --git a/test/language/module-code/instn-resolve-order-src.js b/test/language/module-code/instn-resolve-order-src.js index a301f599ff..31bcbfdb9b 100644 --- a/test/language/module-code/instn-resolve-order-src.js +++ b/test/language/module-code/instn-resolve-order-src.js @@ -4,7 +4,7 @@ description: Modules dependencies are resolved in source text order esid: sec-moduledeclarationinstantiation negative: - phase: early + phase: resolution type: ReferenceError flags: [module] ---*/ diff --git a/tools/lint/lib/checks/negative.py b/tools/lint/lib/checks/negative.py index aa9ec1e406..666cde76e7 100644 --- a/tools/lint/lib/checks/negative.py +++ b/tools/lint/lib/checks/negative.py @@ -23,5 +23,5 @@ class CheckNegative(Check): if not 'phase' in negative: return '"negative" must specify a "phase" field' - if negative["phase"] == "parse" and not _THROW_STMT.search(source): + if negative["phase"] in ["parse", "resolution"] and not _THROW_STMT.search(source): return 'Negative tests of type "early" must include a `throw` statement' diff --git a/tools/lint/test/fixtures/negative_resolution_throw_bad_value.js b/tools/lint/test/fixtures/negative_resolution_throw_bad_value.js new file mode 100644 index 0000000000..daf09d5e87 --- /dev/null +++ b/tools/lint/test/fixtures/negative_resolution_throw_bad_value.js @@ -0,0 +1,16 @@ +NEGATIVE +^ expected errors | v input +// Copyright (C) 2017 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-static-semantics-early-errors +description: Minimal test +flags: [module] +negative: + type: SyntaxError + phase: resolution +---*/ + +throw "Test262: This statement should not be evaluated!"; + +import 'non-existent-module.js'; diff --git a/tools/lint/test/fixtures/negative_resolution_throw_missing.js b/tools/lint/test/fixtures/negative_resolution_throw_missing.js new file mode 100644 index 0000000000..8892676e29 --- /dev/null +++ b/tools/lint/test/fixtures/negative_resolution_throw_missing.js @@ -0,0 +1,14 @@ +NEGATIVE +^ expected errors | v input +// Copyright (C) 2017 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-static-semantics-early-errors +description: Minimal test +flags: [module] +negative: + type: SyntaxError + phase: resolution +---*/ + +import 'non-existent-module.js'; diff --git a/tools/lint/test/fixtures/negative_valid_resolution.js b/tools/lint/test/fixtures/negative_valid_resolution.js new file mode 100644 index 0000000000..b3068c7feb --- /dev/null +++ b/tools/lint/test/fixtures/negative_valid_resolution.js @@ -0,0 +1,15 @@ +^ expected errors | v input +// Copyright (C) 2017 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-assignment-operators-static-semantics-early-errors +description: Minimal test +flags: [module] +negative: + type: SyntaxError + phase: resolution +---*/ + +throw "Test262: This statement should not be evaluated."; + +import 'non-existent-module.js';