tag as top level part 2 (#2773)

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* unit tests pass

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* playwright

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* format

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* format

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* more literals gone

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove console log

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove only

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix some recast shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* last

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Jess Frazelle
2024-06-24 22:39:04 -07:00
committed by GitHub
parent ad5bfa1a29
commit da6cd5cf9f
44 changed files with 720 additions and 536 deletions

View File

@ -65,17 +65,17 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
const bigExampleArr = [
`const part001 = startSketchOn('XY')`,
` |> startProfileAt([0, 0], %)`,
` |> lineTo([1, 1], %, 'abc1')`,
` |> line([-2.04, -0.7], %, 'abc2')`,
` |> angledLine({ angle: 157, length: 1.69 }, %, 'abc3')`,
` |> angledLineOfXLength({ angle: 217, length: 0.86 }, %, 'abc4')`,
` |> angledLineOfYLength({ angle: 104, length: 1.58 }, %, 'abc5')`,
` |> angledLineToX({ angle: 55, to: -2.89 }, %, 'abc6')`,
` |> angledLineToY({ angle: 330, to: 2.53 }, %, 'abc7')`,
` |> xLine(1.47, %, 'abc8')`,
` |> yLine(1.57, %, 'abc9')`,
` |> xLineTo(1.49, %, 'abc10')`,
` |> yLineTo(2.64, %, 'abc11')`,
` |> lineTo([1, 1], %, $abc1)`,
` |> line([-2.04, -0.7], %, $abc2)`,
` |> angledLine({ angle: 157, length: 1.69 }, %, $abc3)`,
` |> angledLineOfXLength({ angle: 217, length: 0.86 }, %, $abc4)`,
` |> angledLineOfYLength({ angle: 104, length: 1.58 }, %, $abc5)`,
` |> angledLineToX({ angle: 55, to: -2.89 }, %, $abc6)`,
` |> angledLineToY({ angle: 330, to: 2.53 }, %, $abc7)`,
` |> xLine(1.47, %, $abc8)`,
` |> yLine(1.57, %, $abc9)`,
` |> xLineTo(1.49, %, $abc10)`,
` |> yLineTo(2.64, %, $abc11)`,
` |> lineTo([2.55, 3.58], %) // lineTo`,
` |> line([0.73, -0.75], %)`,
` |> angledLine([63, 1.38], %) // angledLine`,
@ -90,8 +90,8 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
]
const bigExample = bigExampleArr.join('\n')
it('line with tag converts to xLine', async () => {
const callToSwap = "line([-2.04, -0.7], %, 'abc2')"
const expectedLine = "xLine(-2.04, %, 'abc2')"
const callToSwap = 'line([-2.04, -0.7], %, $abc2)'
const expectedLine = 'xLine(-2.04, %, $abc2)'
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap,
@ -116,10 +116,10 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
it('lineTo with tag converts to xLineTo', async () => {
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap: "lineTo([1, 1], %, 'abc1')",
callToSwap: 'lineTo([1, 1], %, $abc1)',
constraintType: 'horizontal',
})
const expectedLine = "xLineTo(1, %, 'abc1')"
const expectedLine = 'xLineTo(1, %, $abc1)'
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
expect(originalRange[0]).toBe(newCode.indexOf(expectedLine))
@ -138,10 +138,10 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
it('angledLine with tag converts to xLine', async () => {
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap: "angledLine({ angle: 157, length: 1.69 }, %, 'abc3')",
callToSwap: 'angledLine({ angle: 157, length: 1.69 }, %, $abc3)',
constraintType: 'horizontal',
})
const expectedLine = "xLine(-1.56, %, 'abc3')"
const expectedLine = 'xLine(-1.56, %, $abc3)'
console.log(newCode)
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
@ -161,11 +161,10 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
it('angledLineOfXLength with tag converts to xLine', async () => {
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap:
"angledLineOfXLength({ angle: 217, length: 0.86 }, %, 'abc4')",
callToSwap: 'angledLineOfXLength({ angle: 217, length: 0.86 }, %, $abc4)',
constraintType: 'horizontal',
})
const expectedLine = "xLine(-0.86, %, 'abc4')"
const expectedLine = 'xLine(-0.86, %, $abc4)'
// hmm "-0.86" is correct since the angle is 104, but need to make sure this is compatible `-myVar`
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
@ -185,11 +184,10 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
it('angledLineOfYLength with tag converts to yLine', async () => {
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap:
"angledLineOfYLength({ angle: 104, length: 1.58 }, %, 'abc5')",
callToSwap: 'angledLineOfYLength({ angle: 104, length: 1.58 }, %, $abc5)',
constraintType: 'vertical',
})
const expectedLine = "yLine(1.58, %, 'abc5')"
const expectedLine = 'yLine(1.58, %, $abc5)'
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
expect(originalRange[0]).toBe(newCode.indexOf(expectedLine))
@ -208,10 +206,10 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
it('angledLineToX with tag converts to xLineTo', async () => {
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap: "angledLineToX({ angle: 55, to: -2.89 }, %, 'abc6')",
callToSwap: 'angledLineToX({ angle: 55, to: -2.89 }, %, $abc6)',
constraintType: 'horizontal',
})
const expectedLine = "xLineTo(-2.89, %, 'abc6')"
const expectedLine = 'xLineTo(-2.89, %, $abc6)'
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
expect(originalRange[0]).toBe(newCode.indexOf(expectedLine))
@ -230,10 +228,10 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
it('angledLineToY with tag converts to yLineTo', async () => {
const { newCode, originalRange } = await testingSwapSketchFnCall({
inputCode: bigExample,
callToSwap: "angledLineToY({ angle: 330, to: 2.53 }, %, 'abc7')",
callToSwap: 'angledLineToY({ angle: 330, to: 2.53 }, %, $abc7)',
constraintType: 'vertical',
})
const expectedLine = "yLineTo(2.53, %, 'abc7')"
const expectedLine = 'yLineTo(2.53, %, $abc7)'
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
expect(originalRange[0]).toBe(newCode.indexOf(expectedLine))