Fix harness/sm/non262-strict-shell.js for strict mode#5008
Open
Fix harness/sm/non262-strict-shell.js for strict mode#5008
Conversation
This code is broken when run in strict mode as eval() inherits strictness from its scope and causes e.g. testLenientAndStrict() method to run both parts in strict mode. Wrap eval() inside a Function() to properly implement strict->sloppy transition.
Contributor
|
Alternatively, maybe we could mark all tests using |
Author
|
Yes, either way works. I can rewrite PR instead to mark these tests as noStrict. I also later noticed |
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.
harness/sm/non262-strict-shell.jsis problematic and causes discrepancies between different test262 runners intest/staging/sm/strict/tests depending on minor implementation details of the runners.Some (most?) test262 runners e.g. test262-harness + eshost, boa, execute tests by concatenating
'use strict'in strict mode, harness code and test code into a single file to be executed by the engine. This causesharness/sm/non262-strict-shell.jsto be run in strict scope and breaks its eval-basedtestLenientAndStrict()method aseval()inherits strictness.Others e.g. libjs test262-runner run harness code in a separate scope from test code and able to pass
test/staging/sm/strict/tests in both modes in this way. This is easy to do for a test262 runner integrated with an engine, but also an easy detail to miss for implementers (as evidenced by boa's test runner), and awkward to implement in a general eshost-style runner.I propose fixing the harness code - wrap
eval()which inherits strictness with aFunction()which doesn't.