Skip to content

Commit

Permalink
feat(literal): add support for 'true', 'false', 'null' literals
Browse files Browse the repository at this point in the history
  • Loading branch information
kollhof committed May 1, 2020
1 parent c082d28 commit 78006bc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lang/literals/keywords.fnk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{booleanLiteral, nullLiteral} = import '@babel/types'


transform_keyword = fn node:
match node:
{'value': 'true'}: booleanLiteral:: true
{'value': 'false'}: booleanLiteral:: false
{'value': 'null'}: nullLiteral()
13 changes: 13 additions & 0 deletions src/lang/literals/keywords.test.fnk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'


describe:: 'keywords', fn:
it:: 'transforms literals', fn:
expect::
fink2js`
x = false
y = true
z = null
`
to_match_snapshot
12 changes: 12 additions & 0 deletions src/lang/literals/keywords.test.fnk.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`keywords transforms literals 1`] = `
"const x = false;
const y = true;
const z = null;
Object.assign(module.exports, {
x,
y,
z
});"
`;

0 comments on commit 78006bc

Please sign in to comment.