From 61bb1f0c8b109c66d48e678a4d2cf7cb29cf7efb Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 8 Jan 2022 20:31:33 +0530 Subject: test: adds group eval --- tests/eval.spec.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests/eval.spec.ts') 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]) }) }) -- cgit v1.3.1