aboutsummaryrefslogtreecommitdiff
path: root/tests/basic.spec.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2022-01-13 17:54:27 +0530
committerAkshay Nair <phenax5@gmail.com>2022-01-13 17:54:35 +0530
commit1a281a717fe5bab2694bf51c1b03a7569d8facb4 (patch)
treeea0ff4e5ee4d579aed4750d53503b33aab5cb818 /tests/basic.spec.ts
parentfc548093f151355842122912c582fc10a2d5acb2 (diff)
downloadelxr-1a281a717fe5bab2694bf51c1b03a7569d8facb4.tar.gz
elxr-1a281a717fe5bab2694bf51c1b03a7569d8facb4.zip
feat(eval): adds literal equality check
Diffstat (limited to '')
-rw-r--r--tests/basic.spec.ts33
1 files changed, 12 insertions, 21 deletions
diff --git a/tests/basic.spec.ts b/tests/basic.spec.ts
index febf77e..2d7af37 100644
--- a/tests/basic.spec.ts
+++ b/tests/basic.spec.ts
@@ -16,31 +16,22 @@ describe('Basic tests', () => {
// jlog(matchAll(/[age \n]+/, [ {}, { age: 1 }, '' ]))
// jlog(matchAll(/([age \n])+/, [ {}, { age: 1 }, { age: 2 }, { age: 0 }, '' ]))
// jlog(matchAll(/\n+/, [ '', 1, 2, 0, '6', 5, '' ]))
- // jlog(takeLeftWhile((x: number) => x < 5)([1, 2, 3, 4, 5, 6]))
- jlog(
- matchAll(/ [num \n\T]+ /, [
- null,
- { num: 1 },
- { num: 2 },
- {},
- { num: 0 },
- { num: 3 },
- ]),
- )
-
- jlog(
- matchAll(/([age \n][age \T])+/, [
- {},
- { age: 1 },
- { age: 2 },
- { age: 0 },
- '',
- ]).groups,
- )
+ //jlog(matchAll(/ -2.05 /, [ 2, -2.05, 5, -2.05, 2.05, 0.05, 'wow', '-2.05', '-2' ]))
})
describe('matchAll', () => {
+ it ('should match literals', () => {
+ expect(matchAll(/ -2.05 /, [ 2, NaN, -2.05, '-2.05', -2.05, 2.05 ]).groups).toEqual([
+ { value: -2.05, index: 2 },
+ { value: -2.05, index: 4 },
+ ])
+ expect(matchAll(/ true /, [ 1, true, false, true, 'true' ]).groups).toEqual([
+ { value: true, index: 1 },
+ { value: true, index: 3 },
+ ])
+ })
+
it('should match simple expression', () => {
expect(matchAll(/\n/, ['b', 1, 2, 'a', 3]).groups).toEqual([
{ value: 1, index: 1 },