Skip to content

Commit 7aae05f

Browse files
committed
updates
1 parent a8637d8 commit 7aae05f

15 files changed

Lines changed: 200 additions & 184 deletions

File tree

test/parsebox/runtime/array.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Runtime } from '@sinclair/parsebox'
2+
import { Assert } from 'test'
3+
4+
const Test = Assert.Context('Runtime.Parse.Array')
5+
6+
Test('Array', () => {
7+
Assert.IsEqual(Runtime.Parse(Runtime.Array(Runtime.Const('A')), ''), [[], ''])
8+
Assert.IsEqual(Runtime.Parse(Runtime.Array(Runtime.Const('A')), 'AB'), [['A'], 'B'])
9+
Assert.IsEqual(Runtime.Parse(Runtime.Array(Runtime.Const('A')), 'AAB'), [['A', 'A'], 'B'])
10+
Assert.IsEqual(Runtime.Parse(Runtime.Array(Runtime.Const('AA')), 'AAB'), [['AA'], 'B'])
11+
Assert.IsEqual(Runtime.Parse(Runtime.Array(Runtime.Const('AA')), 'AAAB'), [['AA'], 'AB'])
12+
Assert.IsEqual(Runtime.Parse(Runtime.Array(Runtime.Const('AA')), 'B'), [[], 'B'])
13+
})

test/parsebox/runtime/bigint.ts

Whitespace-only changes.

test/parsebox/runtime/const.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Runtime } from '@sinclair/parsebox'
2+
import { Assert } from 'test'
3+
4+
const Test = Assert.Context('Runtime.Parse.Const')
5+
6+
Test('Const', () => {
7+
Assert.IsEqual(Runtime.Parse(Runtime.Const('A'), ''), [])
8+
Assert.IsEqual(Runtime.Parse(Runtime.Const('A'), 'A'), ['A', ''])
9+
Assert.IsEqual(Runtime.Parse(Runtime.Const('A'), ' A'), ['A', ''])
10+
Assert.IsEqual(Runtime.Parse(Runtime.Const('A'), ' A '), ['A', ' '])
11+
})

test/parsebox/runtime/ident.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Runtime } from '@sinclair/parsebox'
2+
import { Assert } from 'test'
3+
4+
const Test = Assert.Context('Runtime.Parse.Ident')
5+
6+
Test('Ident', () => {
7+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ''), [])
8+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), '0'), [])
9+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), '#'), [])
10+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), '_'), ['_', ''])
11+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' _'), ['_', ''])
12+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), '_ '), ['_', ' '])
13+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' _ '), ['_', ' '])
14+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), '$'), ['$', ''])
15+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' $'), ['$', ''])
16+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), '$ '), ['$', ' '])
17+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' $ '), ['$', ' '])
18+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), 'A'), ['A', ''])
19+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' A'), ['A', ''])
20+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), 'A '), ['A', ' '])
21+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' A '), ['A', ' '])
22+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), 'A1'), ['A1', ''])
23+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' A1'), ['A1', ''])
24+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), 'A1 '), ['A1', ' '])
25+
Assert.IsEqual(Runtime.Parse(Runtime.Ident(), ' A1 '), ['A1', ' '])
26+
})

test/parsebox/runtime/integer.ts

Whitespace-only changes.

test/parsebox/runtime/number.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Runtime } from '@sinclair/parsebox'
2+
import { Assert } from 'test'
3+
4+
const Test = Assert.Context('Runtime.Parse.Integer')
5+
6+
Test('Number', () => {
7+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ''), [])
8+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '01'), ['0', '1'])
9+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 01'), ['0', '1'])
10+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '01 '), ['0', '1 '])
11+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 01 '), ['0', '1 '])
12+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '0'), ['0', ''])
13+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '0 '), ['0', ' '])
14+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 0'), ['0', ''])
15+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 0 '), ['0', ' '])
16+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-0'), ['-0', ''])
17+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-0 '), ['-0', ' '])
18+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -0'), ['-0', ''])
19+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -0 '), ['-0', ' '])
20+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '100'), ['100', ''])
21+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '100 '), ['100', ' '])
22+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 100'), ['100', ''])
23+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 100 '), ['100', ' '])
24+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-100'), ['-100', ''])
25+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-100 '), ['-100', ' '])
26+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -100'), ['-100', ''])
27+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -100 '), ['-100', ' '])
28+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '0.1'), ['0.1', ''])
29+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '0.1 '), ['0.1', ' '])
30+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 0.1'), ['0.1', ''])
31+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 0.1 '), ['0.1', ' '])
32+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '100.1'), ['100.1', ''])
33+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '100.1 '), ['100.1', ' '])
34+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 100.1'), ['100.1', ''])
35+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 100.1 '), ['100.1', ' '])
36+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-100.1'), ['-100.1', ''])
37+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-100.1 '), ['-100.1', ' '])
38+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -100.1'), ['-100.1', ''])
39+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -100.1 '), ['-100.1', ' '])
40+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '100.1.1'), ['100.1', '.1'])
41+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '100.1.1 '), ['100.1', '.1 '])
42+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 100.1.1'), ['100.1', '.1'])
43+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' 100.1.1 '), ['100.1', '.1 '])
44+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-.1'), ['-0.1', ''])
45+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-.1 '), ['-0.1', ' '])
46+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -.1'), ['-0.1', ''])
47+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -.1 '), ['-0.1', ' '])
48+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-0.1'), ['-0.1', ''])
49+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), '-0.1 '), ['-0.1', ' '])
50+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -0.1'), ['-0.1', ''])
51+
Assert.IsEqual(Runtime.Parse(Runtime.Number(), ' -0.1 '), ['-0.1', ' '])
52+
})

test/parsebox/runtime/optional.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Runtime } from '@sinclair/parsebox'
2+
import { Assert } from 'test'
3+
4+
const Test = Assert.Context('Runtime.Parse.Optional')
5+
6+
Test('Optional', () => {
7+
Assert.IsEqual(Runtime.Parse(Runtime.Optional(Runtime.Const('A')), ''), [[], ''])
8+
Assert.IsEqual(Runtime.Parse(Runtime.Optional(Runtime.Const('A')), 'A'), [['A'], ''])
9+
Assert.IsEqual(Runtime.Parse(Runtime.Optional(Runtime.Const('A')), 'AA'), [['A'], 'A'])
10+
Assert.IsEqual(Runtime.Parse(Runtime.Optional(Runtime.Const('A')), 'B'), [[], 'B'])
11+
})

test/parsebox/runtime/parse.ts

Lines changed: 0 additions & 184 deletions
This file was deleted.

test/parsebox/runtime/ref.ts

Whitespace-only changes.

test/parsebox/runtime/string.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Runtime } from '@sinclair/parsebox'
2+
import { Assert } from 'test'
3+
4+
const Test = Assert.Context('Runtime.Parse.String')
5+
6+
Test('String', () => {
7+
Assert.IsEqual(Runtime.Parse(Runtime.String([`'`, `"`]), ''), [])
8+
Assert.IsEqual(Runtime.Parse(Runtime.String([`'`, `"`]), '"A"'), ['A', ''])
9+
Assert.IsEqual(Runtime.Parse(Runtime.String([`'`, `"`]), ' "A"'), ['A', ''])
10+
Assert.IsEqual(Runtime.Parse(Runtime.String([`'`, `"`]), '"A" '), ['A', ' '])
11+
Assert.IsEqual(Runtime.Parse(Runtime.String([`'`, `"`]), ' "A" '), ['A', ' '])
12+
})

0 commit comments

Comments
 (0)