From 75e8a317a2729eb5f3dc32dfd94c5c073e9fad3e Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 7 Aug 2018 14:35:13 +0200 Subject: [PATCH] Remove assert.throws.early Negative tests are the better approach for early error tests. Closes #1622. --- CONTRIBUTING.md | 3 +-- harness/assert.js | 7 ------- .../assert-throws-early-incorrect-ctor.js | 20 ------------------- test/harness/assert-throws-early-not-early.js | 11 ---------- .../assert-throws-early-referenceerror.js | 9 --------- .../assert-throws-early-syntaxerror.js | 9 --------- 6 files changed, 1 insertion(+), 58 deletions(-) delete mode 100644 test/harness/assert-throws-early-incorrect-ctor.js delete mode 100644 test/harness/assert-throws-early-not-early.js delete mode 100644 test/harness/assert-throws-early-referenceerror.js delete mode 100644 test/harness/assert-throws-early-syntaxerror.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53ec851c4a..76f1972a34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -163,7 +163,7 @@ This tag is for boolean properties associated with the test. #### features **features**: [list] -Some tests require the use of language features that are not directly described by the test file's location in the directory structure. These features should be specified with this tag. See the `features.txt` file for a complete list of available values. This tag is required for new tests written for new features, but contributions will not be "blocked" if the tag is missing from frontmatter. The committing maintainer is required to ensure that the tag is present and contains the correct feature names; this can be done in an follow up commit. +Some tests require the use of language features that are not directly described by the test file's location in the directory structure. These features should be specified with this tag. See the `features.txt` file for a complete list of available values. This tag is required for new tests written for new features, but contributions will not be "blocked" if the tag is missing from frontmatter. The committing maintainer is required to ensure that the tag is present and contains the correct feature names; this can be done in an follow up commit. #### es5id **es5id**: [es5-test-id] @@ -195,7 +195,6 @@ assert(value, message) | throw a new Test262Error instance if the specified valu assert.sameValue(actual, expected, message) | throw a new Test262Error instance if the first two arguments are not [the same value](https://tc39.github.io/ecma262/#sec-samevalue); accepts an optional string message for use in creating the error assert.notSameValue(actual, unexpected, message) | throw a new Test262Error instance if the first two arguments are [the same value](https://tc39.github.io/ecma262/#sec-samevalue); accepts an optional string message for use in creating the error assert.throws(expectedErrorConstructor, fn, message) | throw a new Test262Error instance if the provided function does not throw an error, or if the constructor of the value thrown does not match the provided constructor -assert.throws.early(expectedErrorConstructor, code) | throw a new Test262Error instance if the provided code does not throw an early error, or if the constructor of the value thrown does not match the provided constructor. This assertion catches only errors that will be parsed through `Function(code)`. $ERROR(message) | construct a Test262Error object and throw it
**DEPRECATED** -- Do not use in new tests. Use `assert`, `assert.*`, or `throw new Test262Error` instead. ``` diff --git a/harness/assert.js b/harness/assert.js index 5fbc122541..58e98e37b7 100644 --- a/harness/assert.js +++ b/harness/assert.js @@ -86,10 +86,3 @@ assert.throws = function (expectedErrorConstructor, func, message) { message += 'Expected a ' + expectedErrorConstructor.name + ' to be thrown but no exception was thrown at all'; $ERROR(message); }; - -assert.throws.early = function(err, code) { - var wrappedCode = 'function wrapperFn() { ' + code + ' }'; - var ieval = eval; - - assert.throws(err, function() { Function(wrappedCode); }, 'Function: ' + code); -}; diff --git a/test/harness/assert-throws-early-incorrect-ctor.js b/test/harness/assert-throws-early-incorrect-ctor.js deleted file mode 100644 index c291c930a5..0000000000 --- a/test/harness/assert-throws-early-incorrect-ctor.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2017 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - Functions that throw values whose constructor does not match the specified - constructor do not satisfy the assertion. ----*/ - -// monkeypatch the API -$ERROR = function $ERROR(message) { - throw new Test262Error(message); -}; - -assert.throws(Test262Error, () => { - assert.throws.early(SyntaxError, "1 = 1;"); -}, "'1=1' is a ReferenceError"); -assert.throws(Test262Error, () => { - assert.throws.early(ReferenceError, "var;"); -}, "'var;' is a SyntaxError"); diff --git a/test/harness/assert-throws-early-not-early.js b/test/harness/assert-throws-early-not-early.js deleted file mode 100644 index f7b721fe61..0000000000 --- a/test/harness/assert-throws-early-not-early.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2017 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - The assertion fails when the code does not parse with an early error -includes: [sta.js] ----*/ -assert.throws(Test262Error, () => { - assert.throws.early(ReferenceError, 'x = 1'); -}); diff --git a/test/harness/assert-throws-early-referenceerror.js b/test/harness/assert-throws-early-referenceerror.js deleted file mode 100644 index fbb667f1cb..0000000000 --- a/test/harness/assert-throws-early-referenceerror.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2017 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - The assertion pass when the code parses with an early ReferenceError ----*/ - -assert.throws.early(ReferenceError, '1 = 1;'); diff --git a/test/harness/assert-throws-early-syntaxerror.js b/test/harness/assert-throws-early-syntaxerror.js deleted file mode 100644 index 0e047d0f0f..0000000000 --- a/test/harness/assert-throws-early-syntaxerror.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2017 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - The assertion pass when the code parses with an early SyntaxError ----*/ - -assert.throws.early(SyntaxError, 'let let');