diff options
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]) }) }) |
