Skip to content

Commit

Permalink
Add arrow function cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Feb 19, 2024
1 parent 49615f3 commit 44cf5f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion feature/arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compile, operator } from "../src/compile.js"
import { PREC_ASSIGN, PREC_TOKEN } from "../src/const.js"

// arrow functions (useful for array methods)
binary('=>', PREC_ASSIGN)
binary('=>', PREC_ASSIGN, true)
operator('=>',
(a, b) => (
a = a[0] === '()' ? a[1] : a,
Expand Down
3 changes: 3 additions & 0 deletions test/subscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ test('ext: arrow', async t => {
is(subscript('() => 1')()(), 1)
is(subscript('(a) => a+1')()(1), 2)
is(subscript('(a) => a+b')({ b: 2 })(1), 3)
is(subscript('a=>a+=1')()(1), 2)
is(parse('a=>a,b=>b=c=d'), [',', ['=>', 'a', 'a'], ['=>', 'b', ['=', 'b', ['=', 'c', 'd']]]])
is(parse('a=>b=>c=d'), ['=>', 'a', ['=>', 'b', ['=', 'c', 'd']]])
})

test('ext: justin', async t => {
Expand Down

0 comments on commit 44cf5f2

Please sign in to comment.