Fix test 'should recognize that sketch001 has been extruded'

This commit is contained in:
Adam Chalmers
2025-01-14 11:10:27 -06:00
committed by Nick Cameron
parent 81e2fd201d
commit ff71250d5d
2 changed files with 22 additions and 5 deletions

View File

@ -585,7 +585,7 @@ sketch002 = startSketchOn(plane001)
const extrudable = doesSceneHaveSweepableSketch(ast, 2)
expect(extrudable).toBeTruthy()
})
it('find sketch002 NOT pipe to be extruded', async () => {
it('should recognize that sketch001 has been extruded', async () => {
const exampleCode = `sketch001 = startSketchOn('XZ')
|> startProfileAt([3.29, 7.86], %)
|> line(end = [2.48, 2.44])

View File

@ -1002,21 +1002,31 @@ export function doesSceneHaveSweepableSketch(ast: Node<Program>, count = 1) {
let hasCircle = false
for (const pipe of node.init.body) {
if (
pipe.type === 'CallExpression' &&
(pipe.type === 'CallExpressionKw' ||
pipe.type === 'CallExpression') &&
pipe.callee.name === 'startProfileAt'
) {
hasStartProfileAt = true
}
if (
pipe.type === 'CallExpression' &&
(pipe.type === 'CallExpressionKw' ||
pipe.type === 'CallExpression') &&
pipe.callee.name === 'startSketchOn'
) {
hasStartSketchOn = true
}
if (pipe.type === 'CallExpression' && pipe.callee.name === 'close') {
if (
(pipe.type === 'CallExpressionKw' ||
pipe.type === 'CallExpression') &&
pipe.callee.name === 'close'
) {
hasClose = true
}
if (pipe.type === 'CallExpression' && pipe.callee.name === 'circle') {
if (
(pipe.type === 'CallExpressionKw' ||
pipe.type === 'CallExpression') &&
pipe.callee.name === 'circle'
) {
hasCircle = true
}
}
@ -1034,6 +1044,13 @@ export function doesSceneHaveSweepableSketch(ast: Node<Program>, count = 1) {
theMap?.[node?.arguments?.[1]?.name]
) {
delete theMap[node.arguments[1].name]
} else if (
node.type === 'CallExpressionKw' &&
(node.callee.name === 'extrude' || node.callee.name === 'revolve') &&
node.unlabeled?.type === 'Identifier' &&
theMap?.[node?.unlabeled?.name]
) {
delete theMap[node.unlabeled.name]
}
},
})