functional sketch working (#26)
* functional sketch working With old sketch block still there * get all version of lines working with add line and update line * remove old ui state types * some clean up * rename some things * add todo for multi cursor * shorten useStore repitition * small type improvement * big overhaul to group sketch function and they ast modifying helpers together * unneeded tweak * ruthlessly rip out sketch logic * clean up path keyword * getting sketch on face working again with all the new sketch line types * add a bunch of tests and re-arrage file structure
This commit is contained in:
@ -62,12 +62,12 @@ log(5, myVar)`
|
||||
expect(recasted).toBe(code)
|
||||
})
|
||||
it('sketch declaration', () => {
|
||||
let code = `sketch mySketch {
|
||||
path myPath = lineTo(0, 1)
|
||||
lineTo(1, 1)
|
||||
path rightPath = lineTo(1, 0)
|
||||
close()
|
||||
}
|
||||
let code = `const mySketch = startSketchAt([0, 0])
|
||||
|> lineTo({ to: [0, 1], tag: "myPath" }, %)
|
||||
|> lineTo([1, 1], %)
|
||||
|> lineTo({ to: [1, 0], tag: "rightPath" }, %)
|
||||
|> close(%)
|
||||
|
||||
show(mySketch)
|
||||
`
|
||||
const { ast } = code2ast(code)
|
||||
@ -76,11 +76,10 @@ show(mySketch)
|
||||
})
|
||||
it('sketch piped into callExpression', () => {
|
||||
const code = [
|
||||
'sketch mySk1 {',
|
||||
' lineTo(1, 1)',
|
||||
' path myPath = lineTo(0, 1)',
|
||||
' lineTo(1, 1)',
|
||||
'}',
|
||||
'const mySk1 = startSketchAt([0, 0])',
|
||||
' |> lineTo([1, 1], %)',
|
||||
' |> lineTo({ to: [0, 1], tag: "myTag" }, %)',
|
||||
' |> lineTo([1, 1], %)',
|
||||
' |> rx(90, %)',
|
||||
].join('\n')
|
||||
const { ast } = code2ast(code)
|
||||
@ -226,24 +225,6 @@ const myFn = () => {
|
||||
|
||||
const key = 'c'
|
||||
// this is also a comment
|
||||
}`
|
||||
const { ast } = code2ast(code)
|
||||
const recasted = recast(ast)
|
||||
expect(recasted).toBe(code)
|
||||
})
|
||||
it('comments in a sketch block', () => {
|
||||
const code = `
|
||||
sketch mySketch { /* comment at start */
|
||||
// comment at start more
|
||||
path myPath = lineTo(0, 1) /* comment here with
|
||||
some whitespace below */
|
||||
|
||||
|
||||
lineTo(1, 1)
|
||||
/* comment before declaration*/path rightPath = lineTo(1, 0)
|
||||
close()
|
||||
// comment at end
|
||||
|
||||
}`
|
||||
const { ast } = code2ast(code)
|
||||
const recasted = recast(ast)
|
||||
@ -251,11 +232,10 @@ sketch mySketch { /* comment at start */
|
||||
})
|
||||
it('comments in a pipe expression', () => {
|
||||
const code = [
|
||||
'sketch mySk1 {',
|
||||
' lineTo(1, 1)',
|
||||
' path myPath = lineTo(0, 1)',
|
||||
' lineTo(1, 1)',
|
||||
'}',
|
||||
'const mySk1 = startSketchAt([0, 0])',
|
||||
' |> lineTo([1, 1], %)',
|
||||
' |> lineTo({ to: [0, 1], tag: "myTag" }, %)',
|
||||
' |> lineTo([1, 1], %)',
|
||||
' // a comment',
|
||||
' |> rx(90, %)',
|
||||
].join('\n')
|
||||
@ -267,14 +247,13 @@ sketch mySketch { /* comment at start */
|
||||
const code = `
|
||||
/* comment at start */
|
||||
|
||||
sketch mySk1 {
|
||||
lineTo(1, 1)
|
||||
const mySk1 = startSketchAt([0, 0])
|
||||
|> lineTo([1, 1], %)
|
||||
// comment here
|
||||
path myPath = lineTo(0, 1)
|
||||
lineTo(1, 1) /* and
|
||||
|> lineTo({ to: [0, 1], tag: 'myTag' }, %)
|
||||
|> lineTo([1, 1], %) /* and
|
||||
here
|
||||
*/
|
||||
}
|
||||
// a comment between pipe expression statements
|
||||
|> rx(90, %)
|
||||
// and another with just white space between others below
|
||||
|
Reference in New Issue
Block a user