Skip to content

Commit ac8e903

Browse files
committed
ゼロ省略と指数表記の組み合わせのテスト
1 parent 259b4bd commit ac8e903

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

test/literals.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,48 @@ describe('literal', () => {
9999
eq(res, NUM(5));
100100
});
101101

102+
test.concurrent('number (integer zero omitted, positive exponent without plus sign)', async () => {
103+
const res = await exe(`
104+
<: .5e3
105+
`);
106+
eq(res, NUM(500));
107+
});
108+
109+
test.concurrent('number (integer zero omitted, positive exponent with plus sign)', async () => {
110+
const res = await exe(`
111+
<: .5e+3
112+
`);
113+
eq(res, NUM(500));
114+
});
115+
116+
test.concurrent('number (integer zero omitted, negative exponent)', async () => {
117+
const res = await exe(`
118+
<: .5e-3
119+
`);
120+
eq(res, NUM(0.0005));
121+
});
122+
123+
test.concurrent('number (decimal zero omitted, positive exponent without plus sign)', async () => {
124+
const res = await exe(`
125+
<: 5.e3
126+
`);
127+
eq(res, NUM(5000));
128+
});
129+
130+
test.concurrent('number (decimal zero omitted, positive exponent with plus sign)', async () => {
131+
const res = await exe(`
132+
<: 5.e+3
133+
`);
134+
eq(res, NUM(5000));
135+
});
136+
137+
test.concurrent('number (decimal zero omitted, negative exponent)', async () => {
138+
const res = await exe(`
139+
<: 5.e-3
140+
`);
141+
eq(res, NUM(0.005));
142+
});
143+
102144
test.concurrent('arr (separated by comma)', async () => {
103145
const res = await exe(`
104146
<: [1, 2, 3]

0 commit comments

Comments
 (0)