Skip to content

Commit bcab658

Browse files
committed
test: add test for token->function
1 parent b7592c9 commit bcab658

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.github/workflows/semantic-release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
cache: npm
2020
node-version: 16
2121
- run: npm ci
22+
- run: npm test
2223
- run: npm run build
2324
- run: zip -r dist.zip dist
2425
- run: npx semantic-release

test/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,17 @@ describe('Ading Token', function () {
386386
])
387387
assert.equal(Mexp.eval('maxof5(7, 12, 23, 33, 2)'), 33)
388388
})
389+
it('token with absolute', function () {
390+
Mexp.addToken([
391+
{
392+
type: 0,
393+
token: 'positive',
394+
show: 'positive',
395+
value: function (a) {
396+
return Math.abs(a)
397+
},
398+
},
399+
])
400+
assert.equal(Mexp.eval('root(positive(2-6))'), 2)
401+
})
389402
})

0 commit comments

Comments
 (0)