-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
173 lines (139 loc) · 4.62 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import assert from 'node:assert/strict'
import test from 'node:test'
import {cont, name, start} from 'estree-util-is-identifier-name'
test('isIdentifierName', async function (t) {
await t.test('core', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(
Object.keys(await import('estree-util-is-identifier-name')).sort(),
['cont', 'name', 'start']
)
})
})
await t.test('cont', async function (t) {
await t.test(
'should not say `undefined` is a cont code',
async function () {
assert.ok(!cont(''.codePointAt(0)))
}
)
await t.test('should say `a` is a cont code', async function () {
assert.ok(cont('a'.codePointAt(0)))
})
await t.test('should say `_` is a cont code', async function () {
assert.ok(cont('_'.codePointAt(0)))
})
await t.test('should say `1` is a cont code', async function () {
assert.ok(cont('1'.codePointAt(0)))
})
await t.test('should not say `-` is a cont code', async function () {
assert.ok(!cont('-'.codePointAt(0)))
})
await t.test('should say `ಠ` is a cont code', async function () {
assert.ok(cont('ಠ'.codePointAt(0)))
})
await t.test(
'should say `0xd8_00 0xde_a7` (together 0x1_02_a7) is a cont code',
async function () {
assert.ok(cont(0x1_02_a7))
}
)
await t.test('should not say `0xd8_00` is a cont code', async function () {
assert.ok(!cont(0xd8_00))
})
await t.test(
'should not say `-` is a cont code normally',
async function () {
assert.ok(!cont('-'.codePointAt(0)))
}
)
await t.test(
'should say `-` is a cont code w/ `jsx: true`',
async function () {
assert.ok(cont('-'.codePointAt(0), {jsx: true}))
}
)
})
await t.test('name', async function (t) {
await t.test(
'should not say `` (empty string) is a name',
async function () {
assert.ok(!name(''))
}
)
await t.test('should say `a` is a name', async function () {
assert.ok(name('a'))
})
await t.test('should say `_` is a name', async function () {
assert.ok(name('_'))
})
await t.test('should not say `1` is a name', async function () {
assert.ok(!name('1'))
})
await t.test('should not say `-` is a name', async function () {
assert.ok(!name('-'))
})
await t.test('should say `a1` is a name', async function () {
assert.ok(name('a1'))
})
await t.test('should not say `a-b` is a name', async function () {
assert.ok(!name('a-b'))
})
await t.test('should say `_a$b9` is a name', async function () {
assert.ok(name('_a$b9'))
})
await t.test('should not say `aaa-` is a name', async function () {
assert.ok(!name('aaa-'))
})
await t.test('should not say `-aaa` is a name', async function () {
assert.ok(!name('-aaa'))
})
await t.test('should say `ಠ_ಠ` is a name', async function () {
assert.ok(name('ಠ_ಠ'))
})
await t.test('should say `𐊧` (0x1_02_a7) is a name', async function () {
assert.ok(name('𐊧'))
})
await t.test('should not say `a-b` is a name normally', async function () {
assert.ok(!name('a-b'))
})
await t.test('should say `a-b` is a jsx name', async function () {
assert.ok(name('a-b', {jsx: true}))
})
await t.test('should say `a-` is a jsx name', async function () {
assert.ok(name('a-', {jsx: true}))
})
})
await t.test('start', async function (t) {
await t.test(
'should not say `undefined` is a start code',
async function () {
assert.ok(!start(''.codePointAt(0)))
}
)
await t.test('should say `a` is a start code', async function () {
assert.ok(start('a'.codePointAt(0)))
})
await t.test('should say `_` is a start code', async function () {
assert.ok(start('_'.codePointAt(0)))
})
await t.test('should not say `1` is a start code', async function () {
assert.ok(!start('1'.codePointAt(0)))
})
await t.test('should not say `-` is a start code', async function () {
assert.ok(!start('-'.codePointAt(0)))
})
await t.test('should say `ಠ` is a start code', async function () {
assert.ok(start('ಠ'.codePointAt(0)))
})
await t.test(
'should say `0xd8_00 0xde_a7` (together 0x1_02_a7) is a start code',
async function () {
assert.ok(start(0x1_02_a7))
}
)
await t.test('should not say `0xd8_00` is a start code', async function () {
assert.ok(!start(0xd8_00))
})
})
})