Skip to content

Commit 3334f58

Browse files
committed
Add tests for new features.
1 parent 4875303 commit 3334f58

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/index.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,45 @@ test('allows top level return by default', function (t) {
4343
})
4444
t.end()
4545
})
46+
47+
test('supports async generators', function (t) {
48+
t.doesNotThrow(function () {
49+
acorn.parse('async function* a () { await x; yield 1 }')
50+
})
51+
t.end()
52+
})
53+
54+
test('supports async iteration', function (t) {
55+
t.doesNotThrow(function () {
56+
acorn.parse('async function l (y) { for await (const x of y) {} }')
57+
})
58+
t.end()
59+
})
60+
61+
test('supports optional catch', function (t) {
62+
t.doesNotThrow(function () {
63+
acorn.parse('try { throw null } catch {}')
64+
})
65+
t.end()
66+
})
67+
68+
test('supports bigint', function (t) {
69+
t.doesNotThrow(function () {
70+
acorn.parse('50n ** 50n')
71+
})
72+
t.end()
73+
})
74+
75+
test('supports import.meta with sourceType: module', function (t) {
76+
t.doesNotThrow(function () {
77+
acorn.parse('console.log(import.meta.url)', { sourceType: 'module' })
78+
})
79+
t.end()
80+
})
81+
82+
test('supports dynamic import() with sourceType: module', function (t) {
83+
t.doesNotThrow(function () {
84+
acorn.parse('import("./whatever.mjs")', { sourceType: 'module' })
85+
})
86+
t.end()
87+
})

0 commit comments

Comments
 (0)