Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to run tests in both strict mode and non-strict mode #35

Closed
bterlson opened this issue Jun 4, 2014 · 19 comments
Closed

Need to run tests in both strict mode and non-strict mode #35

bterlson opened this issue Jun 4, 2014 · 19 comments
Labels

Comments

@bterlson
Copy link
Member

bterlson commented Jun 4, 2014

If a test doesn't indicate that it's specifically for sloppy or strict mode it should be run in both. This change should be made at least for the web harness, but also perhaps for the python harness.

@bterlson
Copy link
Member Author

bterlson commented Jul 6, 2014

(@erights, just fyi)

Investigated this a bit today. Unfortunately this is not easy as many test cases are noStrict due to verifications they do. For example, ES5 15.2.3.5-4-214.js:

function testcase() {
        var descObj = {
            writable: ""
        };

        var newObj = Object.create({}, {
            prop: descObj
        });
        var hasProperty = newObj.hasOwnProperty("prop") && typeof newObj.prop === "undefined";

        newObj.prop = 121;

        return hasProperty && typeof newObj.prop === "undefined";
    }
runTestCase(testcase);

Similar cases exist when ensuring a non-extensible object can't be extended and a non-configurable property can't be deleted.

I don't have an exact count of cases affected but I can confidently say it's over 100.

A quick fix might be to tag these tests noStrict, but ideally the verification steps should be fixed to work in strict and non-strict.

anba added a commit to anba/test262 that referenced this issue Aug 5, 2014
This change adds 'var' declarations for global variables to allow the tests to run in strict mode (see issue tc39#35).
Extra care was taken to ensure the changes do not alter the test behavior, for example when implicit creation of global variables are part of the test.
Note: The change does not fix all strict mode errors due to missing 'var' declarations.
bterlson pushed a commit that referenced this issue Dec 11, 2014
This change adds 'var' declarations for global variables to allow the tests to run in strict mode (see issue #35).
Extra care was taken to ensure the changes do not alter the test behavior, for example when implicit creation of global variables are part of the test.
Note: The change does not fix all strict mode errors due to missing 'var' declarations.
@bterlson
Copy link
Member Author

I think at this point we can track individual test failures as bugs. Thanks to lots of work from @anba and @smikes we should be mostly strict clean right now!

@anba
Copy link
Contributor

anba commented Dec 11, 2014

we should be mostly strict clean right now!

I don't want to be the bearer of bad news, but there are still more than 1200 tests failing when running in strict mode. 😢

@bterlson
Copy link
Member Author

@anba noooo! I guess I messed up my harness command or something :(

@bterlson bterlson reopened this Dec 12, 2014
@anba
Copy link
Contributor

anba commented Dec 12, 2014

@smikes
Copy link
Contributor

smikes commented Dec 12, 2014

@anba I see those too. I believe there is a race in test262-harness that causes failures when many tests are queued, because when I rerun them individually they succeed, eg

$ test262-harness test/built-ins/RegExp/*.js
[lots of failures]
FAIL test/built-ins/RegExp/S15.10.3.1_A2_T2.js
     Checking if using dafined variable "x = 1" as flags leads to throwing the correct exception
     Exp: no error
     Got: ReferenceError: __patterns is not defined
       at evalmachine.<anonymous>:13:69
       at Socket.<anonymous> (/Users/smikes/src/github/test262-harness/lib/runners/nodehost.js:33:12)
       at Socket.emit (events.js:95:17)
       at Socket.<anonymous> (_stream_readable.js:764:14)
       at Socket.emit (events.js:92:17)
       at emitReadable_ (_stream_readable.js:426:10)
       at emitReadable (_stream_readable.js:422:5)
       at readableAddChunk (_stream_readable.js:165:9)
       at Socket.Readable.push (_stream_readable.js:127:10)
       at Pipe.onread (net.js:528:21)

Ran 407 tests
373 passed
34 failed
Took 2.371 seconds
$ test262-harness test/built-ins/RegExp/S15.10.3.1_A2_T2.js 
Ran 1 tests
1 passed
0 failed
Took 0.102 seconds

@anba
Copy link
Contributor

anba commented Dec 12, 2014

@smikes __patterns only appears in RegExp/15.10.2_A1_T1, so the file name in the harness output is definitely wrong. Also: Running 15.10.2_A1_T1 with the --testStrict option should report a failure for strict mode. That works for me when using -r jsshell. It did not work for me with -r node and -r node-ip.

Update: It's still broken with node@0.12, but it works as expected in io.js@0.12

@erights
Copy link
Contributor

erights commented Feb 15, 2015

What's the status of this?

@anba
Copy link
Contributor

anba commented Feb 15, 2015

What's the status of this?

The numbers from my earlier comment still apply, so ~1200 failing tests.

anba added a commit to anba/test262 that referenced this issue Mar 23, 2015
…ed result value to a previously declared global (issue tc39#35)
anba added a commit to anba/test262 that referenced this issue Mar 23, 2015
anba added a commit to anba/test262 that referenced this issue Mar 23, 2015
anba added a commit to anba/test262 that referenced this issue Mar 23, 2015
- Add missing noStrict flags.
- Change 13.2-15-1 and 13.2-18-1 to use assert.js and propertyHelper.js (simplifies writable and configurable checks while in strict mode).
- Add variable declarations for globals.
- Create copies of S13.2.1_A6_T1 and S13.2.1_A6_T2 instead of adding variable declarations, because both files seem to test implicit global variables.
- Split S13_A14 and S13_A16 to work in strict mode.
- Remove assignment to .name property.
anba added a commit to anba/test262 that referenced this issue Mar 23, 2015
anba added a commit to anba/test262 that referenced this issue Mar 23, 2015
bterlson pushed a commit that referenced this issue Apr 8, 2015
…ed result value to a previously declared global (issue #35)

Add missing variable declarations (issue #35)

Split S12.6.3_A10 and S12.6.3_A10.1 because both files seem to test implicit global variables (issue #35)

Changes (issue #35)

- Add missing noStrict flags.
- Change 13.2-15-1 and 13.2-18-1 to use assert.js and propertyHelper.js (simplifies writable and configurable checks while in strict mode).
- Add variable declarations for globals.
- Create copies of S13.2.1_A6_T1 and S13.2.1_A6_T2 instead of adding variable declarations, because both files seem to test implicit global variables.
- Split S13_A14 and S13_A16 to work in strict mode.
- Remove assignment to .name property.

Add missing noStrict flags (issue #35)

Add missing noStrict flags and variable declarations (issue #35)

Add missing noStrict flags (issue #35)
anba added a commit to anba/test262 that referenced this issue Apr 29, 2015
- Add missing "var" declarations and noStrict flags
- Move code which requires non-strict semantics from Array.prototype.find_this-arg.js to Array.prototype.find_this-arg-receiver-primitive.js
- Remove duplicate code from Array.prototype.findIndex_this-arg.js, already present in Array.prototype.findIndex_this-arg-receiver-primitive.js
- Remove test code from Array.of_assignment-to-new-object-length.js, does not work in strict mode

Part of issue tc39#35
anba added a commit to anba/test262 that referenced this issue Apr 29, 2015
Add missing "var" declarations and noStrict flags.

Part of issue tc39#35.
anba added a commit to anba/test262 that referenced this issue Apr 29, 2015
Add missing "var" declarations and noStrict flags.

Part of issue tc39#35.
anba added a commit to anba/test262 that referenced this issue Apr 29, 2015
Add missing "var" declarations and noStrict flags.

Part of issue tc39#35.
anba added a commit to anba/test262 that referenced this issue Apr 29, 2015
Add missing "var" declarations and noStrict flags.

Part of issue tc39#35.
anba added a commit to anba/test262 that referenced this issue Apr 29, 2015
Add missing "var" declarations.

Part of issue tc39#35.
@bterlson
Copy link
Member Author

@anba, any comments on how much further to go after your latest PRs?

@anba
Copy link
Contributor

anba commented Apr 30, 2015

@anba, any comments on how much further to go after your latest PRs?

  • ~240 files in built-ins/Object: All remaining Object tests require changes to use propertyHelper functions.
  • 72 files in language: I still need to decide how to handle tests using eval. I think I'll convert eval("var x = 0;"); if (x !== 0) { ... } to var result = eval("var x = 0; x); if (result !== 0) { ... }, but I haven't yet made a final decision. (See language/line-terminators and language/white-space for examples where this is necessary.)

@smikes
Copy link
Contributor

smikes commented Apr 30, 2015

I can take on the Object tests , if that would help.

@anba
Copy link
Contributor

anba commented Apr 30, 2015

I can take on the Object tests , if that would help.

Sure. Only a handful of test cases were changed in #249, the rest still needs some work.

@smikes
Copy link
Contributor

smikes commented May 1, 2015

Working on that this morning.

anba added a commit to anba/test262 that referenced this issue May 8, 2015
- Add missing "var" declarations and noStrict flags
- Add strict mode tests for:
 - arguments-object/10.6-6-3 -> arguments-object/10.6-6-3-s
 - arguments-object/10.6-6-4 -> arguments-object/10.6-6-4-s
- Remove try-finally clean-up code
- Add strict mode compatible tests for eval-code/S10.4.2_A1.1_T*
  - No strict mode compatible files added for eval-code/S10.4.2_A1.2_T*, because it doesn't really make sense in this context.
  - (S10.4.2_A1.1 and S10.4.2_A1.2 should probably be removed, because the tested behaviour is not required by the spec.)
- Split S8.5_A10, S8.5_A4 and S8.1_A3 into declaration (both modes) and assignment tests (non-strict only)

Part of issue tc39#35.
anba added a commit to anba/test262 that referenced this issue May 8, 2015
…ite-space}

Make tests strict mode compatible by assigning result value to a separate variable.

Part of issue tc39#35.
anba added a commit to anba/test262 that referenced this issue May 8, 2015
Add missing noStrict flags and variable declarations.

Part of issue tc39#35.
@bterlson
Copy link
Member Author

What's left? :-D

@anba
Copy link
Contributor

anba commented May 13, 2015

What's left? :-D

All tests work now in both modes! 😄

The only thing left is updating the python runner to use the new default.

diff --git a/tools/packaging/test262.py b/tools/packaging/test262.py
index b9172b0..ed8939e 100755
--- a/tools/packaging/test262.py
+++ b/tools/packaging/test262.py
@@ -66,9 +66,7 @@ def BuildOptions():
                     help="Test only strict mode")
   result.add_option("--non_strict_only", default=False, action="store_true",
                     help="Test only non-strict mode")
-  # TODO: Once enough tests are made strict compat, change the default
-  # to "both"
-  result.add_option("--unmarked_default", default="non_strict",
+  result.add_option("--unmarked_default", default="both",
                     help="default mode for tests of unspecified strictness")
   result.add_option("--logname", help="Filename to save stdout to")
   result.add_option("--junitname", help="Filename to save test results in JUnit XML format")

@smikes
Copy link
Contributor

smikes commented May 13, 2015

🎉

@bterlson
Copy link
Member Author

Done!!! 🍰 🍨 🎈 🎉

@bterlson
Copy link
Member Author

@anba, @smikes, thanks! ❤️

FrankYFTang added a commit to FrankYFTang/test262 that referenced this issue Feb 8, 2019
Per  https://tc39.github.io/ecma402/#sec-canonicalizelanguagetag
6.2.3 CanonicalizeLanguageTag ( locale )
The CanonicalizeLanguageTag abstract operation returns the canonical and case-regularized form of the locale argument (which must be a String value that is a structurally valid Unicode BCP 47 Locale Identifier as verified by the IsStructurallyValidLanguageTag abstract operation). A conforming implementation shall take the steps specified in the “BCP 47 Language Tag to Unicode BCP 47 Locale Identifier” algorithm, from Unicode Technical Standard tc39#35 LDML § 3.3.1 BCP 47 Language Tag Conversion.

And
http://unicode.org/reports/tr35/#BCP_47_Language_Tag_Conversion
"
2. If the BCP 47 primary language subtag matches the type attribute of a languageAlias element in Supplemental Data, replace the language subtag with the replacement value.
If there are additional subtags in the replacement value, add them to the result, but only if there is no corresponding subtag already in the tag.
"
and
https://www.unicode.org/repos/cldr/trunk/common/supplemental/supplementalMetadata.xml
...
<languageAlias type="aar" replacement="aa" reason="overlong"/>
 <!--  [Afar]  -->
...
<languageAlias type="ces" replacement="cs" reason="overlong"/>
 <!--  [Czech]  -->
...
<languageAlias type="heb" replacement="he" reason="overlong"/>
 <!--  [Hebrew]  -->
rwaldron pushed a commit that referenced this issue Feb 14, 2019
Per  https://tc39.github.io/ecma402/#sec-canonicalizelanguagetag
6.2.3 CanonicalizeLanguageTag ( locale )
The CanonicalizeLanguageTag abstract operation returns the canonical and case-regularized form of the locale argument (which must be a String value that is a structurally valid Unicode BCP 47 Locale Identifier as verified by the IsStructurallyValidLanguageTag abstract operation). A conforming implementation shall take the steps specified in the “BCP 47 Language Tag to Unicode BCP 47 Locale Identifier” algorithm, from Unicode Technical Standard #35 LDML § 3.3.1 BCP 47 Language Tag Conversion.

And
http://unicode.org/reports/tr35/#BCP_47_Language_Tag_Conversion
"
2. If the BCP 47 primary language subtag matches the type attribute of a languageAlias element in Supplemental Data, replace the language subtag with the replacement value.
If there are additional subtags in the replacement value, add them to the result, but only if there is no corresponding subtag already in the tag.
"
and
https://www.unicode.org/repos/cldr/trunk/common/supplemental/supplementalMetadata.xml
...
<languageAlias type="aar" replacement="aa" reason="overlong"/>
 <!--  [Afar]  -->
...
<languageAlias type="ces" replacement="cs" reason="overlong"/>
 <!--  [Czech]  -->
...
<languageAlias type="heb" replacement="he" reason="overlong"/>
 <!--  [Hebrew]  -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants