Skip to content

Commit 0511bed

Browse files
committed
Added more carefully scoped feature checking in the test.
1 parent 97106e6 commit 0511bed

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

docs/v2/test.html

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25716,22 +25716,32 @@ <h1>CoffeeScript Test Suite</h1>
2571625716
<script type="text/x-coffeescript" class="test" id="import_assertions">
2571725717
# This file is running in CommonJS (in Node) or as a classic Script (in the browser tests) so it can use import() within an async function, but not at the top level; and we can’t use static import.
2571825718
test "dynamic import assertion", ->
25719-
if typeof process is "undefined" or process.version?.startsWith("v17")
25719+
try
2572025720
{ default: secret } = await import('data:application/json,{"ofLife":42}', { assert: { type: 'json' } })
2572125721
eq secret.ofLife, 42
25722+
catch e
25723+
# This parses on Node 16.14.x but throws an error async so the `skipUnless` feature detection won't catch it
25724+
# rethrow any other erorr
25725+
unless e.message is 'Invalid module "data:application/json,{"ofLife":42}" has an unsupported MIME type "application/json"'
25726+
throw e
2572225727

2572325728
test "assert keyword", ->
25724-
if typeof process is "undefined" or process.version?.startsWith("v17")
25725-
assert = 1
25729+
assert = 1
2572625730

25731+
try
2572725732
{ default: assert } = await import('data:application/json,{"thatIAm":42}', { assert: { type: 'json' } })
2572825733
eq assert.thatIAm, 42
25734+
catch e
25735+
# This parses on Node 16.14.x but throws an error async so the `skipUnless` feature detection won't catch it
25736+
# rethrow any other erorr
25737+
unless e.message is 'Invalid module "data:application/json,{"thatIAm":42}" has an unsupported MIME type "application/json"'
25738+
throw e
2572925739

25730-
eqJS """
25731-
import assert from 'regression-test'
25732-
""", """
25733-
import assert from 'regression-test';
25734-
"""
25740+
eqJS """
25741+
import assert from 'regression-test'
25742+
""", """
25743+
import assert from 'regression-test';
25744+
"""
2573525745

2573625746
test "static import assertion", ->
2573725747
eqJS """

test/import_assertions.coffee

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
# This file is running in CommonJS (in Node) or as a classic Script (in the browser tests) so it can use import() within an async function, but not at the top level; and we can’t use static import.
22
test "dynamic import assertion", ->
3-
if typeof process is "undefined" or process.version?.startsWith("v17")
3+
try
44
{ default: secret } = await import('data:application/json,{"ofLife":42}', { assert: { type: 'json' } })
55
eq secret.ofLife, 42
6+
catch e
7+
# This parses on Node 16.14.x but throws an error async so the `skipUnless` feature detection won't catch it
8+
# rethrow any other erorr
9+
unless e.message is 'Invalid module "data:application/json,{"ofLife":42}" has an unsupported MIME type "application/json"'
10+
throw e
611

712
test "assert keyword", ->
8-
if typeof process is "undefined" or process.version?.startsWith("v17")
9-
assert = 1
13+
assert = 1
1014

15+
try
1116
{ default: assert } = await import('data:application/json,{"thatIAm":42}', { assert: { type: 'json' } })
1217
eq assert.thatIAm, 42
18+
catch e
19+
# This parses on Node 16.14.x but throws an error async so the `skipUnless` feature detection won't catch it
20+
# rethrow any other erorr
21+
unless e.message is 'Invalid module "data:application/json,{"thatIAm":42}" has an unsupported MIME type "application/json"'
22+
throw e
1323

14-
eqJS """
15-
import assert from 'regression-test'
16-
""", """
17-
import assert from 'regression-test';
18-
"""
24+
eqJS """
25+
import assert from 'regression-test'
26+
""", """
27+
import assert from 'regression-test';
28+
"""
1929

2030
test "static import assertion", ->
2131
eqJS """

0 commit comments

Comments
 (0)