-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from fink-lang/new-features
new features
- Loading branch information
Showing
12 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`new transforms new 1`] = ` | ||
"const foo = new Set(); | ||
Object.assign(module.exports, { | ||
foo | ||
});" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`throw transforms throw 1`] = ` | ||
"const foo = bar || throw err(\`spam\`); | ||
Object.assign(module.exports, { | ||
foo | ||
});" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {newExpression} from '@babel/types'; | ||
import {wrap} from '../types'; | ||
|
||
|
||
export const transform_new = (node, ctx)=> { | ||
const right = ctx.transform(node.right); | ||
|
||
return wrap(node, newExpression(right.callee, right.arguments)); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {fink2js} from '../testing'; | ||
|
||
|
||
describe('new', ()=> { | ||
it('transforms new', ()=> { | ||
expect( | ||
fink2js(` | ||
foo = new Set() | ||
`) | ||
).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
import {templateElement, templateLiteral} from '@babel/types'; | ||
import { | ||
templateElement, templateLiteral, taggedTemplateExpression | ||
} from '@babel/types'; | ||
|
||
|
||
export const transform_string = (node)=> ( | ||
templateLiteral( | ||
export const transform_string = (node, {transform})=> { | ||
const templ_str = templateLiteral( | ||
node.parts.map((part)=> templateElement({raw: part, cooked: part})), | ||
[] | ||
) | ||
); | ||
); | ||
|
||
if (node.tag) { | ||
return taggedTemplateExpression(transform(node.tag), templ_str); | ||
} | ||
|
||
return templ_str; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {unaryExpression} from '@babel/types'; | ||
import {wrap} from '../types'; | ||
|
||
|
||
export const transform_throw = (node, ctx)=> { | ||
const right = ctx.transform(node.right); | ||
|
||
return wrap(node, unaryExpression('throw', right)); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {fink2js} from '../testing'; | ||
|
||
|
||
describe('throw', ()=> { | ||
it('transforms throw', ()=> { | ||
expect( | ||
fink2js(` | ||
foo = bar || throw err('spam') | ||
`) | ||
).toMatchSnapshot(); | ||
}); | ||
}); |