aboutsummaryrefslogtreecommitdiff
path: root/tests/basic.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/basic.spec.ts34
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/basic.spec.ts b/tests/basic.spec.ts
index d443ce1..150966b 100644
--- a/tests/basic.spec.ts
+++ b/tests/basic.spec.ts
@@ -6,9 +6,11 @@ import {
delimited,
} from '../src/parser/utils'
import { parser } from '../src/parser'
-import { some } from 'fp-ts/Option'
+import { none, some } from 'fp-ts/Option'
import { Expr } from '../src/types'
+const plog = (x: any) => console.log(JSON.stringify(x, null, 2))
+
describe('Foobar', () => {
it('should do shit', () => {
expect(integer('12901')).toEqual(right([12901, '']))
@@ -18,10 +20,10 @@ describe('Foobar', () => {
expect(whitespace('a')).toEqual(left(['unable to match', 'a']))
expect(delimited(whitespaces0, integer, whitespaces0)(' 20 ')).toEqual(
- right([20, ''])
+ right([20, '']),
)
expect(delimited(whitespaces0, integer, whitespaces0)(' 2 0 ')).toEqual(
- right([2, '0 '])
+ right([2, '0 ']),
)
})
@@ -40,7 +42,7 @@ describe('Foobar', () => {
some(Expr.End(null)),
],
'',
- ])
+ ]),
)
expect(parser(/^ \s* \T? \n+ $/.source)).toEqual(
@@ -55,7 +57,29 @@ describe('Foobar', () => {
some(Expr.End(null)),
],
'',
- ])
+ ]),
+ )
+
+ expect(parser(/ \s|\b\T|\n /.source)).toEqual(
+ right([
+ [
+ none,
+ [
+ Expr.Or({
+ left: Expr.AnyString(null),
+ right: [
+ Expr.AnyBool(null),
+ Expr.Or({
+ left: Expr.Truthy(null),
+ right: [Expr.AnyNumber(null)],
+ }),
+ ],
+ }),
+ ],
+ none,
+ ],
+ '',
+ ]),
)
})
})