@babel/test262-stream 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-BOCOUP.txt +27 -0
- package/LICENSE.txt +1 -1
- package/README.md +11 -1
- package/lib/builder.js +50 -15
- package/lib/compile.js +14 -11
- package/lib/create-scenarios.js +41 -10
- package/lib/index.d.ts +137 -0
- package/lib/index.js +202 -58
- package/lib/test-file.js +34 -11
- package/package.json +18 -9
- package/.jshintignore +0 -2
- package/.jshintrc +0 -6
- package/.travis.yml +0 -5
- package/CONTRIBUTING.md +0 -37
- package/test/collateral/invalid-missing-harness/fake-test262/test/a-test-file.js +0 -16
- package/test/collateral/invalid-version-other-accepted/fake-test262/harness/assert.js +0 -17
- package/test/collateral/invalid-version-other-accepted/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/invalid-version-other-accepted/fake-test262/harness/sta.js +0 -12
- package/test/collateral/invalid-version-other-accepted/fake-test262/package.json +0 -3
- package/test/collateral/invalid-version-other-accepted/fake-test262/test/strict.js +0 -9
- package/test/collateral/invalid-version-unsupported/fake-test262/harness/assert.js +0 -17
- package/test/collateral/invalid-version-unsupported/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/invalid-version-unsupported/fake-test262/harness/sta.js +0 -12
- package/test/collateral/invalid-version-unsupported/fake-test262/package.json +0 -3
- package/test/collateral/invalid-version-unsupported/fake-test262/test/strict.js +0 -9
- package/test/collateral/valid-default/expected-content/test/asyncNegative_default.js +0 -49
- package/test/collateral/valid-default/expected-content/test/asyncNegative_strict_mode.js +0 -50
- package/test/collateral/valid-default/expected-content/test/async_default.js +0 -48
- package/test/collateral/valid-default/expected-content/test/async_strict_mode.js +0 -49
- package/test/collateral/valid-default/expected-content/test/bothStrict_default.js +0 -46
- package/test/collateral/valid-default/expected-content/test/bothStrict_strict_mode.js +0 -47
- package/test/collateral/valid-default/expected-content/test/error_default.js +0 -39
- package/test/collateral/valid-default/expected-content/test/error_strict_mode.js +0 -40
- package/test/collateral/valid-default/expected-content/test/module_default.js +0 -37
- package/test/collateral/valid-default/expected-content/test/module_strict_mode.js +0 -38
- package/test/collateral/valid-default/expected-content/test/negative-empty_default.js +0 -37
- package/test/collateral/valid-default/expected-content/test/negative-empty_strict_mode.js +0 -38
- package/test/collateral/valid-default/expected-content/test/noStrict_default.js +0 -36
- package/test/collateral/valid-default/expected-content/test/rawNoStrict_default.js +0 -14
- package/test/collateral/valid-default/expected-content/test/rawStrict_default.js +0 -15
- package/test/collateral/valid-default/expected-content/test/strict_strict_mode.js +0 -41
- package/test/collateral/valid-default/expected-metadata/test/asyncNegative_default.json +0 -22
- package/test/collateral/valid-default/expected-metadata/test/asyncNegative_strict_mode.json +0 -22
- package/test/collateral/valid-default/expected-metadata/test/async_default.json +0 -18
- package/test/collateral/valid-default/expected-metadata/test/async_strict_mode.json +0 -18
- package/test/collateral/valid-default/expected-metadata/test/bothStrict_default.json +0 -24
- package/test/collateral/valid-default/expected-metadata/test/bothStrict_strict_mode.json +0 -24
- package/test/collateral/valid-default/expected-metadata/test/error_default.json +0 -19
- package/test/collateral/valid-default/expected-metadata/test/error_strict_mode.json +0 -19
- package/test/collateral/valid-default/expected-metadata/test/module_default.json +0 -17
- package/test/collateral/valid-default/expected-metadata/test/module_strict_mode.json +0 -17
- package/test/collateral/valid-default/expected-metadata/test/negative-empty_default.json +0 -19
- package/test/collateral/valid-default/expected-metadata/test/negative-empty_strict_mode.json +0 -19
- package/test/collateral/valid-default/expected-metadata/test/noStrict_default.json +0 -17
- package/test/collateral/valid-default/expected-metadata/test/rawNoStrict_default.json +0 -14
- package/test/collateral/valid-default/expected-metadata/test/rawStrict_default.json +0 -14
- package/test/collateral/valid-default/expected-metadata/test/strict_strict_mode.json +0 -21
- package/test/collateral/valid-default/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-default/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-default/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-default/fake-test262/test/async.js +0 -10
- package/test/collateral/valid-default/fake-test262/test/asyncNegative.js +0 -11
- package/test/collateral/valid-default/fake-test262/test/bothStrict.js +0 -15
- package/test/collateral/valid-default/fake-test262/test/error.js +0 -8
- package/test/collateral/valid-default/fake-test262/test/module.js +0 -6
- package/test/collateral/valid-default/fake-test262/test/module_FIXTURE.js +0 -2
- package/test/collateral/valid-default/fake-test262/test/negative-empty.js +0 -6
- package/test/collateral/valid-default/fake-test262/test/noStrict.js +0 -5
- package/test/collateral/valid-default/fake-test262/test/rawNoStrict.js +0 -14
- package/test/collateral/valid-default/fake-test262/test/rawStrict.js +0 -15
- package/test/collateral/valid-default/fake-test262/test/strict.js +0 -9
- package/test/collateral/valid-extra-files/expected-content/test/bothStrict_default.js +0 -46
- package/test/collateral/valid-extra-files/expected-content/test/bothStrict_strict_mode.js +0 -47
- package/test/collateral/valid-extra-files/expected-metadata/test/bothStrict_default.json +0 -24
- package/test/collateral/valid-extra-files/expected-metadata/test/bothStrict_strict_mode.json +0 -24
- package/test/collateral/valid-extra-files/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-extra-files/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-extra-files/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-extra-files/fake-test262/test/bothStrict.js +0 -15
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-0_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-1_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-2_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-3_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-4_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-5_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-6_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-7_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-8_FIXTURE.js +0 -2
- package/test/collateral/valid-extra-files/fake-test262/test/zzz-9_FIXTURE.txt +0 -2
- package/test/collateral/valid-insertionindex-with-copyright/expected-content/test/raw_default.js +0 -15
- package/test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_default.js +0 -38
- package/test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_strict_mode.js +0 -39
- package/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/raw_default.json +0 -14
- package/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_default.json +0 -15
- package/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_strict_mode.json +0 -15
- package/test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-insertionindex-with-copyright/fake-test262/test/raw.js +0 -15
- package/test/collateral/valid-insertionindex-with-copyright/fake-test262/test/runtime.js +0 -7
- package/test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_default.js +0 -11
- package/test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_strict_mode.js +0 -12
- package/test/collateral/valid-omit-runtime/expected-content/test/async_default.js +0 -10
- package/test/collateral/valid-omit-runtime/expected-content/test/async_strict_mode.js +0 -11
- package/test/collateral/valid-omit-runtime/expected-content/test/bothStrict_default.js +0 -15
- package/test/collateral/valid-omit-runtime/expected-content/test/bothStrict_strict_mode.js +0 -16
- package/test/collateral/valid-omit-runtime/expected-content/test/error_default.js +0 -8
- package/test/collateral/valid-omit-runtime/expected-content/test/error_strict_mode.js +0 -9
- package/test/collateral/valid-omit-runtime/expected-content/test/module_default.js +0 -6
- package/test/collateral/valid-omit-runtime/expected-content/test/module_strict_mode.js +0 -7
- package/test/collateral/valid-omit-runtime/expected-content/test/negative-empty_default.js +0 -6
- package/test/collateral/valid-omit-runtime/expected-content/test/negative-empty_strict_mode.js +0 -7
- package/test/collateral/valid-omit-runtime/expected-content/test/noStrict_default.js +0 -5
- package/test/collateral/valid-omit-runtime/expected-content/test/rawNoStrict_default.js +0 -14
- package/test/collateral/valid-omit-runtime/expected-content/test/rawStrict_default.js +0 -15
- package/test/collateral/valid-omit-runtime/expected-content/test/strict_strict_mode.js +0 -10
- package/test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_default.json +0 -18
- package/test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_strict_mode.json +0 -18
- package/test/collateral/valid-omit-runtime/expected-metadata/test/async_default.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/async_strict_mode.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_default.json +0 -21
- package/test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_strict_mode.json +0 -21
- package/test/collateral/valid-omit-runtime/expected-metadata/test/error_default.json +0 -16
- package/test/collateral/valid-omit-runtime/expected-metadata/test/error_strict_mode.json +0 -16
- package/test/collateral/valid-omit-runtime/expected-metadata/test/module_default.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/module_strict_mode.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_default.json +0 -16
- package/test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_strict_mode.json +0 -16
- package/test/collateral/valid-omit-runtime/expected-metadata/test/noStrict_default.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/rawNoStrict_default.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/rawStrict_default.json +0 -14
- package/test/collateral/valid-omit-runtime/expected-metadata/test/strict_strict_mode.json +0 -18
- package/test/collateral/valid-omit-runtime/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-omit-runtime/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-omit-runtime/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-omit-runtime/fake-test262/test/async.js +0 -10
- package/test/collateral/valid-omit-runtime/fake-test262/test/asyncNegative.js +0 -11
- package/test/collateral/valid-omit-runtime/fake-test262/test/bothStrict.js +0 -15
- package/test/collateral/valid-omit-runtime/fake-test262/test/error.js +0 -8
- package/test/collateral/valid-omit-runtime/fake-test262/test/module.js +0 -6
- package/test/collateral/valid-omit-runtime/fake-test262/test/module_FIXTURE.js +0 -2
- package/test/collateral/valid-omit-runtime/fake-test262/test/negative-empty.js +0 -6
- package/test/collateral/valid-omit-runtime/fake-test262/test/noStrict.js +0 -5
- package/test/collateral/valid-omit-runtime/fake-test262/test/rawNoStrict.js +0 -14
- package/test/collateral/valid-omit-runtime/fake-test262/test/rawStrict.js +0 -15
- package/test/collateral/valid-omit-runtime/fake-test262/test/strict.js +0 -9
- package/test/collateral/valid-version-ignored/expected-content/test/strict_strict_mode.js +0 -41
- package/test/collateral/valid-version-ignored/expected-metadata/test/strict_strict_mode.json +0 -21
- package/test/collateral/valid-version-ignored/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-version-ignored/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-version-ignored/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-version-ignored/fake-test262/package.json +0 -3
- package/test/collateral/valid-version-ignored/fake-test262/test/strict.js +0 -9
- package/test/collateral/valid-version-supported/expected-content/test/strict_strict_mode.js +0 -41
- package/test/collateral/valid-version-supported/expected-metadata/test/strict_strict_mode.json +0 -21
- package/test/collateral/valid-version-supported/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-version-supported/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-version-supported/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-version-supported/fake-test262/package.json +0 -3
- package/test/collateral/valid-version-supported/fake-test262/test/strict.js +0 -9
- package/test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_default.js +0 -44
- package/test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_strict_mode.js +0 -45
- package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-and-license-on-same-line_default.js +0 -20
- package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-multiline-block_default.js +0 -18
- package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls_default.js +0 -17
- package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-and-license-on-same-line_default.js +0 -20
- package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-multiline-block_default.js +0 -18
- package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps_default.js +0 -17
- package/test/collateral/valid-with-hashbang/expected-content/test/rawWithLicense_default.js +0 -21
- package/test/collateral/valid-with-hashbang/expected-content/test/raw_default.js +0 -17
- package/test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_default.json +0 -22
- package/test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_strict_mode.json +0 -22
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-and-license-on-same-line_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-multiline-block_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-and-license-on-same-line_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-multiline-block_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/rawWithLicense_default.json +0 -21
- package/test/collateral/valid-with-hashbang/expected-metadata/test/raw_default.json +0 -21
- package/test/collateral/valid-with-hashbang/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-with-hashbang/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-with-hashbang/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-with-hashbang/fake-test262/test/missing-raw-flag.js +0 -13
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-and-license-on-same-line.js +0 -20
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-multiline-block.js +0 -18
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls.js +0 -17
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-and-license-on-same-line.js +0 -20
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-multiline-block.js +0 -18
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps.js +0 -17
- package/test/collateral/valid-with-hashbang/fake-test262/test/raw.js +0 -17
- package/test/collateral/valid-with-hashbang/fake-test262/test/rawWithLicense.js +0 -21
- package/test/collateral/valid-with-includes/custom-includes/assert.js +0 -17
- package/test/collateral/valid-with-includes/custom-includes/doneprintHandle.js +0 -9
- package/test/collateral/valid-with-includes/custom-includes/sta.js +0 -13
- package/test/collateral/valid-with-includes/expected-content/test/async_default.js +0 -52
- package/test/collateral/valid-with-includes/expected-content/test/async_strict_mode.js +0 -53
- package/test/collateral/valid-with-includes/expected-content/test/bothStrict_default.js +0 -47
- package/test/collateral/valid-with-includes/expected-content/test/bothStrict_strict_mode.js +0 -48
- package/test/collateral/valid-with-includes/expected-metadata/test/async_default.json +0 -18
- package/test/collateral/valid-with-includes/expected-metadata/test/async_strict_mode.json +0 -18
- package/test/collateral/valid-with-includes/expected-metadata/test/bothStrict_default.json +0 -24
- package/test/collateral/valid-with-includes/expected-metadata/test/bothStrict_strict_mode.json +0 -24
- package/test/collateral/valid-with-includes/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-with-includes/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-with-includes/fake-test262/test/async.js +0 -10
- package/test/collateral/valid-with-includes/fake-test262/test/bothStrict.js +0 -15
- package/test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_default.js +0 -49
- package/test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_strict_mode.js +0 -50
- package/test/collateral/valid-with-paths/expected-content/test/async/async_default.js +0 -48
- package/test/collateral/valid-with-paths/expected-content/test/async/async_strict_mode.js +0 -49
- package/test/collateral/valid-with-paths/expected-content/test/bothStrict_default.js +0 -46
- package/test/collateral/valid-with-paths/expected-content/test/bothStrict_strict_mode.js +0 -47
- package/test/collateral/valid-with-paths/expected-content/test/strict/no/noStrict_default.js +0 -36
- package/test/collateral/valid-with-paths/expected-content/test/strict/no/rawNoStrict_default.js +0 -14
- package/test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_default.json +0 -22
- package/test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_strict_mode.json +0 -22
- package/test/collateral/valid-with-paths/expected-metadata/test/async/async_default.json +0 -18
- package/test/collateral/valid-with-paths/expected-metadata/test/async/async_strict_mode.json +0 -18
- package/test/collateral/valid-with-paths/expected-metadata/test/bothStrict_default.json +0 -24
- package/test/collateral/valid-with-paths/expected-metadata/test/bothStrict_strict_mode.json +0 -24
- package/test/collateral/valid-with-paths/expected-metadata/test/strict/no/noStrict_default.json +0 -17
- package/test/collateral/valid-with-paths/expected-metadata/test/strict/no/rawNoStrict_default.json +0 -14
- package/test/collateral/valid-with-paths/fake-test262/harness/assert.js +0 -17
- package/test/collateral/valid-with-paths/fake-test262/harness/doneprintHandle.js +0 -6
- package/test/collateral/valid-with-paths/fake-test262/harness/sta.js +0 -12
- package/test/collateral/valid-with-paths/fake-test262/test/async/async.js +0 -10
- package/test/collateral/valid-with-paths/fake-test262/test/async/asyncNegative.js +0 -11
- package/test/collateral/valid-with-paths/fake-test262/test/bothStrict.js +0 -15
- package/test/collateral/valid-with-paths/fake-test262/test/error.js +0 -8
- package/test/collateral/valid-with-paths/fake-test262/test/negative-empty.js +0 -6
- package/test/collateral/valid-with-paths/fake-test262/test/strict/no/noStrict.js +0 -5
- package/test/collateral/valid-with-paths/fake-test262/test/strict/no/rawNoStrict.js +0 -14
- package/test/collateral/valid-with-paths/fake-test262/test/strict/rawStrict.js +0 -15
- package/test/collateral/valid-with-paths/fake-test262/test/strict/strict.js +0 -9
- package/test/test.js +0 -319
package/lib/index.js
CHANGED
|
@@ -4,21 +4,52 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const Readable = require('stream').Readable;
|
|
6
6
|
|
|
7
|
-
const klaw = require('klaw');
|
|
8
|
-
|
|
9
7
|
const compile = require('./compile');
|
|
10
8
|
|
|
11
|
-
const
|
|
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');
|
|
9
|
+
const compileOpts = Symbol('compileOpts');
|
|
17
10
|
const acceptVersion = Symbol('acceptVersion');
|
|
11
|
+
const started = Symbol('started');
|
|
12
|
+
const pending = Symbol('pending');
|
|
13
|
+
const active = Symbol('active');
|
|
14
|
+
const ended = Symbol('ended');
|
|
15
|
+
const failed = Symbol('failed');
|
|
16
|
+
const wanted = Symbol('wanted');
|
|
17
|
+
const next = Symbol('next');
|
|
18
|
+
const visit = Symbol('visit');
|
|
19
|
+
const enqueue = Symbol('enqueue');
|
|
20
|
+
const done = Symbol('done');
|
|
21
|
+
const fail = Symbol('fail');
|
|
18
22
|
|
|
19
23
|
const supportedVersion = /^[12345]\./;
|
|
20
24
|
const fixturePattern = /_FIXTURE/;
|
|
21
25
|
|
|
26
|
+
// Returns `path.relative(test262Dir, filePath)`, where `filePath` is
|
|
27
|
+
// `path.join(test262Dir, relativePath)`, without resolving both paths against
|
|
28
|
+
// the working directory when `relativePath` is within `test262Dir`.
|
|
29
|
+
function relativeFile(test262Dir, relativePath, filePath) {
|
|
30
|
+
let file = path.normalize(relativePath);
|
|
31
|
+
|
|
32
|
+
// `path.normalize` keeps a trailing separator, as in `./` or `test/`.
|
|
33
|
+
if (file.length > 1 && file[file.length - 1] === path.sep) {
|
|
34
|
+
file = file.slice(0, -1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
path.isAbsolute(relativePath) ||
|
|
39
|
+
file === '.' ||
|
|
40
|
+
file === '..' ||
|
|
41
|
+
file.slice(0, 3) === '..' + path.sep
|
|
42
|
+
) {
|
|
43
|
+
return path.relative(test262Dir, filePath);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return file;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Maximum number of file system operations in flight. Reading files one at a
|
|
50
|
+
// time leaves the main thread idle while it waits for each of them.
|
|
51
|
+
const concurrency = 64;
|
|
52
|
+
|
|
22
53
|
/**
|
|
23
54
|
* A Node.js readable stream that emits an object value for every test in a
|
|
24
55
|
* given filesystem directory. This object has the following properties:
|
|
@@ -39,6 +70,12 @@ const fixturePattern = /_FIXTURE/;
|
|
|
39
70
|
* which one or more statements may be inserted
|
|
40
71
|
* without necessarily invalidating the test
|
|
41
72
|
*
|
|
73
|
+
* Tests are emitted in no specified order: files are read concurrently, so
|
|
74
|
+
* the tests of different files, and of different `paths`, may be interleaved.
|
|
75
|
+
*
|
|
76
|
+
* An error, such as a file that cannot be read or invalid frontmatter, ends
|
|
77
|
+
* the stream: it emits an `error` event, and no further tests or `end` event.
|
|
78
|
+
*
|
|
42
79
|
* @param {string} test262Dir - filesystem path to a directory containing
|
|
43
80
|
* Test262
|
|
44
81
|
* @param {object} [options]
|
|
@@ -82,34 +119,55 @@ module.exports = class TestStream extends Readable {
|
|
|
82
119
|
options = Object.assign({}, options);
|
|
83
120
|
options.objectMode = true;
|
|
84
121
|
super(options);
|
|
85
|
-
this[test262Dir] = test262Dir;
|
|
86
|
-
this[paths] = (options.paths || ['test'])
|
|
87
|
-
.map(relativePath => path.join(test262Dir, relativePath));
|
|
88
122
|
this[compileOpts] = {
|
|
89
123
|
test262Dir,
|
|
90
124
|
includesDir: options.includesDir,
|
|
91
|
-
omitRuntime: !!options.omitRuntime
|
|
125
|
+
omitRuntime: !!options.omitRuntime,
|
|
126
|
+
includesCache: new Map()
|
|
92
127
|
};
|
|
93
|
-
this[fileStream] = null;
|
|
94
|
-
this[pendingOps] = 0;
|
|
95
|
-
this[fileStreamDone] = false;
|
|
96
128
|
this[acceptVersion] = options.acceptVersion;
|
|
129
|
+
this[started] = false;
|
|
130
|
+
// Stack of paths to visit, the next one last, with their `file` relative
|
|
131
|
+
// to `test262Dir`. `isDirectory` is undefined for the paths given in
|
|
132
|
+
// `options.paths`, which are not known to be files or directories until
|
|
133
|
+
// they are read.
|
|
134
|
+
this[pending] = (options.paths || ['test'])
|
|
135
|
+
.map(relativePath => {
|
|
136
|
+
const filePath = path.join(test262Dir, relativePath);
|
|
137
|
+
return {
|
|
138
|
+
path: filePath,
|
|
139
|
+
file: relativeFile(test262Dir, relativePath, filePath),
|
|
140
|
+
isDirectory: undefined
|
|
141
|
+
};
|
|
142
|
+
})
|
|
143
|
+
.reverse();
|
|
144
|
+
this[active] = 0;
|
|
145
|
+
this[ended] = false;
|
|
146
|
+
this[failed] = false;
|
|
147
|
+
// Whether the stream's buffer has room for more tests, as signaled by
|
|
148
|
+
// `_read` and `push`.
|
|
149
|
+
this[wanted] = false;
|
|
97
150
|
}
|
|
98
151
|
|
|
99
152
|
_read() {
|
|
100
|
-
|
|
153
|
+
this[wanted] = true;
|
|
154
|
+
|
|
155
|
+
if (this[started]) {
|
|
156
|
+
this[next]();
|
|
101
157
|
return;
|
|
102
158
|
}
|
|
159
|
+
this[started] = true;
|
|
160
|
+
|
|
103
161
|
const packagePath = path.join(this[compileOpts].test262Dir, 'package.json');
|
|
104
162
|
|
|
105
163
|
fs.readFile(packagePath, 'utf-8', (error, contents) => {
|
|
106
164
|
if (error) {
|
|
107
165
|
if (error.code === 'ENOENT') {
|
|
108
|
-
this
|
|
166
|
+
this[next]();
|
|
109
167
|
return;
|
|
110
168
|
}
|
|
111
169
|
|
|
112
|
-
this
|
|
170
|
+
this[fail](error);
|
|
113
171
|
return;
|
|
114
172
|
}
|
|
115
173
|
|
|
@@ -118,70 +176,156 @@ module.exports = class TestStream extends Readable {
|
|
|
118
176
|
try {
|
|
119
177
|
packageData = JSON.parse(contents);
|
|
120
178
|
} catch (error) {
|
|
121
|
-
this
|
|
179
|
+
this[fail](error);
|
|
122
180
|
return;
|
|
123
181
|
}
|
|
124
182
|
|
|
125
183
|
const version = packageData.version;
|
|
126
184
|
|
|
127
185
|
if (!supportedVersion.test(version) && this[acceptVersion] !== version) {
|
|
128
|
-
this
|
|
129
|
-
|
|
186
|
+
this[fail](
|
|
187
|
+
new Error(`Unsupported version of Test262: '${version}'`)
|
|
130
188
|
);
|
|
131
189
|
return;
|
|
132
190
|
}
|
|
133
191
|
|
|
134
|
-
this
|
|
192
|
+
this[next]();
|
|
135
193
|
});
|
|
136
194
|
}
|
|
137
195
|
|
|
138
|
-
|
|
139
|
-
|
|
196
|
+
// Starts visiting paths until reaching the concurrency limit or filling the
|
|
197
|
+
// stream's buffer, and ends the stream once every path has been visited.
|
|
198
|
+
[next]() {
|
|
199
|
+
if (this[failed] || this.destroyed) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
140
202
|
|
|
141
|
-
|
|
142
|
-
|
|
203
|
+
while (
|
|
204
|
+
this[wanted] &&
|
|
205
|
+
this[active] < concurrency &&
|
|
206
|
+
this[pending].length > 0
|
|
207
|
+
) {
|
|
208
|
+
this[active] += 1;
|
|
209
|
+
this[visit](this[pending].pop());
|
|
210
|
+
}
|
|
143
211
|
|
|
144
|
-
this[
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
212
|
+
if (this[active] === 0 && this[pending].length === 0 && !this[ended]) {
|
|
213
|
+
this[ended] = true;
|
|
214
|
+
this.push(null);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
149
217
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.push(null);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
218
|
+
[done]() {
|
|
219
|
+
this[active] -= 1;
|
|
220
|
+
this[next]();
|
|
157
221
|
}
|
|
158
222
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
223
|
+
// Node.js 8's default implementation ends the stream, which then emits an
|
|
224
|
+
// `end` event after the `error` one.
|
|
225
|
+
_destroy(error, callback) {
|
|
226
|
+
callback(error);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Stops reading, and does not end the stream.
|
|
230
|
+
[fail](error) {
|
|
231
|
+
// Until Node.js 14, destroying a destroyed stream emits the error again,
|
|
232
|
+
// after the consumer that destroyed it might have stopped listening.
|
|
233
|
+
if (this[failed] || this.destroyed) {
|
|
167
234
|
return;
|
|
168
235
|
}
|
|
236
|
+
this[failed] = true;
|
|
169
237
|
|
|
170
|
-
|
|
238
|
+
// `destroy` is only available from Node.js 8.
|
|
239
|
+
if (typeof this.destroy === 'function') {
|
|
240
|
+
this.destroy(error);
|
|
241
|
+
} else {
|
|
242
|
+
this.emit('error', error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
171
245
|
|
|
172
|
-
|
|
173
|
-
|
|
246
|
+
// Skips fixtures and hidden files. Like a directory listing, symbolic
|
|
247
|
+
// links are not followed.
|
|
248
|
+
[enqueue](filePath, file, name, isDirectory, isFile) {
|
|
249
|
+
if (isDirectory) {
|
|
250
|
+
this[pending].push({ path: filePath, file, isDirectory: true });
|
|
251
|
+
} else if (isFile && name[0] !== '.' && !fixturePattern.test(filePath)) {
|
|
252
|
+
this[pending].push({ path: filePath, file, isDirectory: false });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
174
255
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
256
|
+
[visit](item) {
|
|
257
|
+
if (item.isDirectory === undefined) {
|
|
258
|
+
fs.lstat(item.path, (error, stats) => {
|
|
259
|
+
if (error) {
|
|
260
|
+
this[fail](error);
|
|
261
|
+
} else {
|
|
262
|
+
this[enqueue](
|
|
263
|
+
item.path,
|
|
264
|
+
item.file,
|
|
265
|
+
path.basename(item.path),
|
|
266
|
+
stats.isDirectory(),
|
|
267
|
+
stats.isFile()
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
this[done]();
|
|
271
|
+
});
|
|
272
|
+
} else if (item.isDirectory) {
|
|
273
|
+
fs.readdir(item.path, { withFileTypes: true }, (error, entries) => {
|
|
274
|
+
if (error) {
|
|
275
|
+
this[fail](error);
|
|
276
|
+
} else {
|
|
277
|
+
// `path.join` would normalize the paths of every entry, which are
|
|
278
|
+
// already normalized.
|
|
279
|
+
const pathPrefix = item.path[item.path.length - 1] === path.sep ?
|
|
280
|
+
item.path : item.path + path.sep;
|
|
281
|
+
const filePrefix = item.file === '' ? '' : item.file + path.sep;
|
|
179
282
|
|
|
180
|
-
|
|
283
|
+
// Push in reverse so that reading the entries starts in order. The
|
|
284
|
+
// reads finish in any order, and so are the tests emitted.
|
|
285
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
286
|
+
const entry = entries[i];
|
|
181
287
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
288
|
+
// Before Node.js 10.10, `readdir` ignores `withFileTypes` and
|
|
289
|
+
// only returns names, so the entries are lstat'ed when visited.
|
|
290
|
+
if (typeof entry === 'string') {
|
|
291
|
+
this[pending].push({
|
|
292
|
+
path: pathPrefix + entry,
|
|
293
|
+
file: filePrefix + entry,
|
|
294
|
+
isDirectory: undefined
|
|
295
|
+
});
|
|
296
|
+
} else {
|
|
297
|
+
this[enqueue](
|
|
298
|
+
pathPrefix + entry.name,
|
|
299
|
+
filePrefix + entry.name,
|
|
300
|
+
entry.name,
|
|
301
|
+
entry.isDirectory(),
|
|
302
|
+
entry.isFile()
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
this[done]();
|
|
308
|
+
});
|
|
309
|
+
} else {
|
|
310
|
+
compile(item.path, item.file, this[compileOpts], (error, tests) => {
|
|
311
|
+
if (this[failed] || this.destroyed) {
|
|
312
|
+
return;
|
|
313
|
+
} else if (error) {
|
|
314
|
+
this[fail](error);
|
|
315
|
+
} else {
|
|
316
|
+
for (let i = 0; i < tests.length; i++) {
|
|
317
|
+
// The consumer may destroy the stream when it receives a test,
|
|
318
|
+
// and pushing to a destroyed stream still emits until Node.js 14.
|
|
319
|
+
if (this.destroyed) {
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
if (!this.push(tests[i])) {
|
|
323
|
+
this[wanted] = false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
this[done]();
|
|
328
|
+
});
|
|
329
|
+
}
|
|
186
330
|
}
|
|
187
331
|
};
|
package/lib/test-file.js
CHANGED
|
@@ -8,6 +8,19 @@ const yaml = require('js-yaml');
|
|
|
8
8
|
const yamlStart = '/*---';
|
|
9
9
|
const yamlEnd = '---*/';
|
|
10
10
|
|
|
11
|
+
// The copyright line. With the `m` flag, `^` matches at the start of every
|
|
12
|
+
// line, and `.` does not match line terminators, so this matches line by line
|
|
13
|
+
// without splitting the contents into lines.
|
|
14
|
+
// `(?:\/\/.*)*` backtracks exponentially on lines made of many slashes,
|
|
15
|
+
// and `.*` already matches any further `//`, so one optional group
|
|
16
|
+
// matches the same lines.
|
|
17
|
+
const copyrightPattern = /^(?:\/\/.*)? Copyright.*/mg;
|
|
18
|
+
|
|
19
|
+
// Line terminators: \n, \r, U+2028 and U+2029.
|
|
20
|
+
function isLineTerminator(code) {
|
|
21
|
+
return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
/**
|
|
12
25
|
* Extract copyright message
|
|
13
26
|
*
|
|
@@ -17,19 +30,29 @@ const yamlEnd = '---*/';
|
|
|
17
30
|
* @private
|
|
18
31
|
*/
|
|
19
32
|
function extractCopyright(test262File) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
// The very first line may be a hashbang, so look at
|
|
34
|
+
// all lines until reaching a line that looks close
|
|
35
|
+
// enough to copyright
|
|
36
|
+
const contents = test262File.contents;
|
|
37
|
+
|
|
38
|
+
// Only a line containing " Copyright" can match, so start matching at the
|
|
39
|
+
// first one, rather than trying every position of the contents before it,
|
|
40
|
+
// or of all of them when there is no copyright.
|
|
41
|
+
const index = contents.indexOf(' Copyright');
|
|
42
|
+
|
|
43
|
+
if (index === -1) {
|
|
44
|
+
return '';
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
|
|
47
|
+
let lineStart = index;
|
|
48
|
+
while (lineStart > 0 && !isLineTerminator(contents.charCodeAt(lineStart - 1))) {
|
|
49
|
+
lineStart -= 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
copyrightPattern.lastIndex = lineStart;
|
|
53
|
+
const result = copyrightPattern.exec(contents);
|
|
54
|
+
|
|
55
|
+
return result ? result[0] : '';
|
|
33
56
|
}
|
|
34
57
|
|
|
35
58
|
/**
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babel/test262-stream",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A Node.js API for traversing the Test262 test suite",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"test": "test"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"lint": "jshint lib test",
|
|
10
|
+
"lint": "jshint lib test benchmark",
|
|
11
11
|
"test": "npm run lint && npm run test-unit",
|
|
12
|
-
"test-unit": "
|
|
12
|
+
"test-unit": "node test/test.js",
|
|
13
|
+
"bench": "node --experimental-bench benchmark/index.js",
|
|
14
|
+
"test-coverage": "node --test --experimental-test-coverage --test-coverage-include='lib/**' --test-coverage-exclude='test/**' --test-coverage-lines=100 --test-coverage-branches=100 --test-coverage-functions=100 test/test.js",
|
|
15
|
+
"test-types": "tsc -p test/types"
|
|
13
16
|
},
|
|
14
17
|
"author": "",
|
|
15
18
|
"license": "BSD-3-Clause",
|
|
@@ -21,13 +24,19 @@
|
|
|
21
24
|
"access": "public"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
27
|
+
"@types/node": "^26.6.6",
|
|
24
28
|
"jshint": "^2.10.2",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"tape": "^4.8.0"
|
|
29
|
+
"tape": "^5.11.0",
|
|
30
|
+
"typescript": "^7.0.2"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"js-yaml": "^3.2.1"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
"js-yaml": "^3.2.1"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"lib",
|
|
37
|
+
"LICENSE-MICROSOFT.txt",
|
|
38
|
+
"LICENSE-BOCOUP.txt",
|
|
39
|
+
"LICENSE.txt"
|
|
40
|
+
],
|
|
41
|
+
"types": "lib/index.d.ts"
|
|
33
42
|
}
|
package/.jshintignore
DELETED
package/.jshintrc
DELETED
package/.travis.yml
DELETED
package/CONTRIBUTING.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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.
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
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);
|