From 5c547efb4f7e84bf5117e2da15230c77e9e20dba Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Thu, 8 Aug 2024 18:13:05 -0500 Subject: [PATCH] Migrate code within JS --- e2e/playwright/editor-tests.spec.ts | 16 +++++----- e2e/playwright/sketch-tests.spec.ts | 22 ++++++------- e2e/playwright/snapshot-tests.spec.ts | 4 +-- e2e/playwright/storageStates.ts | 2 +- .../testing-segment-overlays.spec.ts | 24 +++++++------- e2e/playwright/testing-selections.spec.ts | 4 +-- src/lang/modifyAst.test.ts | 4 +-- src/lang/modifyAst/addFillet.test.ts | 32 +++++++++---------- src/lang/std/sketch.test.ts | 6 ++-- src/lang/std/sketch.ts | 1 + src/wasm-lib/kcl/src/parser/parser_impl.rs | 2 +- 11 files changed, 59 insertions(+), 58 deletions(-) diff --git a/e2e/playwright/editor-tests.spec.ts b/e2e/playwright/editor-tests.spec.ts index b51ef92b0..bcec5346f 100644 --- a/e2e/playwright/editor-tests.spec.ts +++ b/e2e/playwright/editor-tests.spec.ts @@ -648,7 +648,7 @@ test.describe('Editor tests', () => { `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%)` ) }) @@ -701,7 +701,7 @@ test.describe('Editor tests', () => { // expect the code to have changed await expect(page.locator('.cm-content')).toHaveText( - `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) |> tangentialArcTo([24.95, -5.38], %) |> close(%)const extrude001 = extrude(5, sketch001)` + `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) |> tangentialArcTo([24.95, -5.38], false, %) |> close(%)const extrude001 = extrude(5, sketch001)` ) // Now hit undo @@ -714,7 +714,7 @@ test.describe('Editor tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%)`) }) @@ -728,7 +728,7 @@ test.describe('Editor tests', () => { `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%) |> extrude(5, %)` ) @@ -819,7 +819,7 @@ test.describe('Editor tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([7.12, -16.82], %) |> line([15.4, -2.74], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> line([2.65, -2.69], %) |> close(%) |> extrude(5, %)`) @@ -833,7 +833,7 @@ test.describe('Editor tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([7.12, -16.82], %) |> line([15.4, -2.74], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%) |> extrude(5, %)`) @@ -846,7 +846,7 @@ test.describe('Editor tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([7.12, -16.82], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%) |> extrude(5, %)`) @@ -860,7 +860,7 @@ test.describe('Editor tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%) |> extrude(5, %)`) }) diff --git a/e2e/playwright/sketch-tests.spec.ts b/e2e/playwright/sketch-tests.spec.ts index e53f6987d..bfa22837f 100644 --- a/e2e/playwright/sketch-tests.spec.ts +++ b/e2e/playwright/sketch-tests.spec.ts @@ -61,7 +61,7 @@ test.describe('Sketch tests', () => { const part002 = startSketchOn('-XZ') ${startProfileAt3} |> xLine(width / 4, %) - |> tangentialArcTo([width / 2, 0], %) + |> tangentialArcTo([width / 2, 0], false, %) |> xLine(-width / 4 + wireRadius, %) |> yLine(wireOffset, %) |> arc({ @@ -115,7 +115,7 @@ test.describe('Sketch tests', () => { `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %)` + |> tangentialArcTo([24.95, -5.38], false, %)` ) }) @@ -125,7 +125,7 @@ test.describe('Sketch tests', () => { await expect(async () => { await page.mouse.click(700, 200) - await page.getByText('tangentialArcTo([24.95, -5.38], %)').click() + await page.getByText('tangentialArcTo([24.95, -5.38], false, %)').click() await expect( page.getByRole('button', { name: 'Edit Sketch' }) ).toBeEnabled({ timeout: 1000 }) @@ -134,7 +134,7 @@ test.describe('Sketch tests', () => { await page.waitForTimeout(600) // wait for animation - await page.getByText('tangentialArcTo([24.95, -5.38], %)').click() + await page.getByText('tangentialArcTo([24.95, -5.38], false, %)').click() await page.keyboard.press('End') await page.keyboard.down('Shift') await page.keyboard.press('ArrowUp') @@ -192,7 +192,7 @@ test.describe('Sketch tests', () => { `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%)` ) }) @@ -234,7 +234,7 @@ test.describe('Sketch tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%)`) } else { // Ensure we don't see the code. @@ -311,7 +311,7 @@ test.describe('Sketch tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([6.44, -12.07], %) |> line([14.72, 1.97], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> line([1.97, 2.06], %) |> close(%)`) } @@ -355,7 +355,7 @@ test.describe('Sketch tests', () => { `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%) |> extrude(5, %)` ) @@ -442,7 +442,7 @@ test.describe('Sketch tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([7.12, -16.82], %) |> line([15.4, -2.74], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> line([2.65, -2.69], %) |> close(%) |> extrude(5, %)`) @@ -459,7 +459,7 @@ test.describe('Sketch tests', () => { `const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> close(%) |> revolve({ axis: "X",}, %)` ) @@ -545,7 +545,7 @@ test.describe('Sketch tests', () => { .toHaveText(`const sketch001 = startSketchOn('XZ') |> startProfileAt([6.44, -12.07], %) |> line([14.72, 1.97], %) - |> tangentialArcTo([24.95, -5.38], %) + |> tangentialArcTo([24.95, -5.38], false, %) |> line([1.97, 2.06], %) |> close(%) |> revolve({ axis: "X" }, %)`) diff --git a/e2e/playwright/snapshot-tests.spec.ts b/e2e/playwright/snapshot-tests.spec.ts index 2273ccac8..a4f0771e9 100644 --- a/e2e/playwright/snapshot-tests.spec.ts +++ b/e2e/playwright/snapshot-tests.spec.ts @@ -570,7 +570,7 @@ test.describe( await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) code += ` - |> tangentialArcTo([21.7, -2.44], %)` + |> tangentialArcTo([21.7, -2.44], false, %)` await expect(u.codeLocator).toHaveText(code) // click tangential arc tool again to unequip it @@ -673,7 +673,7 @@ test.describe( await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) code += ` - |> tangentialArcTo([551.2, -62.01], %)` + |> tangentialArcTo([551.2, -62.01], false, %)` await expect(u.codeLocator).toHaveText(code) await page diff --git a/e2e/playwright/storageStates.ts b/e2e/playwright/storageStates.ts index 399d73b37..078309845 100644 --- a/e2e/playwright/storageStates.ts +++ b/e2e/playwright/storageStates.ts @@ -82,7 +82,7 @@ export const TEST_CODE_GIZMO = `const part001 = startSketchOn('XZ') intersectTag: a, offset: 0 }, %) -|> tangentialArcTo([13.14 + 0, 13.14], %) +|> tangentialArcTo([13.14 + 0, 13.14], false, %) |> close(%) |> extrude(5 + 7, %) ` diff --git a/e2e/playwright/testing-segment-overlays.spec.ts b/e2e/playwright/testing-segment-overlays.spec.ts index 90d6d4b3f..52281f9b1 100644 --- a/e2e/playwright/testing-segment-overlays.spec.ts +++ b/e2e/playwright/testing-segment-overlays.spec.ts @@ -200,7 +200,7 @@ test.describe('Testing segment overlays', () => { intersectTag: a, offset: 9 }, %) - |> tangentialArcTo([5 + 3.14 + 13, 20 + 3.14], %) + |> tangentialArcTo([5 + 3.14 + 13, 20 + 3.14], false, %) ` ) }) @@ -438,7 +438,7 @@ const part001 = startSketchOn('XZ') intersectTag: a, offset: 9 }, %) - |> tangentialArcTo([3.14 + 13, 3.14], %) + |> tangentialArcTo([3.14 + 13, 3.14], false, %) ` ) localStorage.setItem('disableAxis', 'true') @@ -566,7 +566,7 @@ const part001 = startSketchOn('XZ') intersectTag: a, offset: 9 }, %) - |> tangentialArcTo([3.14 + 13, 1.14], %) + |> tangentialArcTo([3.14 + 13, 1.14], false, %) ` ) localStorage.setItem('disableAxis', 'true') @@ -722,7 +722,7 @@ const part001 = startSketchOn('XZ') intersectTag: a, offset: 9 }, %) - |> tangentialArcTo([3.14 + 13, -3.14], %) + |> tangentialArcTo([3.14 + 13, -3.14], false, %) ` ) localStorage.setItem('disableAxis', 'true') @@ -755,9 +755,9 @@ const part001 = startSketchOn('XZ') await clickConstrained({ hoverPos: { x: tangentialArcTo.x, y: tangentialArcTo.y }, constraintType: 'xAbsolute', - expectBeforeUnconstrained: 'tangentialArcTo([3.14 + 13, -3.14], %)', - expectAfterUnconstrained: 'tangentialArcTo([16.14, -3.14], %)', - expectFinal: 'tangentialArcTo([xAbs001, -3.14], %)', + expectBeforeUnconstrained: 'tangentialArcTo([3.14 + 13, -3.14], false, %)', + expectAfterUnconstrained: 'tangentialArcTo([16.14, -3.14], false, %)', + expectFinal: 'tangentialArcTo([xAbs001, -3.14], false, %)', ang: ang + 180, steps: 6, locator: '[data-overlay-toolbar-index="12"]', @@ -766,9 +766,9 @@ const part001 = startSketchOn('XZ') await clickUnconstrained({ hoverPos: { x: tangentialArcTo.x, y: tangentialArcTo.y }, constraintType: 'yAbsolute', - expectBeforeUnconstrained: 'tangentialArcTo([xAbs001, -3.14], %)', - expectAfterUnconstrained: 'tangentialArcTo([xAbs001, yAbs001], %)', - expectFinal: 'tangentialArcTo([xAbs001, -3.14], %)', + expectBeforeUnconstrained: 'tangentialArcTo([xAbs001, -3.14], false, %)', + expectAfterUnconstrained: 'tangentialArcTo([xAbs001, yAbs001], false, %)', + expectFinal: 'tangentialArcTo([xAbs001, -3.14], false, %)', ang: ang + 180, steps: 10, locator: '[data-overlay-toolbar-index="12"]', @@ -835,7 +835,7 @@ const part001 = startSketchOn('XZ') intersectTag: a, offset: 9 }, %) - |> tangentialArcTo([3.14 + 13, 1.14], %) + |> tangentialArcTo([3.14 + 13, 1.14], false, %) ` ) localStorage.setItem('disableAxis', 'true') @@ -866,7 +866,7 @@ const part001 = startSketchOn('XZ') let ang = await u.getAngle(`[data-overlay-index="${12}"]`) await deleteSegmentSequence({ hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y }, - codeToBeDeleted: 'tangentialArcTo([3.14 + 13, 1.14], %)', + codeToBeDeleted: 'tangentialArcTo([3.14 + 13, 1.14], false, %)', stdLibFnName: 'tangentialArcTo', ang: ang + 180, steps: 6, diff --git a/e2e/playwright/testing-selections.spec.ts b/e2e/playwright/testing-selections.spec.ts index 54a856429..7451877c0 100644 --- a/e2e/playwright/testing-selections.spec.ts +++ b/e2e/playwright/testing-selections.spec.ts @@ -476,7 +476,7 @@ const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02) intersectTag: a, offset: 0 }, %) - |> tangentialArcTo([13.14 + 0, 13.14], %) + |> tangentialArcTo([13.14 + 0, 13.14], false, %) |> close(%) |> extrude(5 + 7, %) ` @@ -680,7 +680,7 @@ const extrude001 = extrude(10, sketch001)` }, { pos: [1107, 161], - expectedCode: 'tangentialArcTo([167.95, -28.85], %)', + expectedCode: 'tangentialArcTo([167.95, -28.85], false, %)', }, ] as const await page.addInitScript( diff --git a/src/lang/modifyAst.test.ts b/src/lang/modifyAst.test.ts index b196dfb9d..abbe9dfa2 100644 --- a/src/lang/modifyAst.test.ts +++ b/src/lang/modifyAst.test.ts @@ -584,7 +584,7 @@ describe('Testing removeSingleConstraintInfo', () => { intersectTag: a, offset: 0 + 0 }, %) - |> tangentialArcTo([3.14 + 0, 13.14 + 0], %)` + |> tangentialArcTo([3.14 + 0, 13.14 + 0], false, %)` test.each([ [' line([3 + 0, 4], %)', 'arrayIndex', 1], [ @@ -626,7 +626,7 @@ describe('Testing removeSingleConstraintInfo', () => { 'objectProperty', 'offset', ], - ['tangentialArcTo([3.14 + 0, 13.14], %)', 'arrayIndex', 1], + ['tangentialArcTo([3.14 + 0, 13.14], false, %)', 'arrayIndex', 1], ])('stdlib fn: %s', async (expectedFinish, key, value) => { const ast = parse(code) if (err(ast)) throw ast diff --git a/src/lang/modifyAst/addFillet.test.ts b/src/lang/modifyAst/addFillet.test.ts index 242ea72ff..ccdbbb0a2 100644 --- a/src/lang/modifyAst/addFillet.test.ts +++ b/src/lang/modifyAst/addFillet.test.ts @@ -82,8 +82,8 @@ describe('Testing addFillet', () => { |> line([60.04, -55.72], %) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -97,8 +97,8 @@ describe('Testing addFillet', () => { |> line([60.04, -55.72], %, $seg01) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -125,8 +125,8 @@ const extrude001 = extrude(50, sketch001) |> line([60.04, -55.72], %) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %, $seg01) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -140,8 +140,8 @@ const extrude001 = extrude(50, sketch001) |> line([60.04, -55.72], %, $seg02) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %, $seg01) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -168,8 +168,8 @@ const extrude001 = extrude(50, sketch001) |> line([60.04, -55.72], %) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %, $seg03) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -183,8 +183,8 @@ const extrude001 = extrude(50, sketch001) |> line([60.04, -55.72], %) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %, $seg03) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -210,8 +210,8 @@ const extrude001 = extrude(50, sketch001) |> line([60.04, -55.72], %) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %, $seg03) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) @@ -225,8 +225,8 @@ const extrude001 = extrude(50, sketch001) |> line([60.04, -55.72], %, $seg01) |> line([1.29, -115.74], %) |> line([-87.24, -47.08], %, $seg03) - |> tangentialArcTo([56.15, -94.58], %) - |> tangentialArcTo([14.68, -104.52], %) + |> tangentialArcTo([56.15, -94.58], false, %) + |> tangentialArcTo([14.68, -104.52], false, %) |> lineTo([profileStartX(%), profileStartY(%)], %) |> close(%) const extrude001 = extrude(50, sketch001) diff --git a/src/lang/std/sketch.test.ts b/src/lang/std/sketch.test.ts index e5735f4c8..a73159b77 100644 --- a/src/lang/std/sketch.test.ts +++ b/src/lang/std/sketch.test.ts @@ -270,7 +270,7 @@ describe('testing getConstraintInfo', () => { intersectTag: 'a', offset: 0 }, %) - |> tangentialArcTo([3.14, 13.14], %)` + |> tangentialArcTo([3.14, 13.14], false, %)` const ast = parse(code) test.each([ [ @@ -629,7 +629,7 @@ describe('testing getConstraintInfo', () => { intersectTag: 'a', offset: 0 }, %) - |> tangentialArcTo([3.14, 13.14], %)` + |> tangentialArcTo([3.14, 13.14], false, %)` const ast = parse(code) test.each([ [ @@ -783,7 +783,7 @@ describe('testing getConstraintInfo', () => { intersectTag: 'a', offset: 0 + 0 }, %) - |> tangentialArcTo([3.14 + 0, 13.14 + 0], %)` + |> tangentialArcTo([3.14 + 0, 13.14 + 0], false, %)` const ast = parse(code) test.each([ [ diff --git a/src/lang/std/sketch.ts b/src/lang/std/sketch.ts index e744a4861..434996e9d 100644 --- a/src/lang/std/sketch.ts +++ b/src/lang/std/sketch.ts @@ -811,6 +811,7 @@ export const tangentialArcTo: SketchLineHelper = { } const newLine = createCallExpression('tangentialArcTo', [ createArrayExpression([toX, toY]), + false, createPipeSubstitution(), ]) if (pipe.type === 'PipeExpression') { diff --git a/src/wasm-lib/kcl/src/parser/parser_impl.rs b/src/wasm-lib/kcl/src/parser/parser_impl.rs index 84c524a2b..e5f1f0ebc 100644 --- a/src/wasm-lib/kcl/src/parser/parser_impl.rs +++ b/src/wasm-lib/kcl/src/parser/parser_impl.rs @@ -3152,7 +3152,7 @@ mod snapshot_tests { a, r#"const boxSketch = startSketchAt([0, 0]) |> line([0, 10], %) - |> tangentialArc([-5, 5], %) + |> tangentialArcTo([-5, 5], true, %) |> line([5, -15], %) |> extrude(10, %) "#