diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-10 21:29:42 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-10 21:29:42 +0530 |
| commit | 3581e398a2fe2f38bee7e6d13cbf609221f61672 (patch) | |
| tree | 95715115303ecb9620cbf37530e89a37c0ff5c4b /tests | |
| parent | aa006086f69c827d780e6e0e69947ca7ee6e2c70 (diff) | |
| download | elxr-3581e398a2fe2f38bee7e6d13cbf609221f61672.tar.gz elxr-3581e398a2fe2f38bee7e6d13cbf609221f61672.zip | |
feat: adds matchAll function (incomplete)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic.spec.ts | 13 | ||||
| -rw-r--r-- | tests/eval.spec.ts | 24 |
2 files changed, 32 insertions, 5 deletions
diff --git a/tests/basic.spec.ts b/tests/basic.spec.ts index d964053..db2e9a3 100644 --- a/tests/basic.spec.ts +++ b/tests/basic.spec.ts @@ -1,4 +1,5 @@ -import { filter } from '../src' +import { jlog } from '../src/utils' +import { filter, matchAll } from '../src' describe('Basic tests', () => { it('should do it', () => { @@ -9,4 +10,14 @@ describe('Basic tests', () => { expect(filter(/\F\T/, [1, 0, '4', ''])).toEqual([]) expect(filter(/\s\T/, [1, 0, '4', ''])).toEqual(['4']) }) + + fit('should do it', () => { + // jlog(matchAll(/[age \n]+/, [ {}, { age: 1 }, { age: 2 }, { age: 0 }, '' ])) + // jlog(matchAll(/[age \n]+/, [ {}, { age: 1 }, '' ])) + // jlog(matchAll(/([age \T][age \n])+/, [ {}, { age: 1 }, { age: 2 }, { age: 0 }, '' ])) + + jlog(matchAll(/\n/, [ 'b', 1, 'a' ])) + // jlog(matchAll(/\n\T/, [1, 0, 2, '4', ''])) + // jlog(matchAll(/\n+/, [ '', 1, 2, 0, '', 5, '' ])) + }) }) diff --git a/tests/eval.spec.ts b/tests/eval.spec.ts index 8c79375..ca06033 100644 --- a/tests/eval.spec.ts +++ b/tests/eval.spec.ts @@ -2,9 +2,27 @@ import { left, right } from 'fp-ts/Either' import { none, some } from 'fp-ts/Option' import { Expr, ListExpr } from '../src/types' import { jlog } from '../src/utils' -import { find } from '../src/eval' +import { find, matchAll } from '../src/eval' describe('Eval', () => { + it('should do stuff', () => { + const ls = [-1, 1, 2, '3', 4, '5', 6, 7, ''] + + const liexp: ListExpr = [ + none, + [ + Expr.OneOrMore({ + expr: Expr.Group({ + exprs: [Expr.AnyNumber(null), Expr.Truthy(null)], + }), + }), + ], + none, + ] + + //jlog(matchAll(liexp, ls)) + }) + it('basic evaluation', () => { const list = [0, 1, '2', 3, [4], 5] @@ -66,9 +84,7 @@ describe('Eval', () => { const liexp: ListExpr = [ none, - [ - Expr.OneOrMore({ expr: Expr.AnyNumber(null) }), - ], + [Expr.OneOrMore({ expr: Expr.AnyNumber(null) })], none, ] expect(find(liexp, list)).toEqual([1, 3, 5]) |
