Document raw negative test reqs

This commit is contained in:
Leo Balter 2019-02-05 15:38:12 -05:00 committed by Rick Waldron
parent 8e0c0eac10
commit 9558093416
1 changed files with 17 additions and 1 deletions

View File

@ -197,7 +197,8 @@ Function | Purpose
`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
`$DONOTEVALUATE()` | throw an exception if the code gets evaluated. This is useful for [negative test cases for parsing errors](#handling-errors-and-negative-test-cases)
`$DONOTEVALUATE()` | throw an exception if the code gets evaluated. This is useful for [negative test cases for parsing errors](#handling-errors-and-negative-test-cases).
`throw "Test262: This statement should not be evaluated.";` | throw an exception if the code gets evaluated. Use this if the test file has the `raw` flag and it's a negative test case for parsing error.
`$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.
```javascript
@ -223,6 +224,21 @@ $DONOTEVALUATE();
var var = var;
```
If the test case has the `raw` flag, this disallows the test to load any harness file including `$DONOTEVALUATE`. In this case, include a direct `throw "Test262: This statement should not be evaluated.";` statement:
```javascript
/*---
flags: [raw]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
var var = var;
```
Expectations for **runtime errors** should be defined using the `assert.throws` method and the appropriate JavaScript Error constructor function:
```javascript