test(js): match negative type Test262Error by constructor name#87
Open
codymullins wants to merge 2 commits into
Open
test(js): match negative type Test262Error by constructor name#87codymullins wants to merge 2 commits into
codymullins wants to merge 2 commits into
Conversation
The Test262 runner classified a negative test's thrown error by reading the instance's name property. Built-in errors expose their type that way (TypeError.prototype.name and friends), but the harness Test262Error is a plain function that sets only message, so its instances have no name. Every test with 'negative type: Test262Error' was therefore scored as a failure (expected Test262Error, threw Error) even though the engine threw the right error and terminated the comment correctly. Fall back to the thrown value's constructor name when the instance has no name, which is what the official test262 runner matches against. The engine was already correct. This removes a harness false negative. language/line-terminators: 82.9% -> 100.0% (68/82 -> 82/82). language/module-code: +2 (the two Test262Error module tests).
Add unit tests for the runner's ErrorName: a Test262Error instance (no name property) resolves by its constructor name, a built-in error still resolves by name, an own name wins over the constructor name, and a thrown primitive has no error name. ErrorName is relaxed to internal so the test in the same assembly can call it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Every Test262 negative test with
type: Test262Errorwas scored as a failure even though the engine ran them correctly:Root cause — harness false negative, not an engine bug
The runner's
ErrorNameclassified a thrown error by reading the instance'snameproperty. Built-in errors expose their type that way (TypeError.prototype.nameand friends), but the harness'sTest262Error(defined insta.js) is a plain function that sets onlymessage— its instances have nonameanywhere on the prototype chain. SoErrorNamereturned null, the negative-type match failed, andFormatThrowdefaulted the display to "Error".These tests put a line terminator (CR / LF / U+2028 / U+2029) inside or after a comment, then
throw new Test262Error()on the next line. The engine was terminating the comment correctly — thethrowran (that's why we saw "threw", not "no throw"); the runner just mislabeled the thrown type.Fix
When the thrown instance has no
name, fall back to its constructor's name — which is what the official test262 runner matches a negativetypeagainst. The change is additive: built-in-error tests already have.name, so their matching is unchanged.Result (Test262,
languagescope)language/line-terminatorslanguage/module-code+16 scenarios total, all from correctly recognizing
Test262Error— exactly the 9type: Test262Errorfiles in the language scope (7 line-terminators + 2 module-code), each in its run modes.Remaining
module-codefailures are unrelated genuine engine gaps (module name binding, TDZ, namespace internals) — out of scope here.