Update documentation

This commit is contained in:
Mike Pennisi 2016-03-13 13:26:10 -04:00
parent 2915fe8527
commit 0d4a07ba8c
2 changed files with 35 additions and 8 deletions

View File

@ -70,14 +70,21 @@ Eg: Object.prototype.toString - '[object Null]' will be returned when
'this' value is null 'this' value is null
#### negative #### negative
**negative**: [regex] **negative**: [dictionary containing **phase** and **type**]
This means the test is expected to throw an error of the given type. If no error is thrown, a test failure is reported. This means the test is expected to throw an error of the given type. If no error is thrown, a test failure is reported.
If an error is thrown, it is implicitly converted to a string. The second parameter is a regular expression that will be matched against this string. If the match fails, a test failure is reported. Thus the regular expression can match either the error name, or the message contents, or both. - **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 "early" 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.
For best practices on how to use the negative tag please see Handling Errors and Negative Test Cases, below. For best practices on how to use the negative tag please see Handling Errors and Negative Test Cases, below.
For example:
negative:
phase: early
type: ReferenceError
#### es5id #### es5id
**es5id**: [es5-test-id] **es5id**: [es5-test-id]
@ -181,7 +188,9 @@ Expectations for **parsing errors** should be declared using [the `negative` fro
```javascript ```javascript
/*--- /*---
negative: SyntaxError negative:
phase: early
type: SyntaxError
---*/ ---*/
// This `throw` statement guarantees that no code is executed in order to // This `throw` statement guarantees that no code is executed in order to

View File

@ -117,20 +117,38 @@ structured as [YAML](http://yaml.org/).
### `negative` ### `negative`
These tests are expected to generate an uncaught exception. The value of this These tests are expected to generate an uncaught exception. The value of this
attribute is the name of the constructor of the expected error. If a test attribute is a YAML dictonary with two keys:
configured with the `negative` attribute completes without throwing an
exception, or if the name of the thrown exception's constructor does not match - `phase` - the stage of the test interpretation process that the error is
the specified constructor name, the test must be interpreted as "failing." expected to be produced; either "early" (meaning, "prior to evaluation") or
"runtime" (meaning, "during evaluation"); in the case of "early", additional
test transformation may be required--see below
- `type` - the name of the constructor of the expected error
If a test configured with the `negative` attribute completes without throwing
an exception, or if the name of the thrown exception's constructor does not
match the specified constructor name, or if the error occurs at a phase that
differs from the indicated phase, the test must be interpreted as "failing."
*Example:* *Example:*
```js ```js
/*--- /*---
negative: ReferenceError negative:
phase: runtime
type: ReferenceError
---*/ ---*/
unresolvable; unresolvable;
``` ```
Consumers are free to assert the "early" phase as they see fit.
For example, it is possible to insert a `throw` statement with a unique error
type at the beginning of the test file. In this case, the statement should be
inserted *after* the directive desribed in the section titled "Strict Mode"
(where appropriate), though it must *not* be inserted for tests containing the
"raw" flag.
### `includes` ### `includes`
One or more files whose content must be evaluated in the test realm's global One or more files whose content must be evaluated in the test realm's global