@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.
Files changed (235) hide show
  1. package/LICENSE-BOCOUP.txt +27 -0
  2. package/LICENSE.txt +1 -1
  3. package/README.md +11 -1
  4. package/lib/builder.js +50 -15
  5. package/lib/compile.js +14 -11
  6. package/lib/create-scenarios.js +41 -10
  7. package/lib/index.d.ts +137 -0
  8. package/lib/index.js +202 -58
  9. package/lib/test-file.js +34 -11
  10. package/package.json +18 -9
  11. package/.jshintignore +0 -2
  12. package/.jshintrc +0 -6
  13. package/.travis.yml +0 -5
  14. package/CONTRIBUTING.md +0 -37
  15. package/test/collateral/invalid-missing-harness/fake-test262/test/a-test-file.js +0 -16
  16. package/test/collateral/invalid-version-other-accepted/fake-test262/harness/assert.js +0 -17
  17. package/test/collateral/invalid-version-other-accepted/fake-test262/harness/doneprintHandle.js +0 -6
  18. package/test/collateral/invalid-version-other-accepted/fake-test262/harness/sta.js +0 -12
  19. package/test/collateral/invalid-version-other-accepted/fake-test262/package.json +0 -3
  20. package/test/collateral/invalid-version-other-accepted/fake-test262/test/strict.js +0 -9
  21. package/test/collateral/invalid-version-unsupported/fake-test262/harness/assert.js +0 -17
  22. package/test/collateral/invalid-version-unsupported/fake-test262/harness/doneprintHandle.js +0 -6
  23. package/test/collateral/invalid-version-unsupported/fake-test262/harness/sta.js +0 -12
  24. package/test/collateral/invalid-version-unsupported/fake-test262/package.json +0 -3
  25. package/test/collateral/invalid-version-unsupported/fake-test262/test/strict.js +0 -9
  26. package/test/collateral/valid-default/expected-content/test/asyncNegative_default.js +0 -49
  27. package/test/collateral/valid-default/expected-content/test/asyncNegative_strict_mode.js +0 -50
  28. package/test/collateral/valid-default/expected-content/test/async_default.js +0 -48
  29. package/test/collateral/valid-default/expected-content/test/async_strict_mode.js +0 -49
  30. package/test/collateral/valid-default/expected-content/test/bothStrict_default.js +0 -46
  31. package/test/collateral/valid-default/expected-content/test/bothStrict_strict_mode.js +0 -47
  32. package/test/collateral/valid-default/expected-content/test/error_default.js +0 -39
  33. package/test/collateral/valid-default/expected-content/test/error_strict_mode.js +0 -40
  34. package/test/collateral/valid-default/expected-content/test/module_default.js +0 -37
  35. package/test/collateral/valid-default/expected-content/test/module_strict_mode.js +0 -38
  36. package/test/collateral/valid-default/expected-content/test/negative-empty_default.js +0 -37
  37. package/test/collateral/valid-default/expected-content/test/negative-empty_strict_mode.js +0 -38
  38. package/test/collateral/valid-default/expected-content/test/noStrict_default.js +0 -36
  39. package/test/collateral/valid-default/expected-content/test/rawNoStrict_default.js +0 -14
  40. package/test/collateral/valid-default/expected-content/test/rawStrict_default.js +0 -15
  41. package/test/collateral/valid-default/expected-content/test/strict_strict_mode.js +0 -41
  42. package/test/collateral/valid-default/expected-metadata/test/asyncNegative_default.json +0 -22
  43. package/test/collateral/valid-default/expected-metadata/test/asyncNegative_strict_mode.json +0 -22
  44. package/test/collateral/valid-default/expected-metadata/test/async_default.json +0 -18
  45. package/test/collateral/valid-default/expected-metadata/test/async_strict_mode.json +0 -18
  46. package/test/collateral/valid-default/expected-metadata/test/bothStrict_default.json +0 -24
  47. package/test/collateral/valid-default/expected-metadata/test/bothStrict_strict_mode.json +0 -24
  48. package/test/collateral/valid-default/expected-metadata/test/error_default.json +0 -19
  49. package/test/collateral/valid-default/expected-metadata/test/error_strict_mode.json +0 -19
  50. package/test/collateral/valid-default/expected-metadata/test/module_default.json +0 -17
  51. package/test/collateral/valid-default/expected-metadata/test/module_strict_mode.json +0 -17
  52. package/test/collateral/valid-default/expected-metadata/test/negative-empty_default.json +0 -19
  53. package/test/collateral/valid-default/expected-metadata/test/negative-empty_strict_mode.json +0 -19
  54. package/test/collateral/valid-default/expected-metadata/test/noStrict_default.json +0 -17
  55. package/test/collateral/valid-default/expected-metadata/test/rawNoStrict_default.json +0 -14
  56. package/test/collateral/valid-default/expected-metadata/test/rawStrict_default.json +0 -14
  57. package/test/collateral/valid-default/expected-metadata/test/strict_strict_mode.json +0 -21
  58. package/test/collateral/valid-default/fake-test262/harness/assert.js +0 -17
  59. package/test/collateral/valid-default/fake-test262/harness/doneprintHandle.js +0 -6
  60. package/test/collateral/valid-default/fake-test262/harness/sta.js +0 -12
  61. package/test/collateral/valid-default/fake-test262/test/async.js +0 -10
  62. package/test/collateral/valid-default/fake-test262/test/asyncNegative.js +0 -11
  63. package/test/collateral/valid-default/fake-test262/test/bothStrict.js +0 -15
  64. package/test/collateral/valid-default/fake-test262/test/error.js +0 -8
  65. package/test/collateral/valid-default/fake-test262/test/module.js +0 -6
  66. package/test/collateral/valid-default/fake-test262/test/module_FIXTURE.js +0 -2
  67. package/test/collateral/valid-default/fake-test262/test/negative-empty.js +0 -6
  68. package/test/collateral/valid-default/fake-test262/test/noStrict.js +0 -5
  69. package/test/collateral/valid-default/fake-test262/test/rawNoStrict.js +0 -14
  70. package/test/collateral/valid-default/fake-test262/test/rawStrict.js +0 -15
  71. package/test/collateral/valid-default/fake-test262/test/strict.js +0 -9
  72. package/test/collateral/valid-extra-files/expected-content/test/bothStrict_default.js +0 -46
  73. package/test/collateral/valid-extra-files/expected-content/test/bothStrict_strict_mode.js +0 -47
  74. package/test/collateral/valid-extra-files/expected-metadata/test/bothStrict_default.json +0 -24
  75. package/test/collateral/valid-extra-files/expected-metadata/test/bothStrict_strict_mode.json +0 -24
  76. package/test/collateral/valid-extra-files/fake-test262/harness/assert.js +0 -17
  77. package/test/collateral/valid-extra-files/fake-test262/harness/doneprintHandle.js +0 -6
  78. package/test/collateral/valid-extra-files/fake-test262/harness/sta.js +0 -12
  79. package/test/collateral/valid-extra-files/fake-test262/test/bothStrict.js +0 -15
  80. package/test/collateral/valid-extra-files/fake-test262/test/zzz-0_FIXTURE.js +0 -2
  81. package/test/collateral/valid-extra-files/fake-test262/test/zzz-1_FIXTURE.js +0 -2
  82. package/test/collateral/valid-extra-files/fake-test262/test/zzz-2_FIXTURE.js +0 -2
  83. package/test/collateral/valid-extra-files/fake-test262/test/zzz-3_FIXTURE.js +0 -2
  84. package/test/collateral/valid-extra-files/fake-test262/test/zzz-4_FIXTURE.js +0 -2
  85. package/test/collateral/valid-extra-files/fake-test262/test/zzz-5_FIXTURE.js +0 -2
  86. package/test/collateral/valid-extra-files/fake-test262/test/zzz-6_FIXTURE.js +0 -2
  87. package/test/collateral/valid-extra-files/fake-test262/test/zzz-7_FIXTURE.js +0 -2
  88. package/test/collateral/valid-extra-files/fake-test262/test/zzz-8_FIXTURE.js +0 -2
  89. package/test/collateral/valid-extra-files/fake-test262/test/zzz-9_FIXTURE.txt +0 -2
  90. package/test/collateral/valid-insertionindex-with-copyright/expected-content/test/raw_default.js +0 -15
  91. package/test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_default.js +0 -38
  92. package/test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_strict_mode.js +0 -39
  93. package/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/raw_default.json +0 -14
  94. package/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_default.json +0 -15
  95. package/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_strict_mode.json +0 -15
  96. package/test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/assert.js +0 -17
  97. package/test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/sta.js +0 -12
  98. package/test/collateral/valid-insertionindex-with-copyright/fake-test262/test/raw.js +0 -15
  99. package/test/collateral/valid-insertionindex-with-copyright/fake-test262/test/runtime.js +0 -7
  100. package/test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_default.js +0 -11
  101. package/test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_strict_mode.js +0 -12
  102. package/test/collateral/valid-omit-runtime/expected-content/test/async_default.js +0 -10
  103. package/test/collateral/valid-omit-runtime/expected-content/test/async_strict_mode.js +0 -11
  104. package/test/collateral/valid-omit-runtime/expected-content/test/bothStrict_default.js +0 -15
  105. package/test/collateral/valid-omit-runtime/expected-content/test/bothStrict_strict_mode.js +0 -16
  106. package/test/collateral/valid-omit-runtime/expected-content/test/error_default.js +0 -8
  107. package/test/collateral/valid-omit-runtime/expected-content/test/error_strict_mode.js +0 -9
  108. package/test/collateral/valid-omit-runtime/expected-content/test/module_default.js +0 -6
  109. package/test/collateral/valid-omit-runtime/expected-content/test/module_strict_mode.js +0 -7
  110. package/test/collateral/valid-omit-runtime/expected-content/test/negative-empty_default.js +0 -6
  111. package/test/collateral/valid-omit-runtime/expected-content/test/negative-empty_strict_mode.js +0 -7
  112. package/test/collateral/valid-omit-runtime/expected-content/test/noStrict_default.js +0 -5
  113. package/test/collateral/valid-omit-runtime/expected-content/test/rawNoStrict_default.js +0 -14
  114. package/test/collateral/valid-omit-runtime/expected-content/test/rawStrict_default.js +0 -15
  115. package/test/collateral/valid-omit-runtime/expected-content/test/strict_strict_mode.js +0 -10
  116. package/test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_default.json +0 -18
  117. package/test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_strict_mode.json +0 -18
  118. package/test/collateral/valid-omit-runtime/expected-metadata/test/async_default.json +0 -14
  119. package/test/collateral/valid-omit-runtime/expected-metadata/test/async_strict_mode.json +0 -14
  120. package/test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_default.json +0 -21
  121. package/test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_strict_mode.json +0 -21
  122. package/test/collateral/valid-omit-runtime/expected-metadata/test/error_default.json +0 -16
  123. package/test/collateral/valid-omit-runtime/expected-metadata/test/error_strict_mode.json +0 -16
  124. package/test/collateral/valid-omit-runtime/expected-metadata/test/module_default.json +0 -14
  125. package/test/collateral/valid-omit-runtime/expected-metadata/test/module_strict_mode.json +0 -14
  126. package/test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_default.json +0 -16
  127. package/test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_strict_mode.json +0 -16
  128. package/test/collateral/valid-omit-runtime/expected-metadata/test/noStrict_default.json +0 -14
  129. package/test/collateral/valid-omit-runtime/expected-metadata/test/rawNoStrict_default.json +0 -14
  130. package/test/collateral/valid-omit-runtime/expected-metadata/test/rawStrict_default.json +0 -14
  131. package/test/collateral/valid-omit-runtime/expected-metadata/test/strict_strict_mode.json +0 -18
  132. package/test/collateral/valid-omit-runtime/fake-test262/harness/assert.js +0 -17
  133. package/test/collateral/valid-omit-runtime/fake-test262/harness/doneprintHandle.js +0 -6
  134. package/test/collateral/valid-omit-runtime/fake-test262/harness/sta.js +0 -12
  135. package/test/collateral/valid-omit-runtime/fake-test262/test/async.js +0 -10
  136. package/test/collateral/valid-omit-runtime/fake-test262/test/asyncNegative.js +0 -11
  137. package/test/collateral/valid-omit-runtime/fake-test262/test/bothStrict.js +0 -15
  138. package/test/collateral/valid-omit-runtime/fake-test262/test/error.js +0 -8
  139. package/test/collateral/valid-omit-runtime/fake-test262/test/module.js +0 -6
  140. package/test/collateral/valid-omit-runtime/fake-test262/test/module_FIXTURE.js +0 -2
  141. package/test/collateral/valid-omit-runtime/fake-test262/test/negative-empty.js +0 -6
  142. package/test/collateral/valid-omit-runtime/fake-test262/test/noStrict.js +0 -5
  143. package/test/collateral/valid-omit-runtime/fake-test262/test/rawNoStrict.js +0 -14
  144. package/test/collateral/valid-omit-runtime/fake-test262/test/rawStrict.js +0 -15
  145. package/test/collateral/valid-omit-runtime/fake-test262/test/strict.js +0 -9
  146. package/test/collateral/valid-version-ignored/expected-content/test/strict_strict_mode.js +0 -41
  147. package/test/collateral/valid-version-ignored/expected-metadata/test/strict_strict_mode.json +0 -21
  148. package/test/collateral/valid-version-ignored/fake-test262/harness/assert.js +0 -17
  149. package/test/collateral/valid-version-ignored/fake-test262/harness/doneprintHandle.js +0 -6
  150. package/test/collateral/valid-version-ignored/fake-test262/harness/sta.js +0 -12
  151. package/test/collateral/valid-version-ignored/fake-test262/package.json +0 -3
  152. package/test/collateral/valid-version-ignored/fake-test262/test/strict.js +0 -9
  153. package/test/collateral/valid-version-supported/expected-content/test/strict_strict_mode.js +0 -41
  154. package/test/collateral/valid-version-supported/expected-metadata/test/strict_strict_mode.json +0 -21
  155. package/test/collateral/valid-version-supported/fake-test262/harness/assert.js +0 -17
  156. package/test/collateral/valid-version-supported/fake-test262/harness/doneprintHandle.js +0 -6
  157. package/test/collateral/valid-version-supported/fake-test262/harness/sta.js +0 -12
  158. package/test/collateral/valid-version-supported/fake-test262/package.json +0 -3
  159. package/test/collateral/valid-version-supported/fake-test262/test/strict.js +0 -9
  160. package/test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_default.js +0 -44
  161. package/test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_strict_mode.js +0 -45
  162. package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-and-license-on-same-line_default.js +0 -20
  163. package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-multiline-block_default.js +0 -18
  164. package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls_default.js +0 -17
  165. package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-and-license-on-same-line_default.js +0 -20
  166. package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-multiline-block_default.js +0 -18
  167. package/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps_default.js +0 -17
  168. package/test/collateral/valid-with-hashbang/expected-content/test/rawWithLicense_default.js +0 -21
  169. package/test/collateral/valid-with-hashbang/expected-content/test/raw_default.js +0 -17
  170. package/test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_default.json +0 -22
  171. package/test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_strict_mode.json +0 -22
  172. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-and-license-on-same-line_default.json +0 -21
  173. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-multiline-block_default.json +0 -21
  174. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls_default.json +0 -21
  175. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-and-license-on-same-line_default.json +0 -21
  176. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-multiline-block_default.json +0 -21
  177. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps_default.json +0 -21
  178. package/test/collateral/valid-with-hashbang/expected-metadata/test/rawWithLicense_default.json +0 -21
  179. package/test/collateral/valid-with-hashbang/expected-metadata/test/raw_default.json +0 -21
  180. package/test/collateral/valid-with-hashbang/fake-test262/harness/assert.js +0 -17
  181. package/test/collateral/valid-with-hashbang/fake-test262/harness/doneprintHandle.js +0 -6
  182. package/test/collateral/valid-with-hashbang/fake-test262/harness/sta.js +0 -12
  183. package/test/collateral/valid-with-hashbang/fake-test262/test/missing-raw-flag.js +0 -13
  184. package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-and-license-on-same-line.js +0 -20
  185. package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-multiline-block.js +0 -18
  186. package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls.js +0 -17
  187. package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-and-license-on-same-line.js +0 -20
  188. package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-multiline-block.js +0 -18
  189. package/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps.js +0 -17
  190. package/test/collateral/valid-with-hashbang/fake-test262/test/raw.js +0 -17
  191. package/test/collateral/valid-with-hashbang/fake-test262/test/rawWithLicense.js +0 -21
  192. package/test/collateral/valid-with-includes/custom-includes/assert.js +0 -17
  193. package/test/collateral/valid-with-includes/custom-includes/doneprintHandle.js +0 -9
  194. package/test/collateral/valid-with-includes/custom-includes/sta.js +0 -13
  195. package/test/collateral/valid-with-includes/expected-content/test/async_default.js +0 -52
  196. package/test/collateral/valid-with-includes/expected-content/test/async_strict_mode.js +0 -53
  197. package/test/collateral/valid-with-includes/expected-content/test/bothStrict_default.js +0 -47
  198. package/test/collateral/valid-with-includes/expected-content/test/bothStrict_strict_mode.js +0 -48
  199. package/test/collateral/valid-with-includes/expected-metadata/test/async_default.json +0 -18
  200. package/test/collateral/valid-with-includes/expected-metadata/test/async_strict_mode.json +0 -18
  201. package/test/collateral/valid-with-includes/expected-metadata/test/bothStrict_default.json +0 -24
  202. package/test/collateral/valid-with-includes/expected-metadata/test/bothStrict_strict_mode.json +0 -24
  203. package/test/collateral/valid-with-includes/fake-test262/harness/assert.js +0 -17
  204. package/test/collateral/valid-with-includes/fake-test262/harness/doneprintHandle.js +0 -6
  205. package/test/collateral/valid-with-includes/fake-test262/test/async.js +0 -10
  206. package/test/collateral/valid-with-includes/fake-test262/test/bothStrict.js +0 -15
  207. package/test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_default.js +0 -49
  208. package/test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_strict_mode.js +0 -50
  209. package/test/collateral/valid-with-paths/expected-content/test/async/async_default.js +0 -48
  210. package/test/collateral/valid-with-paths/expected-content/test/async/async_strict_mode.js +0 -49
  211. package/test/collateral/valid-with-paths/expected-content/test/bothStrict_default.js +0 -46
  212. package/test/collateral/valid-with-paths/expected-content/test/bothStrict_strict_mode.js +0 -47
  213. package/test/collateral/valid-with-paths/expected-content/test/strict/no/noStrict_default.js +0 -36
  214. package/test/collateral/valid-with-paths/expected-content/test/strict/no/rawNoStrict_default.js +0 -14
  215. package/test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_default.json +0 -22
  216. package/test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_strict_mode.json +0 -22
  217. package/test/collateral/valid-with-paths/expected-metadata/test/async/async_default.json +0 -18
  218. package/test/collateral/valid-with-paths/expected-metadata/test/async/async_strict_mode.json +0 -18
  219. package/test/collateral/valid-with-paths/expected-metadata/test/bothStrict_default.json +0 -24
  220. package/test/collateral/valid-with-paths/expected-metadata/test/bothStrict_strict_mode.json +0 -24
  221. package/test/collateral/valid-with-paths/expected-metadata/test/strict/no/noStrict_default.json +0 -17
  222. package/test/collateral/valid-with-paths/expected-metadata/test/strict/no/rawNoStrict_default.json +0 -14
  223. package/test/collateral/valid-with-paths/fake-test262/harness/assert.js +0 -17
  224. package/test/collateral/valid-with-paths/fake-test262/harness/doneprintHandle.js +0 -6
  225. package/test/collateral/valid-with-paths/fake-test262/harness/sta.js +0 -12
  226. package/test/collateral/valid-with-paths/fake-test262/test/async/async.js +0 -10
  227. package/test/collateral/valid-with-paths/fake-test262/test/async/asyncNegative.js +0 -11
  228. package/test/collateral/valid-with-paths/fake-test262/test/bothStrict.js +0 -15
  229. package/test/collateral/valid-with-paths/fake-test262/test/error.js +0 -8
  230. package/test/collateral/valid-with-paths/fake-test262/test/negative-empty.js +0 -6
  231. package/test/collateral/valid-with-paths/fake-test262/test/strict/no/noStrict.js +0 -5
  232. package/test/collateral/valid-with-paths/fake-test262/test/strict/no/rawNoStrict.js +0 -14
  233. package/test/collateral/valid-with-paths/fake-test262/test/strict/rawStrict.js +0 -15
  234. package/test/collateral/valid-with-paths/fake-test262/test/strict/strict.js +0 -9
  235. 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 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');
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
- if (this[fileStream]) {
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.traverse();
166
+ this[next]();
109
167
  return;
110
168
  }
111
169
 
112
- this.emit('error', error);
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.emit('error', error);
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.emit(
129
- 'error', new Error(`Unsupported version of Test262: '${version}'`)
186
+ this[fail](
187
+ new Error(`Unsupported version of Test262: '${version}'`)
130
188
  );
131
189
  return;
132
190
  }
133
191
 
134
- this.traverse();
192
+ this[next]();
135
193
  });
136
194
  }
137
195
 
138
- traverse() {
139
- this[fileStream] = klaw(this[paths].shift());
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
- this[fileStream].on('data', (item) => this[onFile](item));
142
- this[fileStream].on('error', (error) => this.emit('error', error));
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[fileStream].on('end', () => {
145
- if (this[paths].length) {
146
- this.traverse();
147
- } else {
148
- this[fileStreamDone] = true;
212
+ if (this[active] === 0 && this[pending].length === 0 && !this[ended]) {
213
+ this[ended] = true;
214
+ this.push(null);
215
+ }
216
+ }
149
217
 
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
- });
218
+ [done]() {
219
+ this[active] -= 1;
220
+ this[next]();
157
221
  }
158
222
 
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)) {
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
- this[pendingOps] += 1;
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
- compile(item.path, this[compileOpts], (err, tests) => {
173
- this[pendingOps] -= 1;
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
- if (err) {
176
- this.emit('error', err);
177
- return;
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
- tests.forEach((test) => this.push(test));
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
- if (this[pendingOps] === 0 && this[fileStreamDone]) {
183
- this.push(null);
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
- 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
- }
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
- return '';
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": "1.4.0",
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": "tape test/test.js"
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
- "mkdirp": "^0.5.1",
26
- "rimraf": "^2.6.2",
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
- "klaw": "^2.1.0"
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
@@ -1,2 +0,0 @@
1
- /test/collateral/
2
- /lib/compilerdeps.js
package/.jshintrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "esversion": 6,
3
- "node": true,
4
- "undef": true,
5
- "unused": true
6
- }
package/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- language: node_js
3
- node_js:
4
- - 6
5
- - 8
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,17 +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";
@@ -1,6 +0,0 @@
1
- function $DONE(){
2
- if(!arguments[0])
3
- print('Test262:AsyncTestComplete');
4
- else
5
- print('Error: ' + arguments[0]);
6
- }
@@ -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,9 +0,0 @@
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');
@@ -1,17 +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";
@@ -1,6 +0,0 @@
1
- function $DONE(){
2
- if(!arguments[0])
3
- print('Test262:AsyncTestComplete');
4
- else
5
- print('Error: ' + arguments[0]);
6
- }
@@ -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,3 +0,0 @@
1
- {
2
- "version": "6.0.0"
3
- }
@@ -1,9 +0,0 @@
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');
@@ -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);