get recasting working for pipes

This commit is contained in:
Kurt Hutten IrevDev
2022-12-04 13:10:26 +11:00
parent b114d61053
commit 200f5b0b0a
2 changed files with 57 additions and 25 deletions

View File

@ -74,6 +74,31 @@ show(mySketch)
const recasted = recast(ast)
expect(recasted).toBe(code.trim())
})
it('sketch piped into callExpression', () => {
const code = [
'sketch mySk1 {',
' lineTo(1, 1)',
' path myPath = lineTo(0, 1)',
' lineTo(1, 1)',
'}',
' |> rx(90, %)',
].join('\n')
const { ast } = code2ast(code)
const recasted = recast(ast)
expect(recasted).toBe(code.trim())
})
it('recast BinaryExpression piped into CallExpression', () => {
const code = [
'fn myFn = (a) => {',
' return a + 1',
'}',
'const myVar = 5 + 1',
' |> myFn(%)',
].join('\n')
const { ast } = code2ast(code)
const recasted = recast(ast)
expect(recasted).toBe(code.trim())
})
})
// helpers