├── .gitignore ├── .jshintignore ├── .travis.yml ├── test ├── collateral │ ├── valid-version-ignored │ │ ├── fake-test262 │ │ │ ├── package.json │ │ │ ├── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ │ └── test │ │ │ │ └── strict.js │ │ ├── expected-metadata │ │ │ └── test │ │ │ │ └── strict_strict_mode.json │ │ └── expected-content │ │ │ └── test │ │ │ └── strict_strict_mode.js │ ├── invalid-version-unsupported │ │ └── fake-test262 │ │ │ ├── package.json │ │ │ ├── harness │ │ │ ├── doneprintHandle.js │ │ │ ├── assert.js │ │ │ └── sta.js │ │ │ └── test │ │ │ └── strict.js │ ├── valid-version-supported │ │ ├── fake-test262 │ │ │ ├── package.json │ │ │ ├── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ │ └── test │ │ │ │ └── strict.js │ │ ├── expected-metadata │ │ │ └── test │ │ │ │ └── strict_strict_mode.json │ │ └── expected-content │ │ │ └── test │ │ │ └── strict_strict_mode.js │ ├── invalid-version-other-accepted │ │ └── fake-test262 │ │ │ ├── package.json │ │ │ ├── harness │ │ │ ├── doneprintHandle.js │ │ │ ├── assert.js │ │ │ └── sta.js │ │ │ └── test │ │ │ └── strict.js │ ├── valid-default │ │ ├── fake-test262 │ │ │ ├── test │ │ │ │ ├── module_FIXTURE.js │ │ │ │ ├── noStrict.js │ │ │ │ ├── module.js │ │ │ │ ├── error.js │ │ │ │ ├── negative-empty.js │ │ │ │ ├── async.js │ │ │ │ ├── strict.js │ │ │ │ ├── asyncNegative.js │ │ │ │ ├── rawNoStrict.js │ │ │ │ ├── bothStrict.js │ │ │ │ └── rawStrict.js │ │ │ └── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ ├── expected-content │ │ │ └── test │ │ │ │ ├── rawNoStrict_default.js │ │ │ │ ├── rawStrict_default.js │ │ │ │ ├── noStrict_default.js │ │ │ │ ├── module_default.js │ │ │ │ ├── error_default.js │ │ │ │ ├── module_strict_mode.js │ │ │ │ ├── negative-empty_default.js │ │ │ │ ├── error_strict_mode.js │ │ │ │ ├── negative-empty_strict_mode.js │ │ │ │ ├── strict_strict_mode.js │ │ │ │ ├── async_default.js │ │ │ │ ├── bothStrict_default.js │ │ │ │ ├── async_strict_mode.js │ │ │ │ ├── bothStrict_strict_mode.js │ │ │ │ ├── asyncNegative_default.js │ │ │ │ └── asyncNegative_strict_mode.js │ │ └── expected-metadata │ │ │ └── test │ │ │ ├── rawNoStrict_default.json │ │ │ ├── rawStrict_default.json │ │ │ ├── module_default.json │ │ │ ├── noStrict_default.json │ │ │ ├── async_default.json │ │ │ ├── module_strict_mode.json │ │ │ ├── async_strict_mode.json │ │ │ ├── error_default.json │ │ │ ├── error_strict_mode.json │ │ │ ├── negative-empty_default.json │ │ │ ├── strict_strict_mode.json │ │ │ ├── asyncNegative_default.json │ │ │ ├── negative-empty_strict_mode.json │ │ │ ├── asyncNegative_strict_mode.json │ │ │ ├── bothStrict_default.json │ │ │ └── bothStrict_strict_mode.json │ ├── valid-omit-runtime │ │ ├── fake-test262 │ │ │ ├── test │ │ │ │ ├── module_FIXTURE.js │ │ │ │ ├── noStrict.js │ │ │ │ ├── module.js │ │ │ │ ├── error.js │ │ │ │ ├── negative-empty.js │ │ │ │ ├── async.js │ │ │ │ ├── strict.js │ │ │ │ ├── asyncNegative.js │ │ │ │ ├── rawNoStrict.js │ │ │ │ ├── bothStrict.js │ │ │ │ └── rawStrict.js │ │ │ └── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ ├── expected-content │ │ │ └── test │ │ │ │ ├── noStrict_default.js │ │ │ │ ├── module_default.js │ │ │ │ ├── module_strict_mode.js │ │ │ │ ├── error_default.js │ │ │ │ ├── negative-empty_default.js │ │ │ │ ├── async_default.js │ │ │ │ ├── error_strict_mode.js │ │ │ │ ├── negative-empty_strict_mode.js │ │ │ │ ├── async_strict_mode.js │ │ │ │ ├── asyncNegative_default.js │ │ │ │ ├── strict_strict_mode.js │ │ │ │ ├── asyncNegative_strict_mode.js │ │ │ │ ├── rawNoStrict_default.js │ │ │ │ ├── bothStrict_default.js │ │ │ │ ├── bothStrict_strict_mode.js │ │ │ │ └── rawStrict_default.js │ │ └── expected-metadata │ │ │ └── test │ │ │ ├── async_default.json │ │ │ ├── module_default.json │ │ │ ├── async_strict_mode.json │ │ │ ├── noStrict_default.json │ │ │ ├── rawNoStrict_default.json │ │ │ ├── module_strict_mode.json │ │ │ ├── rawStrict_default.json │ │ │ ├── error_default.json │ │ │ ├── error_strict_mode.json │ │ │ ├── asyncNegative_default.json │ │ │ ├── asyncNegative_strict_mode.json │ │ │ ├── negative-empty_default.json │ │ │ ├── strict_strict_mode.json │ │ │ ├── negative-empty_strict_mode.json │ │ │ ├── bothStrict_default.json │ │ │ └── bothStrict_strict_mode.json │ ├── valid-with-paths │ │ ├── fake-test262 │ │ │ ├── test │ │ │ │ ├── strict │ │ │ │ │ ├── no │ │ │ │ │ │ ├── noStrict.js │ │ │ │ │ │ └── rawNoStrict.js │ │ │ │ │ ├── strict.js │ │ │ │ │ └── rawStrict.js │ │ │ │ ├── error.js │ │ │ │ ├── negative-empty.js │ │ │ │ ├── async │ │ │ │ │ ├── async.js │ │ │ │ │ └── asyncNegative.js │ │ │ │ └── bothStrict.js │ │ │ └── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ ├── expected-content │ │ │ └── test │ │ │ │ ├── strict │ │ │ │ └── no │ │ │ │ │ ├── rawNoStrict_default.js │ │ │ │ │ └── noStrict_default.js │ │ │ │ ├── bothStrict_default.js │ │ │ │ ├── async │ │ │ │ ├── async_default.js │ │ │ │ ├── async_strict_mode.js │ │ │ │ ├── asyncNegative_default.js │ │ │ │ └── asyncNegative_strict_mode.js │ │ │ │ └── bothStrict_strict_mode.js │ │ └── expected-metadata │ │ │ └── test │ │ │ ├── strict │ │ │ └── no │ │ │ │ ├── rawNoStrict_default.json │ │ │ │ └── noStrict_default.json │ │ │ ├── async │ │ │ ├── async_default.json │ │ │ ├── async_strict_mode.json │ │ │ ├── asyncNegative_default.json │ │ │ └── asyncNegative_strict_mode.json │ │ │ ├── bothStrict_default.json │ │ │ └── bothStrict_strict_mode.json │ ├── valid-extra-files │ │ ├── fake-test262 │ │ │ ├── test │ │ │ │ ├── zzz-0_FIXTURE.js │ │ │ │ ├── zzz-1_FIXTURE.js │ │ │ │ ├── zzz-2_FIXTURE.js │ │ │ │ ├── zzz-3_FIXTURE.js │ │ │ │ ├── zzz-4_FIXTURE.js │ │ │ │ ├── zzz-5_FIXTURE.js │ │ │ │ ├── zzz-6_FIXTURE.js │ │ │ │ ├── zzz-7_FIXTURE.js │ │ │ │ ├── zzz-8_FIXTURE.js │ │ │ │ ├── zzz-9_FIXTURE.txt │ │ │ │ └── bothStrict.js │ │ │ └── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ ├── expected-metadata │ │ │ └── test │ │ │ │ ├── bothStrict_default.json │ │ │ │ └── bothStrict_strict_mode.json │ │ └── expected-content │ │ │ └── test │ │ │ ├── bothStrict_default.js │ │ │ └── bothStrict_strict_mode.js │ ├── valid-with-hashbang │ │ ├── fake-test262 │ │ │ ├── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ │ └── test │ │ │ │ ├── missing-raw-flag.js │ │ │ │ ├── raw.js │ │ │ │ ├── raw-with-ls.js │ │ │ │ ├── raw-with-ps.js │ │ │ │ ├── raw-with-ls-multiline-block.js │ │ │ │ ├── raw-with-ps-multiline-block.js │ │ │ │ ├── rawWithLicense.js │ │ │ │ ├── raw-with-ls-and-license-on-same-line.js │ │ │ │ └── raw-with-ps-and-license-on-same-line.js │ │ ├── expected-content │ │ │ └── test │ │ │ │ ├── raw_default.js │ │ │ │ ├── raw-with-ls_default.js │ │ │ │ ├── raw-with-ps_default.js │ │ │ │ ├── raw-with-ls-multiline-block_default.js │ │ │ │ ├── raw-with-ps-multiline-block_default.js │ │ │ │ ├── rawWithLicense_default.js │ │ │ │ ├── raw-with-ls-and-license-on-same-line_default.js │ │ │ │ ├── raw-with-ps-and-license-on-same-line_default.js │ │ │ │ ├── missing-raw-flag_default.js │ │ │ │ └── missing-raw-flag_strict_mode.js │ │ └── expected-metadata │ │ │ └── test │ │ │ ├── raw_default.json │ │ │ ├── raw-with-ls_default.json │ │ │ ├── raw-with-ps_default.json │ │ │ ├── raw-with-ls-multiline-block_default.json │ │ │ ├── raw-with-ps-multiline-block_default.json │ │ │ ├── rawWithLicense_default.json │ │ │ ├── missing-raw-flag_default.json │ │ │ ├── missing-raw-flag_strict_mode.json │ │ │ ├── raw-with-ls-and-license-on-same-line_default.json │ │ │ └── raw-with-ps-and-license-on-same-line_default.json │ ├── valid-with-includes │ │ ├── fake-test262 │ │ │ ├── harness │ │ │ │ ├── doneprintHandle.js │ │ │ │ └── assert.js │ │ │ └── test │ │ │ │ ├── async.js │ │ │ │ └── bothStrict.js │ │ ├── custom-includes │ │ │ ├── assert.js │ │ │ ├── doneprintHandle.js │ │ │ └── sta.js │ │ ├── expected-metadata │ │ │ └── test │ │ │ │ ├── async_default.json │ │ │ │ ├── async_strict_mode.json │ │ │ │ ├── bothStrict_default.json │ │ │ │ └── bothStrict_strict_mode.json │ │ └── expected-content │ │ │ └── test │ │ │ ├── bothStrict_default.js │ │ │ ├── bothStrict_strict_mode.js │ │ │ ├── async_default.js │ │ │ └── async_strict_mode.js │ ├── valid-insertionindex-with-copyright │ │ ├── fake-test262 │ │ │ ├── test │ │ │ │ ├── runtime.js │ │ │ │ └── raw.js │ │ │ └── harness │ │ │ │ ├── assert.js │ │ │ │ └── sta.js │ │ ├── expected-content │ │ │ └── test │ │ │ │ ├── raw_default.js │ │ │ │ ├── runtime_default.js │ │ │ │ └── runtime_strict_mode.js │ │ └── expected-metadata │ │ │ └── test │ │ │ ├── raw_default.json │ │ │ ├── runtime_default.json │ │ │ └── runtime_strict_mode.json │ └── invalid-missing-harness │ │ └── fake-test262 │ │ └── test │ │ └── a-test-file.js └── test.js ├── .jshintrc ├── lib ├── compile.js ├── create-scenarios.js ├── builder.js ├── test-file.js └── index.js ├── package.json ├── CONTRIBUTING.md ├── LICENSE.txt ├── LICENSE-MICROSOFT.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | /test/collateral/ 2 | /lib/compilerdeps.js 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - 6 5 | - 8 6 | -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/fake-test262/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "999.0.0" 3 | } 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esversion": 6, 3 | "node": true, 4 | "undef": true, 5 | "unused": true 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-unsupported/fake-test262/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "6.0.0" 3 | } 4 | -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/fake-test262/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.23.45" 3 | } 4 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-other-accepted/fake-test262/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "6.0.0" 3 | } 4 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/module_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This file is a Test262 "fixture" file and should not be 2 | // visited. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/module_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This file is a Test262 "fixture" file and should not be 2 | // visited. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/noStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [noStrict] 4 | ---*/ 5 | x = 5; 6 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/noStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [noStrict] 4 | ---*/ 5 | x = 5; 6 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/strict/no/noStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [noStrict] 4 | ---*/ 5 | x = 5; 6 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/noStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [noStrict] 4 | ---*/ 5 | x = 5; 6 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/module.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: A test for module code 3 | flags: [module] 4 | ---*/ 5 | 6 | import fixture from './module_FIXTURE.js'; 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/module.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: A test for module code 3 | flags: [module] 4 | ---*/ 5 | 6 | import fixture from './module_FIXTURE.js'; 7 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-0_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-3_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-4_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-5_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-6_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-7_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-8_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/zzz-9_FIXTURE.txt: -------------------------------------------------------------------------------- 1 | // This non-test file is present only to ensure that traversal continues beyond 2 | // the moment that all tests have been compiled. 3 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/module_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: A test for module code 3 | flags: [module] 4 | ---*/ 5 | 6 | import fixture from './module_FIXTURE.js'; 7 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/error.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Fails by calling $ERROR 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | 8 | $ERROR('failure message'); 9 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/error.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Fails by calling $ERROR 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | 8 | $ERROR('failure message'); 9 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/error.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Fails by calling $ERROR 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | 8 | $ERROR('failure message'); 9 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/module_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: A test for module code 4 | flags: [module] 5 | ---*/ 6 | 7 | import fixture from './module_FIXTURE.js'; 8 | -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-unsupported/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/error_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Fails by calling $ERROR 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | 8 | $ERROR('failure message'); 9 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-other-accepted/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | function $DONE(){ 2 | if(!arguments[0]) 3 | print('Test262:AsyncTestComplete'); 4 | else 5 | print('Error: ' + arguments[0]); 6 | } 7 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/negative-empty.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should report the expected error indicated by the "negative" frontmatter 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/negative-empty.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should report the expected error indicated by the "negative" frontmatter 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/async.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async test 3 | flags: [async] 4 | ---*/ 5 | 6 | var p = new Promise(function(resolve) { 7 | resolve(); 8 | }); 9 | 10 | p.then($DONE, $DONE); 11 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/negative-empty.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should report the expected error indicated by the "negative" frontmatter 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/async.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async test 3 | flags: [async] 4 | ---*/ 5 | 6 | var p = new Promise(function(resolve) { 7 | resolve(); 8 | }); 9 | 10 | p.then($DONE, $DONE); 11 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/fake-test262/test/async.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async test 3 | flags: [async] 4 | ---*/ 5 | 6 | var p = new Promise(function(resolve) { 7 | resolve(); 8 | }); 9 | 10 | p.then($DONE, $DONE); 11 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/async/async.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async test 3 | flags: [async] 4 | ---*/ 5 | 6 | var p = new Promise(function(resolve) { 7 | resolve(); 8 | }); 9 | 10 | p.then($DONE, $DONE); 11 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/negative-empty_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should report the expected error indicated by the "negative" frontmatter 3 | negative: 4 | phase: runtime 5 | type: Test262Error 6 | ---*/ 7 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/async_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async test 3 | flags: [async] 4 | ---*/ 5 | 6 | var p = new Promise(function(resolve) { 7 | resolve(); 8 | }); 9 | 10 | p.then($DONE, $DONE); 11 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/error_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: Fails by calling $ERROR 4 | negative: 5 | phase: runtime 6 | type: Test262Error 7 | ---*/ 8 | 9 | $ERROR('failure message'); 10 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/negative-empty_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: Should report the expected error indicated by the "negative" frontmatter 4 | negative: 5 | phase: runtime 6 | type: Test262Error 7 | ---*/ 8 | -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/fake-test262/test/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/fake-test262/test/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/strict/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-other-accepted/fake-test262/test/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-unsupported/fake-test262/test/strict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in sloppy mode 3 | flags: [onlyStrict] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | x = 5; 9 | $ERROR('Not in strict mode'); 10 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/async_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: Async test 4 | flags: [async] 5 | ---*/ 6 | 7 | var p = new Promise(function(resolve) { 8 | resolve(); 9 | }); 10 | 11 | p.then($DONE, $DONE); 12 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/asyncNegative.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async negative test 3 | negative: 4 | phase: runtime 5 | type: RangeError 6 | flags: [async] 7 | ---*/ 8 | 9 | setTimeout(function() { 10 | $DONE(new RangeError()); 11 | }, 1000); 12 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/asyncNegative.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async negative test 3 | negative: 4 | phase: runtime 5 | type: RangeError 6 | flags: [async] 7 | ---*/ 8 | 9 | setTimeout(function() { 10 | $DONE(new RangeError()); 11 | }, 1000); 12 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/async/asyncNegative.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async negative test 3 | negative: 4 | phase: runtime 5 | type: RangeError 6 | flags: [async] 7 | ---*/ 8 | 9 | setTimeout(function() { 10 | $DONE(new RangeError()); 11 | }, 1000); 12 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Async negative test 3 | negative: 4 | phase: runtime 5 | type: RangeError 6 | flags: [async] 7 | ---*/ 8 | 9 | setTimeout(function() { 10 | $DONE(new RangeError()); 11 | }, 1000); 12 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/strict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: Should not test in sloppy mode 4 | flags: [onlyStrict] 5 | negative: 6 | phase: runtime 7 | type: ReferenceError 8 | ---*/ 9 | x = 5; 10 | $ERROR('Not in strict mode'); 11 | -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/fake-test262/test/runtime.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2048 $ContributorName. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: License and correct insertionIndex 6 | ---*/ 7 | assert(true); 8 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: Async negative test 4 | negative: 5 | phase: runtime 6 | type: RangeError 7 | flags: [async] 8 | ---*/ 9 | 10 | setTimeout(function() { 11 | $DONE(new RangeError()); 12 | }, 1000); 13 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-other-accepted/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-unsupported/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/assert.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/custom-includes/assert.js: -------------------------------------------------------------------------------- 1 | // This is a CUSTOM assert.js 2 | 3 | 'It has some CUSTOM contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, CUSTOM, trailing; 15 | whitespace: ; 16 | 17 | void "end of CUSTOM assert.js"; 18 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/custom-includes/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | // This is a customized implementation of `doneprintHandle.js` 2 | function $DONE(){ 3 | if(!arguments[0]) { 4 | print('Test262:AsyncTestComplete'); 5 | } else { 6 | print('Error: ' + arguments[0]); 7 | } 8 | } 9 | // End customized implementation of `doneprintHandle.js` 10 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-other-accepted/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/invalid-version-unsupported/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | function Test262Error(message) { 2 | this.message = message || ""; 3 | } 4 | 5 | Test262Error.prototype.toString = function () { 6 | return "Test262Error: " + this.message; 7 | }; 8 | 9 | var $ERROR; 10 | $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/rawNoStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [raw] 4 | ---*/ 5 | var seemsStrict; 6 | try { 7 | x = 1; 8 | } catch (err) { 9 | seemsStrict = err.constructor === ReferenceError; 10 | } 11 | 12 | if (seemsStrict) { 13 | throw new Error('Script erroneously interpreted in strict mode.'); 14 | } 15 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/bothStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | features: [var, try, if] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/rawNoStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [raw] 4 | ---*/ 5 | var seemsStrict; 6 | try { 7 | x = 1; 8 | } catch (err) { 9 | seemsStrict = err.constructor === ReferenceError; 10 | } 11 | 12 | if (seemsStrict) { 13 | throw new Error('Script erroneously interpreted in strict mode.'); 14 | } 15 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/bothStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | features: [var, try, if] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/rawNoStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [raw] 4 | ---*/ 5 | var seemsStrict; 6 | try { 7 | x = 1; 8 | } catch (err) { 9 | seemsStrict = err.constructor === ReferenceError; 10 | } 11 | 12 | if (seemsStrict) { 13 | throw new Error('Script erroneously interpreted in strict mode.'); 14 | } 15 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/fake-test262/test/bothStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | features: [var, try, if] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/bothStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | features: [var, try, if] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/fake-test262/test/bothStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | features: [var, try, if] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/strict/no/rawNoStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [raw] 4 | ---*/ 5 | var seemsStrict; 6 | try { 7 | x = 1; 8 | } catch (err) { 9 | seemsStrict = err.constructor === ReferenceError; 10 | } 11 | 12 | if (seemsStrict) { 13 | throw new Error('Script erroneously interpreted in strict mode.'); 14 | } 15 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/rawNoStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [raw] 4 | ---*/ 5 | var seemsStrict; 6 | try { 7 | x = 1; 8 | } catch (err) { 9 | seemsStrict = err.constructor === ReferenceError; 10 | } 11 | 12 | if (seemsStrict) { 13 | throw new Error('Script erroneously interpreted in strict mode.'); 14 | } 15 | -------------------------------------------------------------------------------- /test/collateral/invalid-missing-harness/fake-test262/test/a-test-file.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | negative: 4 | phase: runtime 5 | type: ReferenceError 6 | expected: 7 | pass: true 8 | ---*/ 9 | var strict; 10 | try { x = 1; strict = false;} catch(e) { strict = true } 11 | 12 | if(strict) { 13 | y = 1; 14 | } else { 15 | throw new ReferenceError(); 16 | } 17 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/bothStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should test in both modes 3 | features: [var, try, if] 4 | negative: 5 | phase: runtime 6 | type: ReferenceError 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/missing-raw-flag.js: -------------------------------------------------------------------------------- 1 | #! 2 | 3 | /*--- 4 | description: > 5 | Missing raw flag will result in the harness/runtime includes being added, 6 | however doing so will produce invalid test code. 7 | features: [hashbang] 8 | negative: 9 | phase: parse 10 | type: SyntaxError 11 | ---*/ 12 | 13 | throw "Test262: This statement should not be evaluated."; 14 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/strict/no/rawNoStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode 3 | flags: [raw] 4 | ---*/ 5 | var seemsStrict; 6 | try { 7 | x = 1; 8 | } catch (err) { 9 | seemsStrict = err.constructor === ReferenceError; 10 | } 11 | 12 | if (seemsStrict) { 13 | throw new Error('Script erroneously interpreted in strict mode.'); 14 | } 15 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/bothStrict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*--- 3 | description: Should test in both modes 4 | features: [var, try, if] 5 | negative: 6 | phase: runtime 7 | type: ReferenceError 8 | ---*/ 9 | var strict; 10 | try { x = 1; strict = false;} catch(e) { strict = true } 11 | 12 | if(strict) { 13 | y = 1; 14 | } else { 15 | throw new ReferenceError(); 16 | } 17 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/async_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": 0 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/custom-includes/sta.js: -------------------------------------------------------------------------------- 1 | // This is a custom implementation of `sta.js` 2 | function Test262Error(message) { 3 | this.message = message || ''; 4 | } 5 | 6 | Test262Error.prototype.toString = function() { 7 | return 'Test262Error: ' + this.message; 8 | }; 9 | 10 | var $ERROR = function $ERROR(message) { 11 | throw new Test262Error(message); 12 | }; 13 | // End custom implementation of `sta.js` 14 | -------------------------------------------------------------------------------- /test/collateral/valid-default/fake-test262/test/rawStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode (but allow strict mode to be enabled) 3 | flags: [raw] 4 | ---*/ 5 | 'use strict'; 6 | var seemsStrict; 7 | try { 8 | x = 1; 9 | } catch (err) { 10 | seemsStrict = err.constructor === ReferenceError; 11 | } 12 | 13 | if (!seemsStrict) { 14 | throw new Error('Script erroneously not interpreted in strict mode.'); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/module_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/module.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "A test for module code", 6 | "flags": { 7 | "module": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": 0 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/fake-test262/test/rawStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode (but allow strict mode to be enabled) 3 | flags: [raw] 4 | ---*/ 5 | 'use strict'; 6 | var seemsStrict; 7 | try { 8 | x = 1; 9 | } catch (err) { 10 | seemsStrict = err.constructor === ReferenceError; 11 | } 12 | 13 | if (!seemsStrict) { 14 | throw new Error('Script erroneously not interpreted in strict mode.'); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/rawStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode (but allow strict mode to be enabled) 3 | flags: [raw] 4 | ---*/ 5 | 'use strict'; 6 | var seemsStrict; 7 | try { 8 | x = 1; 9 | } catch (err) { 10 | seemsStrict = err.constructor === ReferenceError; 11 | } 12 | 13 | if (!seemsStrict) { 14 | throw new Error('Script erroneously not interpreted in strict mode.'); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/async_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test (Strict Mode)", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "strict mode", 13 | "insertionIndex": 14 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw.js: -------------------------------------------------------------------------------- 1 | #!whatever 2 | /*--- 3 | description: No license after the hashbang. Contents should have hashbang 4 | features: [hashbang] 5 | flags: [raw] 6 | negative: 7 | phase: runtime 8 | type: ReferenceError 9 | ---*/ 10 | var strict; 11 | try { x = 1; strict = false;} catch(e) { strict = true } 12 | 13 | if(strict) { 14 | y = 1; 15 | } else { 16 | throw new ReferenceError(); 17 | } 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/fake-test262/test/strict/rawStrict.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode (but allow strict mode to be enabled) 3 | flags: [raw] 4 | ---*/ 5 | 'use strict'; 6 | var seemsStrict; 7 | try { 8 | x = 1; 9 | } catch (err) { 10 | seemsStrict = err.constructor === ReferenceError; 11 | } 12 | 13 | if (!seemsStrict) { 14 | throw new Error('Script erroneously not interpreted in strict mode.'); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/rawNoStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/rawNoStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode", 6 | "flags": { 7 | "raw": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": -1 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-content/test/rawStrict_default.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Should not test in strict mode (but allow strict mode to be enabled) 3 | flags: [raw] 4 | ---*/ 5 | 'use strict'; 6 | var seemsStrict; 7 | try { 8 | x = 1; 9 | } catch (err) { 10 | seemsStrict = err.constructor === ReferenceError; 11 | } 12 | 13 | if (!seemsStrict) { 14 | throw new Error('Script erroneously not interpreted in strict mode.'); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/noStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/noStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode", 6 | "flags": { 7 | "noStrict": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": 0 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/rawNoStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/rawNoStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode", 6 | "flags": { 7 | "raw": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": -1 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw_default.js: -------------------------------------------------------------------------------- 1 | #!whatever 2 | /*--- 3 | description: No license after the hashbang. Contents should have hashbang 4 | features: [hashbang] 5 | flags: [raw] 6 | negative: 7 | phase: runtime 8 | type: ReferenceError 9 | ---*/ 10 | var strict; 11 | try { x = 1; strict = false;} catch(e) { strict = true } 12 | 13 | if(strict) { 14 | y = 1; 15 | } else { 16 | throw new ReferenceError(); 17 | } 18 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/module_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/module.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "A test for module code (Strict Mode)", 6 | "flags": { 7 | "module": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "strict mode", 13 | "insertionIndex": 14 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/fake-test262/test/raw.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2048 $ContributorName. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: License and correct insertionIndex 6 | flags: [raw] 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/strict/no/rawNoStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/strict/no/rawNoStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode", 6 | "flags": { 7 | "raw": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": -1 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/rawStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/rawStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode (but allow strict mode to be enabled)", 6 | "flags": { 7 | "raw": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": -1 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/expected-content/test/raw_default.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2048 $ContributorName. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: License and correct insertionIndex 6 | flags: [raw] 7 | ---*/ 8 | var strict; 9 | try { x = 1; strict = false;} catch(e) { strict = true } 10 | 11 | if(strict) { 12 | y = 1; 13 | } else { 14 | throw new ReferenceError(); 15 | } 16 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/module_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/module.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "A test for module code", 6 | "flags": { 7 | "module": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js" 12 | ] 13 | }, 14 | "copyright": "", 15 | "scenario": "default", 16 | "insertionIndex": 439 17 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/rawStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/rawStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode (but allow strict mode to be enabled)", 6 | "flags": { 7 | "raw": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "", 12 | "scenario": "default", 13 | "insertionIndex": -1 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/error_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/error.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Fails by calling $ERROR", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [] 12 | }, 13 | "copyright": "", 14 | "scenario": "default", 15 | "insertionIndex": 0 16 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/noStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/noStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode", 6 | "flags": { 7 | "noStrict": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js" 12 | ] 13 | }, 14 | "copyright": "", 15 | "scenario": "default", 16 | "insertionIndex": 439 17 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/async_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js", 12 | "doneprintHandle.js" 13 | ] 14 | }, 15 | "copyright": "", 16 | "scenario": "default", 17 | "insertionIndex": 564 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/module_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/module.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "A test for module code (Strict Mode)", 6 | "flags": { 7 | "module": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js" 12 | ] 13 | }, 14 | "copyright": "", 15 | "scenario": "strict mode", 16 | "insertionIndex": 453 17 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls.js: -------------------------------------------------------------------------------- 1 | #!LS
// a U+2028 LINE SEPARATOR is to the immediate left of "//" 2 | /*--- 3 | description: No license after the hashbang. Contents should have hashbang 4 | features: [hashbang] 5 | flags: [raw] 6 | negative: 7 | phase: runtime 8 | type: ReferenceError 9 | ---*/ 10 | var strict; 11 | try { x = 1; strict = false;} catch(e) { strict = true } 12 | 13 | if(strict) { 14 | y = 1; 15 | } else { 16 | throw new ReferenceError(); 17 | } 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps.js: -------------------------------------------------------------------------------- 1 | #!PS
// a U+2029 PARAGRAPH SEPARATOR is to the immediate left of "//" 2 | /*--- 3 | description: No license after the hashbang. Contents should have hashbang 4 | features: [hashbang] 5 | flags: [raw] 6 | negative: 7 | phase: runtime 8 | type: ReferenceError 9 | ---*/ 10 | var strict; 11 | try { x = 1; strict = false;} catch(e) { strict = true } 12 | 13 | if(strict) { 14 | y = 1; 15 | } else { 16 | throw new ReferenceError(); 17 | } 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-metadata/test/async_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js", 12 | "doneprintHandle.js" 13 | ] 14 | }, 15 | "copyright": "", 16 | "scenario": "default", 17 | "insertionIndex": 804 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/raw_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "License and correct insertionIndex", 6 | "flags": { 7 | "raw": true 8 | }, 9 | "includes": [] 10 | }, 11 | "copyright": "// Copyright (C) 2048 $ContributorName. All rights reserved.", 12 | "scenario": "default", 13 | "insertionIndex": -1 14 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls_default.js: -------------------------------------------------------------------------------- 1 | #!LS
// a U+2028 LINE SEPARATOR is to the immediate left of "//" 2 | /*--- 3 | description: No license after the hashbang. Contents should have hashbang 4 | features: [hashbang] 5 | flags: [raw] 6 | negative: 7 | phase: runtime 8 | type: ReferenceError 9 | ---*/ 10 | var strict; 11 | try { x = 1; strict = false;} catch(e) { strict = true } 12 | 13 | if(strict) { 14 | y = 1; 15 | } else { 16 | throw new ReferenceError(); 17 | } 18 | -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/error_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/error.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Fails by calling $ERROR (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [] 12 | }, 13 | "copyright": "", 14 | "scenario": "strict mode", 15 | "insertionIndex": 14 16 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps_default.js: -------------------------------------------------------------------------------- 1 | #!PS
// a U+2029 PARAGRAPH SEPARATOR is to the immediate left of "//" 2 | /*--- 3 | description: No license after the hashbang. Contents should have hashbang 4 | features: [hashbang] 5 | flags: [raw] 6 | negative: 7 | phase: runtime 8 | type: ReferenceError 9 | ---*/ 10 | var strict; 11 | try { x = 1; strict = false;} catch(e) { strict = true } 12 | 13 | if(strict) { 14 | y = 1; 15 | } else { 16 | throw new ReferenceError(); 17 | } 18 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/async/async_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js", 12 | "doneprintHandle.js" 13 | ] 14 | }, 15 | "copyright": "", 16 | "scenario": "default", 17 | "insertionIndex": 564 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/strict/no/noStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/strict/no/noStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in strict mode", 6 | "flags": { 7 | "noStrict": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js" 12 | ] 13 | }, 14 | "copyright": "", 15 | "scenario": "default", 16 | "insertionIndex": 439 17 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/async_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test (Strict Mode)", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js", 12 | "doneprintHandle.js" 13 | ] 14 | }, 15 | "copyright": "", 16 | "scenario": "strict mode", 17 | "insertionIndex": 578 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-multiline-block.js: -------------------------------------------------------------------------------- 1 | #!LS
{// a U+2028 LINE SEPARATOR is to the immediate left of "{//" 2 | } 3 | /*--- 4 | description: No license after the hashbang. Contents should have hashbang 5 | features: [hashbang] 6 | flags: [raw] 7 | negative: 8 | phase: runtime 9 | type: ReferenceError 10 | ---*/ 11 | var strict; 12 | try { x = 1; strict = false;} catch(e) { strict = true } 13 | 14 | if(strict) { 15 | y = 1; 16 | } else { 17 | throw new ReferenceError(); 18 | } 19 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-metadata/test/async_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test (Strict Mode)", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js", 12 | "doneprintHandle.js" 13 | ] 14 | }, 15 | "copyright": "", 16 | "scenario": "strict mode", 17 | "insertionIndex": 818 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/asyncNegative.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async negative test", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "RangeError" 9 | }, 10 | "flags": { 11 | "async": true 12 | }, 13 | "includes": [] 14 | }, 15 | "copyright": "", 16 | "scenario": "default", 17 | "insertionIndex": 0 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-multiline-block_default.js: -------------------------------------------------------------------------------- 1 | #!LS
{// a U+2028 LINE SEPARATOR is to the immediate left of "{//" 2 | } 3 | /*--- 4 | description: No license after the hashbang. Contents should have hashbang 5 | features: [hashbang] 6 | flags: [raw] 7 | negative: 8 | phase: runtime 9 | type: ReferenceError 10 | ---*/ 11 | var strict; 12 | try { x = 1; strict = false;} catch(e) { strict = true } 13 | 14 | if(strict) { 15 | y = 1; 16 | } else { 17 | throw new ReferenceError(); 18 | } 19 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/async/async_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async/async.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async test (Strict Mode)", 6 | "flags": { 7 | "async": true 8 | }, 9 | "includes": [ 10 | "assert.js", 11 | "sta.js", 12 | "doneprintHandle.js" 13 | ] 14 | }, 15 | "copyright": "", 16 | "scenario": "strict mode", 17 | "insertionIndex": 578 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/runtime.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "License and correct insertionIndex", 6 | "flags": {}, 7 | "includes": [ 8 | "assert.js", 9 | "sta.js" 10 | ] 11 | }, 12 | "copyright": "// Copyright (C) 2048 $ContributorName. All rights reserved.", 13 | "scenario": "default", 14 | "insertionIndex": 439 15 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/error_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/error.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Fails by calling $ERROR", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [ 12 | "assert.js", 13 | "sta.js" 14 | ] 15 | }, 16 | "copyright": "", 17 | "scenario": "default", 18 | "insertionIndex": 439 19 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-multiline-block.js: -------------------------------------------------------------------------------- 1 | #!PS
{// a U+2029 PARAGRAPH SEPARATOR is to the immediate left of "{//" 2 | } 3 | /*--- 4 | description: Multiline block, no license after the hashbang. Contents should have hashbang 5 | features: [hashbang] 6 | flags: [raw] 7 | negative: 8 | phase: runtime 9 | type: ReferenceError 10 | ---*/ 11 | var strict; 12 | try { x = 1; strict = false;} catch(e) { strict = true } 13 | 14 | if(strict) { 15 | y = 1; 16 | } else { 17 | throw new ReferenceError(); 18 | } 19 | -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/runtime.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "License and correct insertionIndex (Strict Mode)", 6 | "flags": {}, 7 | "includes": [ 8 | "assert.js", 9 | "sta.js" 10 | ] 11 | }, 12 | "copyright": "// Copyright (C) 2048 $ContributorName. All rights reserved.", 13 | "scenario": "strict mode", 14 | "insertionIndex": 453 15 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/asyncNegative.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async negative test (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "RangeError" 9 | }, 10 | "flags": { 11 | "async": true 12 | }, 13 | "includes": [] 14 | }, 15 | "copyright": "", 16 | "scenario": "strict mode", 17 | "insertionIndex": 14 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/negative-empty.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should report the expected error indicated by the \"negative\" frontmatter", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [] 12 | }, 13 | "copyright": "", 14 | "scenario": "default", 15 | "insertionIndex": 0 16 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-multiline-block_default.js: -------------------------------------------------------------------------------- 1 | #!PS
{// a U+2029 PARAGRAPH SEPARATOR is to the immediate left of "{//" 2 | } 3 | /*--- 4 | description: Multiline block, no license after the hashbang. Contents should have hashbang 5 | features: [hashbang] 6 | flags: [raw] 7 | negative: 8 | phase: runtime 9 | type: ReferenceError 10 | ---*/ 11 | var strict; 12 | try { x = 1; strict = false;} catch(e) { strict = true } 13 | 14 | if(strict) { 15 | y = 1; 16 | } else { 17 | throw new ReferenceError(); 18 | } 19 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/error_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/error.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Fails by calling $ERROR (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [ 12 | "assert.js", 13 | "sta.js" 14 | ] 15 | }, 16 | "copyright": "", 17 | "scenario": "strict mode", 18 | "insertionIndex": 453 19 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/strict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/strict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in sloppy mode (Strict Mode)", 6 | "flags": { 7 | "onlyStrict": true 8 | }, 9 | "negative": { 10 | "phase": "runtime", 11 | "type": "ReferenceError" 12 | }, 13 | "includes": [] 14 | }, 15 | "copyright": "", 16 | "scenario": "strict mode", 17 | "insertionIndex": 14 18 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/negative-empty.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should report the expected error indicated by the \"negative\" frontmatter (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [] 12 | }, 13 | "copyright": "", 14 | "scenario": "strict mode", 15 | "insertionIndex": 14 16 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "default", 20 | "insertionIndex": 0 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/rawWithLicense.js: -------------------------------------------------------------------------------- 1 | #!whatever 2 | 3 | // Copyright (c) 2019, Bocoup LLC. All rights reserved. 4 | // This code is governed by the BSD license found in the LICENSE file. 5 | 6 | /*--- 7 | description: Has a license after the hashbang. Contents should have hashbang 8 | features: [hashbang] 9 | flags: [raw] 10 | negative: 11 | phase: runtime 12 | type: ReferenceError 13 | ---*/ 14 | var strict; 15 | try { x = 1; strict = false;} catch(e) { strict = true } 16 | 17 | if(strict) { 18 | y = 1; 19 | } else { 20 | throw new ReferenceError(); 21 | } 22 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/negative-empty_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/negative-empty.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should report the expected error indicated by the \"negative\" frontmatter", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [ 12 | "assert.js", 13 | "sta.js" 14 | ] 15 | }, 16 | "copyright": "", 17 | "scenario": "default", 18 | "insertionIndex": 439 19 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/rawWithLicense_default.js: -------------------------------------------------------------------------------- 1 | #!whatever 2 | 3 | // Copyright (c) 2019, Bocoup LLC. All rights reserved. 4 | // This code is governed by the BSD license found in the LICENSE file. 5 | 6 | /*--- 7 | description: Has a license after the hashbang. Contents should have hashbang 8 | features: [hashbang] 9 | flags: [raw] 10 | negative: 11 | phase: runtime 12 | type: ReferenceError 13 | ---*/ 14 | var strict; 15 | try { x = 1; strict = false;} catch(e) { strict = true } 16 | 17 | if(strict) { 18 | y = 1; 19 | } else { 20 | throw new ReferenceError(); 21 | } 22 | -------------------------------------------------------------------------------- /lib/compile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | const builder = require('./builder'); 5 | const createScenarios = require('./create-scenarios'); 6 | 7 | module.exports = function(filePath, options, done) { 8 | fs.readFile(filePath, 'utf-8', (error, contents) => { 9 | if (error) { 10 | done(error); 11 | return; 12 | } 13 | 14 | done(null, 15 | createScenarios( 16 | builder( 17 | path.relative(options.test262Dir, filePath), 18 | contents, 19 | options 20 | ) 21 | ) 22 | ); 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/strict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/strict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in sloppy mode (Strict Mode)", 6 | "flags": { 7 | "onlyStrict": true 8 | }, 9 | "negative": { 10 | "phase": "runtime", 11 | "type": "ReferenceError" 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js" 16 | ] 17 | }, 18 | "copyright": "", 19 | "scenario": "strict mode", 20 | "insertionIndex": 453 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes (Strict Mode)", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "strict mode", 20 | "insertionIndex": 14 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/asyncNegative_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/asyncNegative.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async negative test", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "RangeError" 9 | }, 10 | "flags": { 11 | "async": true 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js", 16 | "doneprintHandle.js" 17 | ] 18 | }, 19 | "copyright": "", 20 | "scenario": "default", 21 | "insertionIndex": 564 22 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "No license after the hashbang. Contents should have hashbang", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/expected-metadata/test/strict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/strict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in sloppy mode (Strict Mode)", 6 | "flags": { 7 | "onlyStrict": true 8 | }, 9 | "negative": { 10 | "phase": "runtime", 11 | "type": "ReferenceError" 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js" 16 | ] 17 | }, 18 | "copyright": "", 19 | "scenario": "strict mode", 20 | "insertionIndex": 453 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/expected-metadata/test/strict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/strict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should not test in sloppy mode (Strict Mode)", 6 | "flags": { 7 | "onlyStrict": true 8 | }, 9 | "negative": { 10 | "phase": "runtime", 11 | "type": "ReferenceError" 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js" 16 | ] 17 | }, 18 | "copyright": "", 19 | "scenario": "strict mode", 20 | "insertionIndex": 453 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-and-license-on-same-line.js: -------------------------------------------------------------------------------- 1 | #!LS
// Copyright (c) 2019, Bocoup LLC. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: > 6 | Has a license after the hashbang, on same line. There is an between them. 7 | features: [hashbang] 8 | flags: [raw] 9 | negative: 10 | phase: runtime 11 | type: ReferenceError 12 | ---*/ 13 | var strict; 14 | try { x = 1; strict = false;} catch(e) { strict = true } 15 | 16 | if(strict) { 17 | y = 1; 18 | } else { 19 | throw new ReferenceError(); 20 | } 21 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-and-license-on-same-line.js: -------------------------------------------------------------------------------- 1 | #!PS
// Copyright (c) 2019, Bocoup LLC. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: > 6 | Has a license after the hashbang, on same line. There is a between them. 7 | features: [hashbang] 8 | flags: [raw] 9 | negative: 10 | phase: runtime 11 | type: ReferenceError 12 | ---*/ 13 | var strict; 14 | try { x = 1; strict = false;} catch(e) { strict = true } 15 | 16 | if(strict) { 17 | y = 1; 18 | } else { 19 | throw new ReferenceError(); 20 | } 21 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/negative-empty_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/negative-empty.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should report the expected error indicated by the \"negative\" frontmatter (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "Test262Error" 9 | }, 10 | "flags": {}, 11 | "includes": [ 12 | "assert.js", 13 | "sta.js" 14 | ] 15 | }, 16 | "copyright": "", 17 | "scenario": "strict mode", 18 | "insertionIndex": 453 19 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-and-license-on-same-line_default.js: -------------------------------------------------------------------------------- 1 | #!LS
// Copyright (c) 2019, Bocoup LLC. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: > 6 | Has a license after the hashbang, on same line. There is an between them. 7 | features: [hashbang] 8 | flags: [raw] 9 | negative: 10 | phase: runtime 11 | type: ReferenceError 12 | ---*/ 13 | var strict; 14 | try { x = 1; strict = false;} catch(e) { strict = true } 15 | 16 | if(strict) { 17 | y = 1; 18 | } else { 19 | throw new ReferenceError(); 20 | } 21 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-and-license-on-same-line_default.js: -------------------------------------------------------------------------------- 1 | #!PS
// Copyright (c) 2019, Bocoup LLC. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: > 6 | Has a license after the hashbang, on same line. There is a between them. 7 | features: [hashbang] 8 | flags: [raw] 9 | negative: 10 | phase: runtime 11 | type: ReferenceError 12 | ---*/ 13 | var strict; 14 | try { x = 1; strict = false;} catch(e) { strict = true } 15 | 16 | if(strict) { 17 | y = 1; 18 | } else { 19 | throw new ReferenceError(); 20 | } 21 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw-with-ls.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "No license after the hashbang. Contents should have hashbang", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw-with-ps.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "No license after the hashbang. Contents should have hashbang", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async/asyncNegative.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async negative test", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "RangeError" 9 | }, 10 | "flags": { 11 | "async": true 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js", 16 | "doneprintHandle.js" 17 | ] 18 | }, 19 | "copyright": "", 20 | "scenario": "default", 21 | "insertionIndex": 564 22 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/asyncNegative_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/asyncNegative.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async negative test (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "RangeError" 9 | }, 10 | "flags": { 11 | "async": true 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js", 16 | "doneprintHandle.js" 17 | ] 18 | }, 19 | "copyright": "", 20 | "scenario": "strict mode", 21 | "insertionIndex": 578 22 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/bothStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "default", 23 | "insertionIndex": 439 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/bothStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "default", 23 | "insertionIndex": 439 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/expected-metadata/test/bothStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "default", 23 | "insertionIndex": 439 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-metadata/test/bothStrict_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "default", 23 | "insertionIndex": 549 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/async/asyncNegative.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Async negative test (Strict Mode)", 6 | "negative": { 7 | "phase": "runtime", 8 | "type": "RangeError" 9 | }, 10 | "flags": { 11 | "async": true 12 | }, 13 | "includes": [ 14 | "assert.js", 15 | "sta.js", 16 | "doneprintHandle.js" 17 | ] 18 | }, 19 | "copyright": "", 20 | "scenario": "strict mode", 21 | "insertionIndex": 578 22 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-metadata/test/bothStrict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes (Strict Mode)", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "strict mode", 23 | "insertionIndex": 453 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-multiline-block_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw-with-ls-multiline-block.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "No license after the hashbang. Contents should have hashbang", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/expected-metadata/test/bothStrict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes (Strict Mode)", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "strict mode", 23 | "insertionIndex": 453 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-metadata/test/bothStrict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes (Strict Mode)", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "strict mode", 23 | "insertionIndex": 563 24 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-metadata/test/bothStrict_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/bothStrict.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Should test in both modes (Strict Mode)", 6 | "features": [ 7 | "var", 8 | "try", 9 | "if" 10 | ], 11 | "negative": { 12 | "phase": "runtime", 13 | "type": "ReferenceError" 14 | }, 15 | "flags": {}, 16 | "includes": [ 17 | "assert.js", 18 | "sta.js" 19 | ] 20 | }, 21 | "copyright": "", 22 | "scenario": "strict mode", 23 | "insertionIndex": 453 24 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test262-stream", 3 | "version": "1.4.0", 4 | "description": "A Node.js API for traversing the Test262 test suite", 5 | "main": "lib/index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "lint": "jshint lib test", 11 | "test": "npm run lint && npm run test-unit", 12 | "test-unit": "tape test/test.js" 13 | }, 14 | "author": "", 15 | "license": "BSD-3-Clause", 16 | "devDependencies": { 17 | "jshint": "^2.10.2", 18 | "mkdirp": "^0.5.1", 19 | "rimraf": "^2.6.2", 20 | "tape": "^4.8.0" 21 | }, 22 | "dependencies": { 23 | "js-yaml": "^3.2.1", 24 | "klaw": "^2.1.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-multiline-block_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw-with-ps-multiline-block.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Multiline block, no license after the hashbang. Contents should have hashbang", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/rawWithLicense_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/rawWithLicense.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Has a license after the hashbang. Contents should have hashbang", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "// Copyright (c) 2019, Bocoup LLC. All rights reserved.", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/missing-raw-flag.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Missing raw flag will result in the harness/runtime includes being added, however doing so will produce invalid test code.\n", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "negative": { 10 | "phase": "parse", 11 | "type": "SyntaxError" 12 | }, 13 | "flags": {}, 14 | "includes": [ 15 | "assert.js", 16 | "sta.js" 17 | ] 18 | }, 19 | "copyright": "", 20 | "scenario": "default", 21 | "insertionIndex": 439 22 | } -------------------------------------------------------------------------------- /lib/create-scenarios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const usd = '"use strict";\n'; 3 | const usdLength = usd.length; 4 | 5 | module.exports = function scenariosForTest(test) { 6 | const scenarios = []; 7 | 8 | if (!test.attrs.flags.onlyStrict) { 9 | test.scenario = 'default'; 10 | scenarios.push(test); 11 | } 12 | 13 | if (!test.attrs.flags.noStrict && !test.attrs.flags.raw) { 14 | const copy = Object.assign({}, test); 15 | copy.attrs = Object.assign({}, test.attrs); 16 | copy.attrs.description += ' (Strict Mode)'; 17 | copy.contents = usd + copy.contents; 18 | copy.insertionIndex += usdLength; 19 | copy.scenario = 'strict mode'; 20 | scenarios.push(copy); 21 | } 22 | 23 | return scenarios; 24 | }; 25 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/noStrict_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Should not test in strict mode 34 | flags: [noStrict] 35 | ---*/ 36 | x = 5; 37 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_strict_mode.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/missing-raw-flag.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Missing raw flag will result in the harness/runtime includes being added, however doing so will produce invalid test code.\n (Strict Mode)", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "negative": { 10 | "phase": "parse", 11 | "type": "SyntaxError" 12 | }, 13 | "flags": {}, 14 | "includes": [ 15 | "assert.js", 16 | "sta.js" 17 | ] 18 | }, 19 | "copyright": "", 20 | "scenario": "strict mode", 21 | "insertionIndex": 453 22 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/strict/no/noStrict_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Should not test in strict mode 34 | flags: [noStrict] 35 | ---*/ 36 | x = 5; 37 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-and-license-on-same-line_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw-with-ls-and-license-on-same-line.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Has a license after the hashbang, on same line. There is an between them.\n", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "// Copyright (c) 2019, Bocoup LLC. All rights reserved.", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-and-license-on-same-line_default.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": "test/raw-with-ps-and-license-on-same-line.js", 3 | "contents": "(The value of this property is over-sized, so it is validated independently.)", 4 | "attrs": { 5 | "description": "Has a license after the hashbang, on same line. There is a between them.\n", 6 | "features": [ 7 | "hashbang" 8 | ], 9 | "flags": { 10 | "raw": true 11 | }, 12 | "negative": { 13 | "phase": "runtime", 14 | "type": "ReferenceError" 15 | }, 16 | "includes": [] 17 | }, 18 | "copyright": "// Copyright (c) 2019, Bocoup LLC. All rights reserved.", 19 | "scenario": "default", 20 | "insertionIndex": -1 21 | } -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/module_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: A test for module code 34 | flags: [module] 35 | ---*/ 36 | 37 | import fixture from './module_FIXTURE.js'; 38 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/error_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Fails by calling $ERROR 34 | negative: 35 | phase: runtime 36 | type: Test262Error 37 | ---*/ 38 | 39 | $ERROR('failure message'); 40 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/module_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: A test for module code 35 | flags: [module] 36 | ---*/ 37 | 38 | import fixture from './module_FIXTURE.js'; 39 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/negative-empty_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Should report the expected error indicated by the "negative" frontmatter 34 | negative: 35 | phase: runtime 36 | type: Test262Error 37 | ---*/ 38 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/error_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Fails by calling $ERROR 35 | negative: 36 | phase: runtime 37 | type: Test262Error 38 | ---*/ 39 | 40 | $ERROR('failure message'); 41 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/negative-empty_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should report the expected error indicated by the "negative" frontmatter 35 | negative: 36 | phase: runtime 37 | type: Test262Error 38 | ---*/ 39 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/strict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should not test in sloppy mode 35 | flags: [onlyStrict] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | x = 5; 41 | $ERROR('Not in strict mode'); 42 | -------------------------------------------------------------------------------- /test/collateral/valid-version-ignored/expected-content/test/strict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should not test in sloppy mode 35 | flags: [onlyStrict] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | x = 5; 41 | $ERROR('Not in strict mode'); 42 | -------------------------------------------------------------------------------- /test/collateral/valid-version-supported/expected-content/test/strict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should not test in sloppy mode 35 | flags: [onlyStrict] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | x = 5; 41 | $ERROR('Not in strict mode'); 42 | -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | // Copyright (C) 2048 $ContributorName. All rights reserved. 33 | // This code is governed by the BSD license found in the LICENSE file. 34 | 35 | /*--- 36 | description: License and correct insertionIndex 37 | ---*/ 38 | assert(true); 39 | -------------------------------------------------------------------------------- /test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | // Copyright (C) 2048 $ContributorName. All rights reserved. 34 | // This code is governed by the BSD license found in the LICENSE file. 35 | 36 | /*--- 37 | description: License and correct insertionIndex 38 | ---*/ 39 | assert(true); 40 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/async_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | function $DONE(){ 33 | if(!arguments[0]) 34 | print('Test262:AsyncTestComplete'); 35 | else 36 | print('Error: ' + arguments[0]); 37 | } 38 | 39 | /*--- 40 | description: Async test 41 | flags: [async] 42 | ---*/ 43 | 44 | var p = new Promise(function(resolve) { 45 | resolve(); 46 | }); 47 | 48 | p.then($DONE, $DONE); 49 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/bothStrict_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Should test in both modes 34 | features: [var, try, if] 35 | negative: 36 | phase: runtime 37 | type: ReferenceError 38 | ---*/ 39 | var strict; 40 | try { x = 1; strict = false;} catch(e) { strict = true } 41 | 42 | if(strict) { 43 | y = 1; 44 | } else { 45 | throw new ReferenceError(); 46 | } 47 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/expected-content/test/bothStrict_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Should test in both modes 34 | features: [var, try, if] 35 | negative: 36 | phase: runtime 37 | type: ReferenceError 38 | ---*/ 39 | var strict; 40 | try { x = 1; strict = false;} catch(e) { strict = true } 41 | 42 | if(strict) { 43 | y = 1; 44 | } else { 45 | throw new ReferenceError(); 46 | } 47 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/bothStrict_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | /*--- 33 | description: Should test in both modes 34 | features: [var, try, if] 35 | negative: 36 | phase: runtime 37 | type: ReferenceError 38 | ---*/ 39 | var strict; 40 | try { x = 1; strict = false;} catch(e) { strict = true } 41 | 42 | if(strict) { 43 | y = 1; 44 | } else { 45 | throw new ReferenceError(); 46 | } 47 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/async/async_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | function $DONE(){ 33 | if(!arguments[0]) 34 | print('Test262:AsyncTestComplete'); 35 | else 36 | print('Error: ' + arguments[0]); 37 | } 38 | 39 | /*--- 40 | description: Async test 41 | flags: [async] 42 | ---*/ 43 | 44 | var p = new Promise(function(resolve) { 45 | resolve(); 46 | }); 47 | 48 | p.then($DONE, $DONE); 49 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/async_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | function $DONE(){ 34 | if(!arguments[0]) 35 | print('Test262:AsyncTestComplete'); 36 | else 37 | print('Error: ' + arguments[0]); 38 | } 39 | 40 | /*--- 41 | description: Async test 42 | flags: [async] 43 | ---*/ 44 | 45 | var p = new Promise(function(resolve) { 46 | resolve(); 47 | }); 48 | 49 | p.then($DONE, $DONE); 50 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | #! 33 | 34 | /*--- 35 | description: > 36 | Missing raw flag will result in the harness/runtime includes being added, 37 | however doing so will produce invalid test code. 38 | features: [hashbang] 39 | negative: 40 | phase: parse 41 | type: SyntaxError 42 | ---*/ 43 | 44 | throw "Test262: This statement should not be evaluated."; 45 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/bothStrict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should test in both modes 35 | features: [var, try, if] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | var strict; 41 | try { x = 1; strict = false;} catch(e) { strict = true } 42 | 43 | if(strict) { 44 | y = 1; 45 | } else { 46 | throw new ReferenceError(); 47 | } 48 | -------------------------------------------------------------------------------- /test/collateral/valid-extra-files/expected-content/test/bothStrict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should test in both modes 35 | features: [var, try, if] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | var strict; 41 | try { x = 1; strict = false;} catch(e) { strict = true } 42 | 43 | if(strict) { 44 | y = 1; 45 | } else { 46 | throw new ReferenceError(); 47 | } 48 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/bothStrict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | /*--- 34 | description: Should test in both modes 35 | features: [var, try, if] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | var strict; 41 | try { x = 1; strict = false;} catch(e) { strict = true } 42 | 43 | if(strict) { 44 | y = 1; 45 | } else { 46 | throw new ReferenceError(); 47 | } 48 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/async/async_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | function $DONE(){ 34 | if(!arguments[0]) 35 | print('Test262:AsyncTestComplete'); 36 | else 37 | print('Error: ' + arguments[0]); 38 | } 39 | 40 | /*--- 41 | description: Async test 42 | flags: [async] 43 | ---*/ 44 | 45 | var p = new Promise(function(resolve) { 46 | resolve(); 47 | }); 48 | 49 | p.then($DONE, $DONE); 50 | -------------------------------------------------------------------------------- /test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | #! 34 | 35 | /*--- 36 | description: > 37 | Missing raw flag will result in the harness/runtime includes being added, 38 | however doing so will produce invalid test code. 39 | features: [hashbang] 40 | negative: 41 | phase: parse 42 | type: SyntaxError 43 | ---*/ 44 | 45 | throw "Test262: This statement should not be evaluated."; 46 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/asyncNegative_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | function $DONE(){ 33 | if(!arguments[0]) 34 | print('Test262:AsyncTestComplete'); 35 | else 36 | print('Error: ' + arguments[0]); 37 | } 38 | 39 | /*--- 40 | description: Async negative test 41 | negative: 42 | phase: runtime 43 | type: RangeError 44 | flags: [async] 45 | ---*/ 46 | 47 | setTimeout(function() { 48 | $DONE(new RangeError()); 49 | }, 1000); 50 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_default.js: -------------------------------------------------------------------------------- 1 | // This is assert.js 2 | 3 | 'It has some contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, trailing; 15 | whitespace: ; 16 | 17 | void "end of assert.js"; 18 | 19 | function Test262Error(message) { 20 | this.message = message || ""; 21 | } 22 | 23 | Test262Error.prototype.toString = function () { 24 | return "Test262Error: " + this.message; 25 | }; 26 | 27 | var $ERROR; 28 | $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | 32 | function $DONE(){ 33 | if(!arguments[0]) 34 | print('Test262:AsyncTestComplete'); 35 | else 36 | print('Error: ' + arguments[0]); 37 | } 38 | 39 | /*--- 40 | description: Async negative test 41 | negative: 42 | phase: runtime 43 | type: RangeError 44 | flags: [async] 45 | ---*/ 46 | 47 | setTimeout(function() { 48 | $DONE(new RangeError()); 49 | }, 1000); 50 | -------------------------------------------------------------------------------- /test/collateral/valid-default/expected-content/test/asyncNegative_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | function $DONE(){ 34 | if(!arguments[0]) 35 | print('Test262:AsyncTestComplete'); 36 | else 37 | print('Error: ' + arguments[0]); 38 | } 39 | 40 | /*--- 41 | description: Async negative test 42 | negative: 43 | phase: runtime 44 | type: RangeError 45 | flags: [async] 46 | ---*/ 47 | 48 | setTimeout(function() { 49 | $DONE(new RangeError()); 50 | }, 1000); 51 | -------------------------------------------------------------------------------- /test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is assert.js 3 | 4 | 'It has some contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, trailing; 16 | whitespace: ; 17 | 18 | void "end of assert.js"; 19 | 20 | function Test262Error(message) { 21 | this.message = message || ""; 22 | } 23 | 24 | Test262Error.prototype.toString = function () { 25 | return "Test262Error: " + this.message; 26 | }; 27 | 28 | var $ERROR; 29 | $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | 33 | function $DONE(){ 34 | if(!arguments[0]) 35 | print('Test262:AsyncTestComplete'); 36 | else 37 | print('Error: ' + arguments[0]); 38 | } 39 | 40 | /*--- 41 | description: Async negative test 42 | negative: 43 | phase: runtime 44 | type: RangeError 45 | flags: [async] 46 | ---*/ 47 | 48 | setTimeout(function() { 49 | $DONE(new RangeError()); 50 | }, 1000); 51 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-content/test/bothStrict_default.js: -------------------------------------------------------------------------------- 1 | // This is a CUSTOM assert.js 2 | 3 | 'It has some CUSTOM contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, CUSTOM, trailing; 15 | whitespace: ; 16 | 17 | void "end of CUSTOM assert.js"; 18 | 19 | // This is a custom implementation of `sta.js` 20 | function Test262Error(message) { 21 | this.message = message || ''; 22 | } 23 | 24 | Test262Error.prototype.toString = function() { 25 | return 'Test262Error: ' + this.message; 26 | }; 27 | 28 | var $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | // End custom implementation of `sta.js` 32 | 33 | /*--- 34 | description: Should test in both modes 35 | features: [var, try, if] 36 | negative: 37 | phase: runtime 38 | type: ReferenceError 39 | ---*/ 40 | var strict; 41 | try { x = 1; strict = false;} catch(e) { strict = true } 42 | 43 | if(strict) { 44 | y = 1; 45 | } else { 46 | throw new ReferenceError(); 47 | } 48 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-content/test/bothStrict_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is a CUSTOM assert.js 3 | 4 | 'It has some CUSTOM contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, CUSTOM, trailing; 16 | whitespace: ; 17 | 18 | void "end of CUSTOM assert.js"; 19 | 20 | // This is a custom implementation of `sta.js` 21 | function Test262Error(message) { 22 | this.message = message || ''; 23 | } 24 | 25 | Test262Error.prototype.toString = function() { 26 | return 'Test262Error: ' + this.message; 27 | }; 28 | 29 | var $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | // End custom implementation of `sta.js` 33 | 34 | /*--- 35 | description: Should test in both modes 36 | features: [var, try, if] 37 | negative: 38 | phase: runtime 39 | type: ReferenceError 40 | ---*/ 41 | var strict; 42 | try { x = 1; strict = false;} catch(e) { strict = true } 43 | 44 | if(strict) { 45 | y = 1; 46 | } else { 47 | throw new ReferenceError(); 48 | } 49 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-content/test/async_default.js: -------------------------------------------------------------------------------- 1 | // This is a CUSTOM assert.js 2 | 3 | 'It has some CUSTOM contents'; 4 | 5 | /* that 6 | * 7 | * should 8 | 9 | * not 10 | */ 11 | 12 | `be ${ "modified" }`; 13 | 14 | var including, CUSTOM, trailing; 15 | whitespace: ; 16 | 17 | void "end of CUSTOM assert.js"; 18 | 19 | // This is a custom implementation of `sta.js` 20 | function Test262Error(message) { 21 | this.message = message || ''; 22 | } 23 | 24 | Test262Error.prototype.toString = function() { 25 | return 'Test262Error: ' + this.message; 26 | }; 27 | 28 | var $ERROR = function $ERROR(message) { 29 | throw new Test262Error(message); 30 | }; 31 | // End custom implementation of `sta.js` 32 | 33 | // This is a customized implementation of `doneprintHandle.js` 34 | function $DONE(){ 35 | if(!arguments[0]) { 36 | print('Test262:AsyncTestComplete'); 37 | } else { 38 | print('Error: ' + arguments[0]); 39 | } 40 | } 41 | // End customized implementation of `doneprintHandle.js` 42 | 43 | /*--- 44 | description: Async test 45 | flags: [async] 46 | ---*/ 47 | 48 | var p = new Promise(function(resolve) { 49 | resolve(); 50 | }); 51 | 52 | p.then($DONE, $DONE); 53 | -------------------------------------------------------------------------------- /test/collateral/valid-with-includes/expected-content/test/async_strict_mode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This is a CUSTOM assert.js 3 | 4 | 'It has some CUSTOM contents'; 5 | 6 | /* that 7 | * 8 | * should 9 | 10 | * not 11 | */ 12 | 13 | `be ${ "modified" }`; 14 | 15 | var including, CUSTOM, trailing; 16 | whitespace: ; 17 | 18 | void "end of CUSTOM assert.js"; 19 | 20 | // This is a custom implementation of `sta.js` 21 | function Test262Error(message) { 22 | this.message = message || ''; 23 | } 24 | 25 | Test262Error.prototype.toString = function() { 26 | return 'Test262Error: ' + this.message; 27 | }; 28 | 29 | var $ERROR = function $ERROR(message) { 30 | throw new Test262Error(message); 31 | }; 32 | // End custom implementation of `sta.js` 33 | 34 | // This is a customized implementation of `doneprintHandle.js` 35 | function $DONE(){ 36 | if(!arguments[0]) { 37 | print('Test262:AsyncTestComplete'); 38 | } else { 39 | print('Error: ' + arguments[0]); 40 | } 41 | } 42 | // End customized implementation of `doneprintHandle.js` 43 | 44 | /*--- 45 | description: Async test 46 | flags: [async] 47 | ---*/ 48 | 49 | var p = new Promise(function(resolve) { 50 | resolve(); 51 | }); 52 | 53 | p.then($DONE, $DONE); 54 | -------------------------------------------------------------------------------- /lib/builder.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | const TestFile = require('./test-file'); 5 | 6 | module.exports = function builder(file, contents, options) { 7 | options = options || {}; 8 | if (!options.test262Dir && !options.includesDir) { 9 | throw new Error('Need one of test262Dir or includesDir options'); 10 | } 11 | 12 | if (options.test262Dir && !options.includesDir) { 13 | options.includesDir = path.join(options.test262Dir, 'harness'); 14 | } 15 | 16 | const test = new TestFile(file, contents); 17 | 18 | if (test.attrs.flags.raw || options.omitRuntime) { 19 | test.insertionIndex = test.attrs.flags.raw ? -1 : 0; 20 | return test; 21 | } 22 | 23 | const includes = test.attrs.includes; 24 | 25 | includes.push( 26 | 'assert.js', 27 | 'sta.js' 28 | ); 29 | 30 | if (test.attrs.flags.async) { 31 | includes.push('doneprintHandle.js'); 32 | } 33 | 34 | let includeContents = ''; 35 | for (let i = 0; i < includes.length; i++) { 36 | includeContents += fs.readFileSync( 37 | path.join(options.includesDir, includes[i]) 38 | ); 39 | includeContents += '\n'; 40 | } 41 | 42 | test.contents = includeContents + test.contents; 43 | test.insertionIndex = includeContents.length; 44 | 45 | return test; 46 | }; 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Thank you for your interest in `test262-stream`! 4 | 5 | ## Development environment 6 | 7 | This project relies on [Node.js](https://nodejs.org) version 6 or higher. Once 8 | installed, run the following command in a terminal located at the root of this 9 | project: 10 | 11 | npm install 12 | 13 | This will retrieve the Node.js packages necessary to run the project and its 14 | tests. 15 | 16 | ## Running the tests 17 | 18 | Execute the following command in a terminal located at the root of this 19 | project: 20 | 21 | npm test 22 | 23 | Please ensure that all tests pass before submitting a patch. 24 | 25 | The tests reference static files in the `test/` directory to determine expected 26 | behavior. Contributors who are changing this module's behavior will likely need 27 | to update these expectations. To ease maintenance, the static files can be 28 | automatically updated by setting the environment variable named `RECORD` prior 29 | to running the tests. On Unix-like systems, this can be achieved by running the 30 | tests with the following command: 31 | 32 | RECORD=true npm test 33 | 34 | When executed under these conditions, the tests will always pass and the 35 | expectation files will be modified to describe the current behavior. The 36 | modified versions should be verified for correctness and checked in to the 37 | project. 38 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Bocoup LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of [project] nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /LICENSE-MICROSOFT.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Microsoft Corporation 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of test262-parser nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Test262-Stream 2 | 3 | A [Node.js](https://nodejs.org) API for traversing [the Test262 test 4 | suite](https://github.com/tc39/test262). 5 | 6 | ## Usage 7 | 8 | ```js 9 | var TestStream = require('test262-stream'); 10 | var stream = new TestStream('/path/to/test262', { 11 | // Directory from which to load "includes" files (defaults to the 12 | // appropriate subdirectory of the provided `test262Dir` 13 | // Optional. Defaults to './harness' 14 | includesDir: '/path/to/includes/dir', 15 | 16 | // File system paths refining the set of tests that should be produced; 17 | // only tests whose source file matches one of these values (in the case of 18 | // file paths) or is contained by one of these paths (in the case of 19 | // directory paths) will be created; all paths are interpreted relative to 20 | // the root of the provided `test262Dir` 21 | // Optional. Defaults to ['test'] 22 | paths: ['test/built-ins/eval', 'test/language/statements/empty/S12.3_A1.js'], 23 | 24 | // Flag to disable the insertion of code necessary to execute the test 25 | // (e.g. assertion functions and "include" files); defaults to `false` 26 | omitRuntime: true, 27 | 28 | // By default, this stream will emit an error if the provided version of 29 | // Test262 is not supported; this behavior may be disabled by providing a 30 | // value of the expected version. Use of this option may cause the stream 31 | // to emit invalid tests; consider updating the library instead. 32 | acceptVersion: '2.0.0' 33 | }); 34 | 35 | stream.on('data', function(test) { 36 | // the path to the file from which the test was derived, relative to the 37 | // provided Test262 directory 38 | console.log(test.file); 39 | 40 | // the complete source text for the test; this contains any "includes" 41 | // files specified in the frontmatter, "prelude" content if specified (see 42 | // below), and any "scenario" transformations 43 | console.log(test.contents); 44 | 45 | // an object representation of the metadata declared in the test's 46 | // "frontmatter" section 47 | console.log(test.attrs); 48 | 49 | // the licensing information included within the test (if any) 50 | console.log(test.copyright); 51 | 52 | // name describing how the source file was interpreted to create the test 53 | console.log(test.scenario); 54 | 55 | // numeric offset within the `contents` string at which one or more 56 | // statements may be inserted without necessarily invalidating the test 57 | console.log(test.insertionIndex); 58 | }); 59 | 60 | stream.on('end', function() { 61 | console.log('No further tests.'); 62 | }); 63 | 64 | stream.on('error', function(err) { 65 | console.error('Something went wrong:', err); 66 | }); 67 | ``` 68 | 69 | ## License 70 | 71 | Copyright 2017, Bocoup LLC under the 3-Clause BSD License (see `LICENSE.txt`) 72 | -------------------------------------------------------------------------------- /lib/test-file.js: -------------------------------------------------------------------------------- 1 | // Based on 2 | // https://github.com/smikes/test262-parser/blob/04902c58d2e2d1b452b34754924b8e75f2e5f3ac/lib/parser.js 3 | // Copyright (C) 2014, Microsoft Corporation. All rights reserved. 4 | // This code is governed by the BSD License found in the LICENSE-MICROSOFT.txt 5 | 'use strict'; 6 | 7 | const yaml = require('js-yaml'); 8 | const yamlStart = '/*---'; 9 | const yamlEnd = '---*/'; 10 | 11 | /** 12 | * Extract copyright message 13 | * 14 | * @method extractCopyright 15 | * @param {Test262File} file - file object 16 | * @return {string} the copyright string extracted from contents 17 | * @private 18 | */ 19 | function extractCopyright(test262File) { 20 | let lines = test262File.contents.split(/\r|\n|\u2028|\u2029/); 21 | 22 | for (let line of lines) { 23 | // The very first line may be a hashbang, so look at 24 | // all lines until reaching a line that looks close 25 | // enough to copyright 26 | let result = /^(?:(?:\/\/.*)*) Copyright.*/.exec(line); 27 | if (result && result[0]) { 28 | return result[0]; 29 | } 30 | } 31 | 32 | return ''; 33 | } 34 | 35 | /** 36 | * Extract YAML frontmatter from a test262 test 37 | * @method extractYAML 38 | * @param {Test262File} file - file object 39 | * @return {string} the YAML frontmatter or empty string if none 40 | */ 41 | function extractYAML(test262File) { 42 | let start = test262File.contents.indexOf(yamlStart); 43 | 44 | if (start > -1) { 45 | return test262File.contents.substring(start + 5, test262File.contents.indexOf(yamlEnd)); 46 | } 47 | 48 | return ''; 49 | } 50 | 51 | /** 52 | * Extract and parse frontmatter from a test 53 | * @method loadAttrs 54 | * @param {Test262File} file - file object 55 | * @return {Object} - raw, unnormalized attributes 56 | * @private 57 | */ 58 | function loadAttrs(test262File) { 59 | let extracted = extractYAML(test262File); 60 | 61 | if (extracted) { 62 | try { 63 | return yaml.load(extracted); 64 | } catch (e) { 65 | throw new Error(`Error loading frontmatter from file ${test262File.file}\n${e.message}`); 66 | } 67 | } 68 | 69 | return {}; 70 | } 71 | 72 | /** 73 | * Normalize attributes; ensure that flags, includes exist 74 | * 75 | * @method extractAttrs 76 | * @param {Test262File} file - file object 77 | * @return {Test262FileAttrs} normalized attributes 78 | * @private 79 | */ 80 | function extractAttrs(test262File) { 81 | const attrs = loadAttrs(test262File); 82 | attrs.flags = attrs.flags || []; 83 | attrs.flags = attrs.flags.reduce((acc, v) => { 84 | acc[v] = true; 85 | return acc; 86 | }, {}); 87 | 88 | attrs.includes = attrs.includes || []; 89 | 90 | return attrs; 91 | } 92 | 93 | /** 94 | * filename 95 | * @property {string} file 96 | */ 97 | /** 98 | * test code 99 | * @property {string} contents 100 | */ 101 | /** 102 | * parsed, normalized attributes 103 | * @property {Object} attrs 104 | */ 105 | /** 106 | * copyright message 107 | * @property {string} copyright 108 | */ 109 | 110 | /** 111 | * list of harness files to include 112 | * @attribute {Array} includes 113 | */ 114 | /** 115 | * test flags; 116 | * https://github.com/tc39/test262/blob/master/INTERPRETING.md#flags 117 | * valid values include: 118 | * - async 119 | * - module 120 | * - noStrict 121 | * - onlyStrict 122 | * - raw 123 | * @attribute {Object} flags 124 | */ 125 | /** 126 | * author name 127 | * @attribute {String} author 128 | * @optional 129 | */ 130 | 131 | class Test262File { 132 | constructor(file, contents) { 133 | if (!file) { 134 | throw new Error('Test262File: missing "file"'); 135 | } 136 | 137 | if (!contents) { 138 | throw new Error('Test262File: missing "contents"'); 139 | } 140 | 141 | this.file = file; 142 | this.contents = contents; 143 | this.attrs = extractAttrs(this); 144 | this.copyright = extractCopyright(this); 145 | this.scenario = null; 146 | this.insertionIndex = null; 147 | } 148 | } 149 | 150 | module.exports = Test262File; 151 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const Readable = require('stream').Readable; 6 | 7 | const klaw = require('klaw'); 8 | 9 | const compile = require('./compile'); 10 | 11 | const paths = Symbol('paths'); 12 | const compileOpts = Symbol('includesDir'); 13 | const fileStream = Symbol('fileStream'); 14 | const onFile = Symbol('onFile'); 15 | const pendingOps = Symbol('pendingOps'); 16 | const fileStreamDone = Symbol('fileStreamDone'); 17 | const acceptVersion = Symbol('acceptVersion'); 18 | 19 | const supportedVersion = /^[12345]\./; 20 | const fixturePattern = /_FIXTURE/; 21 | 22 | /** 23 | * A Node.js readable stream that emits an object value for every test in a 24 | * given filesystem directory. This object has the following properties: 25 | * 26 | * - file {string} - the path to the file from which the test was derived, 27 | * relative to the provided Test262 directory 28 | * - contents {string} - the complete source text for the test; this contains 29 | * any "includes" files specified in the frontmatter, 30 | * "prelude" content if specified (see below), and any 31 | * "scenario" transformations 32 | * - attrs {object} - an object representation of the metadata declared in the 33 | * test's YAML-formatted "frontmatter" section 34 | * - copyright {string} - the licensing information included within the test 35 | * (if any) 36 | * - scenario {string} - name describing how the source file was interpreted to 37 | * create the test 38 | * - insertionIndex {number} - numeric offset within the `contents` string at 39 | * which one or more statements may be inserted 40 | * without necessarily invalidating the test 41 | * 42 | * @param {string} test262Dir - filesystem path to a directory containing 43 | * Test262 44 | * @param {object} [options] 45 | * @param {string} [options.includesDir] - directory from which to load 46 | * "includes" files (defaults to the 47 | * appropriate subdirectory of the 48 | * provided `test262Dir` 49 | * @param {Array} [options.paths] - file system paths refining the set 50 | * of tests that should be produced; 51 | * only tests whose source file 52 | * matches one of these values (in the 53 | * case of file paths) or is contained 54 | * by one of these paths (in the case 55 | * of directory paths) will be 56 | * created; all paths are interpreted 57 | * relative to the root of the 58 | * provided `test262Dir` 59 | * @param {string} [options.prelude] - string contents to inject into each 60 | * test that does not carry the `raw` 61 | * metadata flag; defaults to the empty 62 | * string (e.g. no injection) 63 | * @param {boolean} [options.omitRuntime] - flag to disable the insertion of 64 | * code necessary to execute the test 65 | * (e.g. assertion functions and 66 | * "include" files); defaults to 67 | * `false` 68 | * @param {string} [options.acceptVersion] - by default, this stream will emit 69 | * an error if the provided version 70 | * of Test262 is not supported; this 71 | * behavior may be disabled by 72 | * providing a value of the expected 73 | * version. Use of this option may 74 | * cause the stream to emit invalid 75 | * tests; consider updating the 76 | * library instead. 77 | * 78 | * @returns {object} readable stream 79 | */ 80 | module.exports = class TestStream extends Readable { 81 | constructor(test262Dir, options) { 82 | options = Object.assign({}, options); 83 | options.objectMode = true; 84 | super(options); 85 | this[test262Dir] = test262Dir; 86 | this[paths] = (options.paths || ['test']) 87 | .map(relativePath => path.join(test262Dir, relativePath)); 88 | this[compileOpts] = { 89 | test262Dir, 90 | includesDir: options.includesDir, 91 | omitRuntime: !!options.omitRuntime 92 | }; 93 | this[fileStream] = null; 94 | this[pendingOps] = 0; 95 | this[fileStreamDone] = false; 96 | this[acceptVersion] = options.acceptVersion; 97 | } 98 | 99 | _read() { 100 | if (this[fileStream]) { 101 | return; 102 | } 103 | const packagePath = path.join(this[compileOpts].test262Dir, 'package.json'); 104 | 105 | fs.readFile(packagePath, 'utf-8', (error, contents) => { 106 | if (error) { 107 | if (error.code === 'ENOENT') { 108 | this.traverse(); 109 | return; 110 | } 111 | 112 | this.emit('error', error); 113 | return; 114 | } 115 | 116 | let packageData; 117 | 118 | try { 119 | packageData = JSON.parse(contents); 120 | } catch (error) { 121 | this.emit('error', error); 122 | return; 123 | } 124 | 125 | const version = packageData.version; 126 | 127 | if (!supportedVersion.test(version) && this[acceptVersion] !== version) { 128 | this.emit( 129 | 'error', new Error(`Unsupported version of Test262: '${version}'`) 130 | ); 131 | return; 132 | } 133 | 134 | this.traverse(); 135 | }); 136 | } 137 | 138 | traverse() { 139 | this[fileStream] = klaw(this[paths].shift()); 140 | 141 | this[fileStream].on('data', (item) => this[onFile](item)); 142 | this[fileStream].on('error', (error) => this.emit('error', error)); 143 | 144 | this[fileStream].on('end', () => { 145 | if (this[paths].length) { 146 | this.traverse(); 147 | } else { 148 | this[fileStreamDone] = true; 149 | 150 | // If the final file visited is not a test and compilation for all 151 | // other tests has completed, the stream should signal completion. 152 | if (this[pendingOps] === 0) { 153 | this.push(null); 154 | } 155 | } 156 | }); 157 | } 158 | 159 | [onFile](item) { 160 | if (!item.stats.isFile()) { 161 | return; 162 | } 163 | if (path.basename(item.path)[0] === '.') { 164 | return; 165 | } 166 | if (fixturePattern.test(item.path)) { 167 | return; 168 | } 169 | 170 | this[pendingOps] += 1; 171 | 172 | compile(item.path, this[compileOpts], (err, tests) => { 173 | this[pendingOps] -= 1; 174 | 175 | if (err) { 176 | this.emit('error', err); 177 | return; 178 | } 179 | 180 | tests.forEach((test) => this.push(test)); 181 | 182 | if (this[pendingOps] === 0 && this[fileStreamDone]) { 183 | this.push(null); 184 | } 185 | }); 186 | } 187 | }; 188 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const fs = require('fs'); 3 | const mkdirp = require('mkdirp'); 4 | const path = require('path'); 5 | const rimraf = require('rimraf'); 6 | const tape = require('tape'); 7 | 8 | const TestStream = require('..'); 9 | const scenarios = /^(strict mode|default)$/; 10 | 11 | const RECORDING = !!process.env.RECORD; 12 | 13 | // Properties to exclude when validating metadata. The values are 14 | // inconsequential; they have been selected to aid in discoverability in the 15 | // programatically-generated "expectations" files. 16 | const blankOut = { 17 | contents: '(The value of this property is over-sized, so it is validated independently.)' 18 | }; 19 | 20 | function makeDataHandler(t, ids, fixtureDir) { 21 | const test262Dir = path.join(fixtureDir, 'fake-test262'); 22 | const expectedContentDir = path.join(fixtureDir, 'expected-content'); 23 | const expectedMetadataDir = path.join(fixtureDir, 'expected-metadata'); 24 | 25 | if (RECORDING) { 26 | rimraf.sync(expectedContentDir); 27 | rimraf.sync(expectedMetadataDir); 28 | } 29 | 30 | return (test) => { 31 | 32 | if (typeof test !== 'object' || test === null) { 33 | t.ok(false, 'Emits object values'); 34 | return; 35 | } 36 | 37 | const actualContents = test.contents; 38 | const actualMetadata = Object.assign({}, test, blankOut); 39 | 40 | if (!fs.existsSync(path.join(test262Dir, test.file))) { 41 | t.ok(false, 'Source file does not exist: ' + test.file); 42 | return; 43 | } 44 | 45 | // `RegExp.prototype.test` acceptes `undefined`, so an explicit type 46 | // check is necessary. 47 | t.equal(typeof test.scenario, 'string', '`scenario` property is a string value'); 48 | t.ok(scenarios.test(test.scenario), '`scenario` property is a valid value'); 49 | 50 | const id = test.file.replace(/\.js$/, '_' + test.scenario.replace(' ', '_')); 51 | const expectedContentFile = path.join(expectedContentDir, id) + '.js'; 52 | const expectedMetadataFile = path.join(expectedMetadataDir, id) + '.json'; 53 | 54 | t.not(ids.indexOf(id) === -1, 'Emits each test exactly once'); 55 | ids.push(id); 56 | 57 | if (RECORDING) { 58 | mkdirp.sync(path.dirname(expectedContentFile)); 59 | fs.writeFileSync(expectedContentFile, actualContents, 'utf-8'); 60 | mkdirp.sync(path.dirname(expectedMetadataFile)); 61 | fs.writeFileSync(expectedMetadataFile, JSON.stringify(actualMetadata, null, 2), 'utf-8'); 62 | return; 63 | } 64 | 65 | if (!fs.existsSync(expectedContentFile)) { 66 | t.ok(false, 'Expected content file not found: ' + expectedContentFile); 67 | return; 68 | } 69 | 70 | if (!fs.existsSync(expectedMetadataFile)) { 71 | t.ok(false, 'Expected metadata file not found: ' + expectedMetadataFile); 72 | return; 73 | } 74 | 75 | t.deepEqual(actualContents, fs.readFileSync(expectedContentFile, 'utf-8')); 76 | t.deepEqual(actualMetadata, require(expectedMetadataFile)); 77 | }; 78 | } 79 | 80 | tape('valid source directory', t => { 81 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-default'); 82 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262')); 83 | const ids = []; 84 | 85 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 86 | 87 | stream.on('error', (error) => { 88 | t.ok(error); 89 | t.end(error); 90 | }); 91 | 92 | stream.on('end', () => { 93 | t.equal(ids.length, 16, 'Reports every available test'); 94 | t.end(); 95 | }); 96 | }); 97 | 98 | tape('valid source directory (with paths)', t => { 99 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-with-paths'); 100 | const paths = ['test/bothStrict.js', 'test/strict/no', 'test/async']; 101 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262'), { paths }); 102 | const ids = []; 103 | 104 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 105 | 106 | stream.on('error', (error) => { 107 | t.ok(error); 108 | t.end(error); 109 | }); 110 | 111 | stream.on('end', () => { 112 | t.equal(ids.length, 8, 'Reports every available test'); 113 | t.end(); 114 | }); 115 | }); 116 | 117 | tape('valid source directory (with custom includes)', t => { 118 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-with-includes'); 119 | const includesDir = path.join(fixtureDir, 'custom-includes'); 120 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262'), { includesDir }); 121 | const ids = []; 122 | 123 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 124 | 125 | stream.on('error', (error) => { 126 | t.ok(error); 127 | t.end(error); 128 | }); 129 | 130 | stream.on('end', () => { 131 | t.equal(ids.length, 4, 'Reports every available test'); 132 | t.end(); 133 | }); 134 | }); 135 | 136 | tape('missing `assert.js`', t => { 137 | const stream = new TestStream(path.join(__dirname, 'collateral', 'invalid-missing-harness')); 138 | 139 | stream.on('data', () => { 140 | t.end(new Error('Stream should not emit a `data` event')); 141 | }); 142 | 143 | stream.on('end', () => { 144 | t.end(new Error('Stream should not emit an `end` event')); 145 | }); 146 | 147 | stream.on('error', (error) => { 148 | t.ok(error, '`error` event should be published with an object'); 149 | t.end(); 150 | }); 151 | }); 152 | 153 | tape.skip('non-existent source directory', t => { 154 | const stream = new TestStream(path.join(__dirname, 'collateral', 'this-directory-does-not-exist')); 155 | 156 | stream.on('data', () => { 157 | t.end(new Error('Stream should not emit a `data` event')); 158 | }); 159 | 160 | stream.on('end', () => { 161 | t.end(new Error('Stream should not emit an `end` event')); 162 | }); 163 | 164 | stream.on('error', (error) => { 165 | t.ok(error, '`error` event should be published with an object'); 166 | t.end(); 167 | }); 168 | }); 169 | 170 | tape('valid source directory (with a supported version)', t => { 171 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-version-supported'); 172 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262')); 173 | const ids = []; 174 | 175 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 176 | 177 | stream.on('error', (error) => { 178 | t.ok(error); 179 | t.end(error); 180 | }); 181 | 182 | stream.on('end', () => { 183 | t.equal(ids.length, 1, 'Reports every available test'); 184 | t.end(); 185 | }); 186 | }); 187 | 188 | tape('invalid source directory (with an unsupported version)', t => { 189 | const fixtureDir = path.join(__dirname, 'collateral', 'invalid-version-unsupported'); 190 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262')); 191 | 192 | stream.on('data', () => { 193 | t.end(new Error('Stream should not emit a `data` event')); 194 | }); 195 | 196 | stream.on('end', () => { 197 | t.end(new Error('Stream should not emit an `end` event')); 198 | }); 199 | 200 | stream.on('error', (error) => { 201 | t.ok(error, '`error` event should be published with an object'); 202 | t.end(); 203 | }); 204 | }); 205 | 206 | tape('invalid source directory (accepting newer version)', t => { 207 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-version-ignored'); 208 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262'), { 209 | acceptVersion: '999.0.0' 210 | }); 211 | const ids = []; 212 | 213 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 214 | 215 | stream.on('error', (error) => { 216 | t.ok(error); 217 | t.end(error); 218 | }); 219 | 220 | stream.on('end', () => { 221 | t.equal(ids.length, 1, 'Reports every available test'); 222 | t.end(); 223 | }); 224 | }); 225 | 226 | tape('invalid source directory (with a version that differs from the "accepted" versoin)', t => { 227 | const fixtureDir = path.join(__dirname, 'collateral', 'invalid-version-other-accepted'); 228 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262'), { 229 | acceptVersion: '3.0.1' 230 | }); 231 | 232 | stream.on('data', () => { 233 | t.end(new Error('Stream should not emit a `data` event')); 234 | }); 235 | 236 | stream.on('end', () => { 237 | t.end(new Error('Stream should not emit an `end` event')); 238 | }); 239 | 240 | stream.on('error', (error) => { 241 | t.ok(error, '`error` event should be published with an object'); 242 | t.end(); 243 | }); 244 | }); 245 | 246 | tape('omit runtime', t => { 247 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-omit-runtime'); 248 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262'), { 249 | omitRuntime: true 250 | }); 251 | const ids = []; 252 | 253 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 254 | 255 | stream.on('error', (error) => { 256 | t.ok(error); 257 | t.end(error); 258 | }); 259 | 260 | stream.on('end', () => { 261 | t.equal(ids.length, 16, 'Reports every available test'); 262 | t.end(); 263 | }); 264 | }); 265 | 266 | tape('completion detection when final files visited are not tests', t => { 267 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-extra-files'); 268 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262')); 269 | const ids = []; 270 | 271 | global.mike = true; 272 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 273 | 274 | stream.on('error', (error) => { 275 | t.ok(error); 276 | t.end(error); 277 | }); 278 | 279 | stream.on('end', () => { 280 | t.equal(ids.length, 2, 'Reports every available test'); 281 | t.end(); 282 | }); 283 | }); 284 | 285 | tape('valid source directory (with hashbang tests)', t => { 286 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-with-hashbang'); 287 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262')); 288 | const ids = []; 289 | 290 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 291 | 292 | stream.on('error', (error) => { 293 | t.ok(error); 294 | t.end(error); 295 | }); 296 | 297 | stream.on('end', () => { 298 | t.equal(ids.length, 10, 'Reports every available test'); 299 | t.end(); 300 | }); 301 | }); 302 | 303 | tape('copyright and insertionIndex integrity', t => { 304 | const fixtureDir = path.join(__dirname, 'collateral', 'valid-insertionindex-with-copyright'); 305 | const stream = new TestStream(path.join(fixtureDir, 'fake-test262')); 306 | const ids = []; 307 | 308 | stream.on('data', makeDataHandler(t, ids, fixtureDir)); 309 | 310 | stream.on('error', (error) => { 311 | t.ok(error); 312 | t.end(error); 313 | }); 314 | 315 | stream.on('end', () => { 316 | t.equal(ids.length, 3, 'Reports every available test'); 317 | t.end(); 318 | }); 319 | }); 320 | --------------------------------------------------------------------------------