From e246f2341ee13926f4273c6d634cef4fe07f040e Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 8 Jan 2022 21:12:20 +0530 Subject: feat(parse): implements object property matching parser --- tests/parser.spec.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/parser.spec.ts b/tests/parser.spec.ts index 150966b..1ebd290 100644 --- a/tests/parser.spec.ts +++ b/tests/parser.spec.ts @@ -4,8 +4,10 @@ import { whitespace, whitespaces0, delimited, + many1, + satifyChar, } from '../src/parser/utils' -import { parser } from '../src/parser' +import { parser, propertyName } from '../src/parser' import { none, some } from 'fp-ts/Option' import { Expr } from '../src/types' @@ -82,4 +84,20 @@ describe('Foobar', () => { ]), ) }) + + it('object proprtyu', () => { + expect(parser(/ [name \s\T] [age \n] /.source)).toEqual( + right([ + [ + none, + [ + Expr.PropertyMatch({ name: 'name', exprs: [Expr.AnyString(null), Expr.Truthy(null)] }), + Expr.PropertyMatch({ name: 'age', exprs: [Expr.AnyNumber(null)] }), + ], + none, + ], + '', + ]), + ) + }) }) -- cgit v1.3.1