@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
@@ -0,0 +1,27 @@
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.
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017, Bocoup LLC
1
+ Copyright (c) 2026, Babel contributors
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -66,6 +66,16 @@ stream.on('error', function(err) {
66
66
  });
67
67
  ```
68
68
 
69
+ The package includes TypeScript typings, in which the stream's tests are of
70
+ type `TestStream.Test`.
71
+
72
+ Tests are emitted in no specified order: files are read concurrently, so the
73
+ tests of different files, and of different `paths`, may be interleaved.
74
+
75
+ An error, such as a file that cannot be read or invalid frontmatter, ends the
76
+ stream: it emits an `error` event, and no further tests or `end` event.
77
+
69
78
  ## License
70
79
 
71
- Copyright 2017, Bocoup LLC under the 3-Clause BSD License (see `LICENSE.txt`)
80
+ Copyright 2026, Babel contributors, and 2017, Bocoup LLC, under the 3-Clause BSD
81
+ License (see `LICENSE.txt` and `LICENSE-BOCOUP.txt`)
package/lib/builder.js CHANGED
@@ -3,6 +3,30 @@ const fs = require('fs');
3
3
  const path = require('path');
4
4
  const TestFile = require('./test-file');
5
5
 
6
+ // Harness files are the same for every test, so a stream reads each of them
7
+ // once rather than once per test.
8
+ function readInclude(options, name) {
9
+ const cache = options.includesCache;
10
+ let contents = cache && cache.get(name);
11
+
12
+ if (contents === undefined) {
13
+ contents = fs.readFileSync(path.join(options.includesDir, name), 'utf-8');
14
+ if (cache) {
15
+ cache.set(name, contents);
16
+ }
17
+ }
18
+
19
+ return contents;
20
+ }
21
+
22
+ function concatIncludes(options, includes) {
23
+ let includeContents = '';
24
+ for (let i = 0; i < includes.length; i++) {
25
+ includeContents += readInclude(options, includes[i]) + '\n';
26
+ }
27
+ return includeContents;
28
+ }
29
+
6
30
  module.exports = function builder(file, contents, options) {
7
31
  options = options || {};
8
32
  if (!options.test262Dir && !options.includesDir) {
@@ -20,23 +44,34 @@ module.exports = function builder(file, contents, options) {
20
44
  return test;
21
45
  }
22
46
 
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');
47
+ // Prepend assert.js, sta.js, and (if needed) doneprintHandle.js,
48
+ // preserving their relative order. Building a new list is faster than
49
+ // prepending to the test's.
50
+ // https://github.com/tc39/test262/blob/main/INTERPRETING.md#includes
51
+ const includes = test.attrs.flags.async ?
52
+ ['assert.js', 'sta.js', 'doneprintHandle.js'] :
53
+ ['assert.js', 'sta.js'];
54
+ const testIncludes = test.attrs.includes;
55
+ for (let i = 0; i < testIncludes.length; i++) {
56
+ includes.push(testIncludes[i]);
32
57
  }
58
+ test.attrs.includes = includes;
33
59
 
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';
60
+ // Most tests only include the harness files that every test, or every
61
+ // async test, includes, so a stream concatenates these once. File names
62
+ // cannot contain "\0", so the keys do not clash with theirs.
63
+ const cache = options.includesCache;
64
+ let includeContents;
65
+
66
+ if (cache && testIncludes.length === 0) {
67
+ const key = test.attrs.flags.async ? '\0async' : '\0default';
68
+ includeContents = cache.get(key);
69
+ if (includeContents === undefined) {
70
+ includeContents = concatIncludes(options, includes);
71
+ cache.set(key, includeContents);
72
+ }
73
+ } else {
74
+ includeContents = concatIncludes(options, includes);
40
75
  }
41
76
 
42
77
  test.contents = includeContents + test.contents;
package/lib/compile.js CHANGED
@@ -1,24 +1,27 @@
1
1
  'use strict';
2
2
  const fs = require('fs');
3
- const path = require('path');
4
3
  const builder = require('./builder');
5
4
  const createScenarios = require('./create-scenarios');
6
5
 
7
- module.exports = function(filePath, options, done) {
6
+ // `file` is the path of the file relative to `options.test262Dir`.
7
+ module.exports = function(filePath, file, options, done) {
8
8
  fs.readFile(filePath, 'utf-8', (error, contents) => {
9
9
  if (error) {
10
10
  done(error);
11
11
  return;
12
12
  }
13
13
 
14
- done(null,
15
- createScenarios(
16
- builder(
17
- path.relative(options.test262Dir, filePath),
18
- contents,
19
- options
20
- )
21
- )
22
- );
14
+ let tests;
15
+
16
+ try {
17
+ tests = createScenarios(
18
+ builder(file, contents, options)
19
+ );
20
+ } catch (error) {
21
+ done(error);
22
+ return;
23
+ }
24
+
25
+ done(null, tests);
23
26
  });
24
27
  };
@@ -2,22 +2,53 @@
2
2
  const usd = '"use strict";\n';
3
3
  const usdLength = usd.length;
4
4
 
5
+ // Copies attributes, and their lists and mappings, such as `includes`,
6
+ // `features` and `negative`, so that changing those of one scenario does not
7
+ // change the other's.
8
+ function copyAttrs(attrs) {
9
+ const copy = Object.assign({}, attrs);
10
+ const keys = Object.keys(copy);
11
+
12
+ for (let i = 0; i < keys.length; i++) {
13
+ const value = copy[keys[i]];
14
+
15
+ if (Array.isArray(value)) {
16
+ copy[keys[i]] = value.slice();
17
+ } else if (typeof value === 'object' && value !== null) {
18
+ copy[keys[i]] = Object.assign({}, value);
19
+ }
20
+ }
21
+
22
+ return copy;
23
+ }
24
+
5
25
  module.exports = function scenariosForTest(test) {
6
26
  const scenarios = [];
7
27
 
8
- if (!test.attrs.flags.onlyStrict) {
28
+ if (test.attrs.flags.module) {
9
29
  test.scenario = 'default';
10
30
  scenarios.push(test);
11
- }
31
+ } else {
32
+ if (!test.attrs.flags.onlyStrict) {
33
+ test.scenario = 'default';
34
+ scenarios.push(test);
35
+ }
36
+
37
+ if (!test.attrs.flags.noStrict && !test.attrs.flags.raw) {
38
+ const attrs = copyAttrs(test.attrs);
39
+ attrs.description += ' (Strict Mode)';
12
40
 
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);
41
+ // The properties of a Test262File, in order. A literal is faster to
42
+ // create than a copy with Object.assign.
43
+ scenarios.push({
44
+ file: test.file,
45
+ contents: usd + test.contents,
46
+ attrs,
47
+ copyright: test.copyright,
48
+ scenario: 'strict mode',
49
+ insertionIndex: test.insertionIndex + usdLength
50
+ });
51
+ }
21
52
  }
22
53
 
23
54
  return scenarios;
package/lib/index.d.ts ADDED
@@ -0,0 +1,137 @@
1
+ import { Readable, ReadableOptions } from 'stream';
2
+
3
+ /**
4
+ * A Node.js readable stream that emits an object for every test in a Test262
5
+ * directory.
6
+ *
7
+ * Tests are emitted in no specified order: files are read concurrently, so
8
+ * the tests of different files, and of different `paths`, may be interleaved.
9
+ *
10
+ * An error, such as a file that cannot be read or invalid frontmatter, ends
11
+ * the stream: it emits an `error` event, and no further tests or `end` event.
12
+ */
13
+ declare class TestStream extends Readable {
14
+ /**
15
+ * @param test262Dir - path to a directory containing Test262
16
+ */
17
+ constructor(test262Dir: string, options?: TestStream.Options);
18
+
19
+ read(size?: number): TestStream.Test | null;
20
+
21
+ [Symbol.asyncIterator](): TestStream.TestIterator;
22
+
23
+ addListener(event: 'data', listener: (test: TestStream.Test) => void): this;
24
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
25
+ on(event: 'data', listener: (test: TestStream.Test) => void): this;
26
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
27
+ once(event: 'data', listener: (test: TestStream.Test) => void): this;
28
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
29
+ prependListener(event: 'data', listener: (test: TestStream.Test) => void): this;
30
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
31
+ prependOnceListener(event: 'data', listener: (test: TestStream.Test) => void): this;
32
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
33
+ }
34
+
35
+ declare namespace TestStream {
36
+ interface Options extends Omit<ReadableOptions, 'objectMode' | 'read'> {
37
+ /**
38
+ * Directory from which to load "includes" files; defaults to the
39
+ * `harness` directory of `test262Dir`.
40
+ */
41
+ includesDir?: string;
42
+ /**
43
+ * Files and directories, relative to `test262Dir`, to read tests from;
44
+ * defaults to `['test']`.
45
+ */
46
+ paths?: string[];
47
+ /**
48
+ * Whether to leave out the code that tests need to run, such as
49
+ * assert.js and the "includes" files; defaults to `false`.
50
+ */
51
+ omitRuntime?: boolean;
52
+ /**
53
+ * Version of Test262 to accept although this library does not support
54
+ * it. Use of this option may cause the stream to emit invalid tests.
55
+ */
56
+ acceptVersion?: string;
57
+ }
58
+
59
+ /**
60
+ * The iterator of the tests of a stream, which `for await` uses: the
61
+ * iterator of Readable streams, whose type depends on the version of
62
+ * @types/node, with its values typed as tests.
63
+ */
64
+ interface TestIterator extends Omit<
65
+ ReturnType<Readable[typeof Symbol.asyncIterator]>,
66
+ 'next' | 'return' | 'throw' | typeof Symbol.asyncIterator
67
+ > {
68
+ next(...args: [] | [unknown]): Promise<IteratorResult<Test, any>>;
69
+ return?(value?: any): Promise<IteratorResult<Test, any>>;
70
+ throw?(error?: any): Promise<IteratorResult<Test, any>>;
71
+ [Symbol.asyncIterator](): TestIterator;
72
+ }
73
+
74
+ interface Test {
75
+ /** Path of the test's file, relative to `test262Dir`. */
76
+ file: string;
77
+ /**
78
+ * Source text of the test, including the "includes" files and any
79
+ * scenario transformation, such as a "use strict" directive.
80
+ */
81
+ contents: string;
82
+ /** Metadata from the test's YAML frontmatter. */
83
+ attrs: Attrs;
84
+ /** Copyright line of the test, or `''` if it has none. */
85
+ copyright: string;
86
+ /** How the test's file was interpreted to create the test. */
87
+ scenario: 'default' | 'strict mode';
88
+ /**
89
+ * Offset in `contents` at which statements may be inserted without
90
+ * necessarily invalidating the test, or -1 for `raw` tests.
91
+ */
92
+ insertionIndex: number;
93
+ }
94
+
95
+ /**
96
+ * Metadata from a test's YAML frontmatter.
97
+ * https://github.com/tc39/test262/blob/main/INTERPRETING.md#metadata
98
+ */
99
+ interface Attrs {
100
+ description: string;
101
+ /** Harness files to include, including the default ones. */
102
+ includes: string[];
103
+ flags: Flags;
104
+ negative?: Negative;
105
+ features?: string[];
106
+ locale?: string | string[];
107
+ esid?: string;
108
+ es5id?: string | number;
109
+ es6id?: string | number;
110
+ info?: string;
111
+ author?: string;
112
+ [key: string]: unknown;
113
+ }
114
+
115
+ /**
116
+ * Flags of a test, each `true` if the test has it.
117
+ */
118
+ interface Flags {
119
+ onlyStrict?: true;
120
+ noStrict?: true;
121
+ module?: true;
122
+ raw?: true;
123
+ async?: true;
124
+ generated?: true;
125
+ CanBlockIsFalse?: true;
126
+ CanBlockIsTrue?: true;
127
+ [flag: string]: true | undefined;
128
+ }
129
+
130
+ interface Negative {
131
+ phase: 'parse' | 'resolution' | 'runtime';
132
+ /** Name of the error constructor, such as `SyntaxError`. */
133
+ type: string;
134
+ }
135
+ }
136
+
137
+ export = TestStream;