Remove assert.throws.early

Negative tests are the better approach for early error tests.

Closes #1622.
This commit is contained in:
Mathias Bynens 2018-08-07 14:35:13 +02:00
parent 48d95ac3c4
commit 75e8a317a2
6 changed files with 1 additions and 58 deletions

View File

@ -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 <br>**DEPRECATED** -- Do not use in new tests. Use `assert`, `assert.*`, or `throw new Test262Error` instead.
```

View File

@ -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);
};

View File

@ -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");

View File

@ -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');
});

View File

@ -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;');

View File

@ -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');