From c2c6e8d1258158f61fba026ded1e48ffc5b36cf6 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 14 Jan 2022 19:43:45 +0530 Subject: feat(eval): implements 0 or more quantifier --- tests/basic.spec.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests/basic.spec.ts') diff --git a/tests/basic.spec.ts b/tests/basic.spec.ts index dfa5e40..33a4228 100644 --- a/tests/basic.spec.ts +++ b/tests/basic.spec.ts @@ -1,7 +1,12 @@ +import {jlog} from '../src/utils' import { matchAll } from '../src' describe('Basic tests', () => { describe('matchAll', () => { + it('should do shit', () => { + // jlog(matchAll(/\s+/, [1, '2', '', '3', 5, '6'])) + }) + it('should filter shit', () => { expect(matchAll(/\s/, [1, '2', 3, '4']).groups).toEqual([ { value: '2', index: 1 }, @@ -70,7 +75,7 @@ describe('Basic tests', () => { ]) }) - it('should match object property matchers', () => { + it('should match object property matchers multi', () => { expect( matchAll(/([age \n][age \T])+/, [ {}, @@ -81,6 +86,21 @@ describe('Basic tests', () => { ]).groups, ).toEqual([{ value: [{ age: 1 }, { age: 2 }], index: 1 }]) + expect( + matchAll(/([age \n][age \T])*/, [ + {}, + { age: 1 }, + { age: 2 }, + { age: 0 }, + '', + ]).groups, + ).toEqual([ + { value: [], index: 0 }, + { value: [{ age: 1 }, { age: 2 }], index: 1 }, + { value: [], index: 3 }, + { value: [], index: 4 }, + ]) + expect( matchAll(/ [num \n\T]+ /, [ null, -- cgit v1.3.1