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:
@ -163,25 +163,25 @@ describe('Testing giveSketchFnCallTag', () => {
|
||||
code,
|
||||
'line([0, 0.83], %)'
|
||||
)
|
||||
expect(newCode).toContain("line([0, 0.83], %, 'seg01')")
|
||||
expect(newCode).toContain('line([0, 0.83], %, $seg01)')
|
||||
expect(tag).toBe('seg01')
|
||||
expect(isTagExisting).toBe(false)
|
||||
})
|
||||
it('Should create a unique tag if seg01 already exists', () => {
|
||||
let _code = code.replace(
|
||||
'line([-2.57, -0.13], %)',
|
||||
"line([-2.57, -0.13], %, 'seg01')"
|
||||
'line([-2.57, -0.13], %, $seg01)'
|
||||
)
|
||||
const { newCode, tag, isTagExisting } = giveSketchFnCallTagTestHelper(
|
||||
_code,
|
||||
'line([0, 0.83], %)'
|
||||
)
|
||||
expect(newCode).toContain("line([0, 0.83], %, 'seg02')")
|
||||
expect(newCode).toContain('line([0, 0.83], %, $seg02)')
|
||||
expect(tag).toBe('seg02')
|
||||
expect(isTagExisting).toBe(false)
|
||||
})
|
||||
it('Should return existing tag if it already exists', () => {
|
||||
const lineButWithTag = "line([-2.57, -0.13], %, 'butts')"
|
||||
const lineButWithTag = 'line([-2.57, -0.13], %, $butts)'
|
||||
let _code = code.replace('line([-2.57, -0.13], %)', lineButWithTag)
|
||||
const { newCode, tag, isTagExisting } = giveSketchFnCallTagTestHelper(
|
||||
_code,
|
||||
@ -328,11 +328,11 @@ describe('testing sketchOnExtrudedFace', () => {
|
||||
const newCode = recast(modifiedAst)
|
||||
expect(newCode).toContain(`const part001 = startSketchOn('-XZ')
|
||||
|> startProfileAt([3.58, 2.06], %)
|
||||
|> line([9.7, 9.19], %, 'seg01')
|
||||
|> line([9.7, 9.19], %, $seg01)
|
||||
|> line([8.62, -9.57], %)
|
||||
|> close(%)
|
||||
|> extrude(5 + 7, %)
|
||||
const sketch001 = startSketchOn(part001, 'seg01')`)
|
||||
const sketch001 = startSketchOn(part001, seg01)`)
|
||||
})
|
||||
test('it should be able to extrude on close segments', async () => {
|
||||
const code = `const part001 = startSketchOn('-XZ')
|
||||
@ -371,9 +371,9 @@ const sketch001 = startSketchOn(part001, 'seg01')`)
|
||||
|> startProfileAt([3.58, 2.06], %)
|
||||
|> line([9.7, 9.19], %)
|
||||
|> line([8.62, -9.57], %)
|
||||
|> close(%, 'seg01')
|
||||
|> close(%, $seg01)
|
||||
|> extrude(5 + 7, %)
|
||||
const sketch001 = startSketchOn(part001, 'seg01')`)
|
||||
const sketch001 = startSketchOn(part001, seg01)`)
|
||||
})
|
||||
test('it should be able to extrude on start-end caps', async () => {
|
||||
const code = `const part001 = startSketchOn('-XZ')
|
||||
@ -457,7 +457,7 @@ const sketch001 = startSketchOn(part001, 'END')`)
|
||||
if (err(updatedAst)) throw updatedAst
|
||||
const newCode = recast(updatedAst.modifiedAst)
|
||||
expect(newCode).toContain(`const part001 = extrude(5 + 7, sketch001)
|
||||
const sketch002 = startSketchOn(part001, 'seg01')`)
|
||||
const sketch002 = startSketchOn(part001, seg01)`)
|
||||
})
|
||||
})
|
||||
|
||||
@ -499,49 +499,49 @@ describe('Testing deleteSegmentFromPipeExpression', () => {
|
||||
replace2 = ''
|
||||
) => `const part001 = startSketchOn('-XZ')
|
||||
|> startProfileAt([54.78, -95.91], %)
|
||||
|> line([306.21, 198.82], %, 'b')
|
||||
|> line([306.21, 198.82], %, $b)
|
||||
${!replace1 ? ` |> ${line}\n` : ''} |> angledLine([-65, ${
|
||||
!replace1 ? "segLen('a', %)" : replace1
|
||||
!replace1 ? 'segLen(a, %)' : replace1
|
||||
}], %)
|
||||
|> line([306.21, 198.87], %)
|
||||
|> angledLine([65, ${!replace2 ? "segAng('a', %)" : replace2}], %)
|
||||
|> angledLine([65, ${!replace2 ? 'segAng(a, %)' : replace2}], %)
|
||||
|> line([-963.39, -154.67], %)
|
||||
`
|
||||
test.each([
|
||||
['line', "line([306.21, 198.85], %, 'a')", ['365.11', '33']],
|
||||
['lineTo', "lineTo([306.21, 198.85], %, 'a')", ['110.48', '119.73']],
|
||||
['yLine', "yLine(198.85, %, 'a')", ['198.85', '90']],
|
||||
['xLine', "xLine(198.85, %, 'a')", ['198.85', '0']],
|
||||
['yLineTo', "yLineTo(198.85, %, 'a')", ['95.94', '90']],
|
||||
['xLineTo', "xLineTo(198.85, %, 'a')", ['162.14', '180']],
|
||||
['line', 'line([306.21, 198.85], %, $a)', ['365.11', '33']],
|
||||
['lineTo', 'lineTo([306.21, 198.85], %, $a)', ['110.48', '119.73']],
|
||||
['yLine', 'yLine(198.85, %, $a)', ['198.85', '90']],
|
||||
['xLine', 'xLine(198.85, %, $a)', ['198.85', '0']],
|
||||
['yLineTo', 'yLineTo(198.85, %, $a)', ['95.94', '90']],
|
||||
['xLineTo', 'xLineTo(198.85, %, $a)', ['162.14', '180']],
|
||||
[
|
||||
'angledLine',
|
||||
"angledLine({ angle: 45.5, length: 198.85 }, %, 'a')",
|
||||
'angledLine({ angle: 45.5, length: 198.85 }, %, $a)',
|
||||
['198.85', '45.5'],
|
||||
],
|
||||
[
|
||||
'angledLineOfXLength',
|
||||
"angledLineOfXLength({ angle: 45.5, length: 198.85 }, %, 'a')",
|
||||
'angledLineOfXLength({ angle: 45.5, length: 198.85 }, %, $a)',
|
||||
['283.7', '45.5'],
|
||||
],
|
||||
[
|
||||
'angledLineOfYLength',
|
||||
"angledLineOfYLength({ angle: 45.5, length: 198.85 }, %, 'a')",
|
||||
'angledLineOfYLength({ angle: 45.5, length: 198.85 }, %, $a)',
|
||||
['278.79', '45.5'],
|
||||
],
|
||||
[
|
||||
'angledLineToX',
|
||||
"angledLineToX({ angle: 45.5, to: 198.85 }, %, 'a')",
|
||||
'angledLineToX({ angle: 45.5, to: 198.85 }, %, $a)',
|
||||
['231.33', '134.5'],
|
||||
],
|
||||
[
|
||||
'angledLineToY',
|
||||
"angledLineToY({ angle: 45.5, to: 198.85 }, %, 'a')",
|
||||
'angledLineToY({ angle: 45.5, to: 198.85 }, %, $a)',
|
||||
['134.51', '45.5'],
|
||||
],
|
||||
[
|
||||
'angledLineThatIntersects',
|
||||
`angledLineThatIntersects({ angle: 45.5, intersectTag: 'b', offset: 198.85 }, %, 'a')`,
|
||||
`angledLineThatIntersects({ angle: 45.5, intersectTag: b, offset: 198.85 }, %, $a)`,
|
||||
['918.4', '45.5'],
|
||||
],
|
||||
])(`%s`, async (_, line, [replace1, replace2]) => {
|
||||
@ -579,7 +579,7 @@ describe('Testing removeSingleConstraintInfo', () => {
|
||||
|> lineTo([6.14 + 0, 3.14 + 0], %)
|
||||
|> xLineTo(8 + 0, %)
|
||||
|> yLineTo(5 + 0, %)
|
||||
|> yLine(3.14 + 0, %, 'a')
|
||||
|> yLine(3.14 + 0, %, $a)
|
||||
|> xLine(3.14 + 0, %)
|
||||
|> angledLineOfXLength({ angle: 3 + 0, length: 3.14 + 0 }, %)
|
||||
|> angledLineOfYLength({ angle: 30 + 0, length: 3 + 0 }, %)
|
||||
@ -587,7 +587,7 @@ describe('Testing removeSingleConstraintInfo', () => {
|
||||
|> angledLineToY({ angle: 30 + 0, to: 10.14 + 0 }, %)
|
||||
|> angledLineThatIntersects({
|
||||
angle: 3.14 + 0,
|
||||
intersectTag: 'a',
|
||||
intersectTag: a,
|
||||
offset: 0 + 0
|
||||
}, %)
|
||||
|> tangentialArcTo([3.14 + 0, 13.14 + 0], %)`
|
||||
@ -601,7 +601,7 @@ describe('Testing removeSingleConstraintInfo', () => {
|
||||
['lineTo([6.14, 3.14 + 0], %)', 'arrayIndex', 0],
|
||||
['xLineTo(8, %)', '', ''],
|
||||
['yLineTo(5, %)', '', ''],
|
||||
["yLine(3.14, %, 'a')", '', ''],
|
||||
['yLine(3.14, %, $a)', '', ''],
|
||||
['xLine(3.14, %)', '', ''],
|
||||
[
|
||||
'angledLineOfXLength({ angle: 3, length: 3.14 + 0 }, %)',
|
||||
@ -627,7 +627,7 @@ describe('Testing removeSingleConstraintInfo', () => {
|
||||
`angledLineThatIntersects({
|
||||
angle: 3.14 + 0,
|
||||
offset: 0,
|
||||
intersectTag: 'a'
|
||||
intersectTag: a
|
||||
}, %)`,
|
||||
'objectProperty',
|
||||
'offset',
|
||||
|
Reference in New Issue
Block a user