diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-08 20:31:33 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-08 20:31:33 +0530 |
| commit | 61bb1f0c8b109c66d48e678a4d2cf7cb29cf7efb (patch) | |
| tree | 6cb1308db42e812086534c21f6949c6a2c91c3b1 /tests/eval.spec.ts | |
| parent | 84b3cb464fd78c5d381324db244c6a5d9bcd698d (diff) | |
| download | elxr-61bb1f0c8b109c66d48e678a4d2cf7cb29cf7efb.tar.gz elxr-61bb1f0c8b109c66d48e678a4d2cf7cb29cf7efb.zip | |
test: adds group eval
Diffstat (limited to '')
| -rw-r--r-- | tests/eval.spec.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/eval.spec.ts b/tests/eval.spec.ts index 97995bf..9bf3000 100644 --- a/tests/eval.spec.ts +++ b/tests/eval.spec.ts @@ -5,15 +5,32 @@ import { jlog } from '../src/utils' import { find } from '../src/eval' describe('Eval', () => { - it('should do shit', () => { + it('basic evaluation', () => { + const list = [0, 1, '2', 3, [4], 5] + const liexp: ListExpr = [ none, [ Expr.AnyNumber(null), Expr.Truthy(null) ], none, ] + expect(find(liexp, list)).toEqual([1, 3, 5]) + + const liexp2: ListExpr = [ + none, + [ Expr.Falsey(null), Expr.Truthy(null) ], + none, + ] + expect(find(liexp2, list)).toEqual([]) + }) + it('with groups', () => { const list = [0, 1, '2', 3, [4], 5] + const liexp: ListExpr = [ + none, + [ Expr.AnyItem(null), Expr.Group({ exprs: [ Expr.AnyNumber(null), Expr.Truthy(null)] }) ], + none, + ] expect(find(liexp, list)).toEqual([1, 3, 5]) }) }) |
