2023-09-29 11:11:01 -07:00
|
|
|
import { parse, initPromise } from '../wasm'
|
2023-07-10 15:15:07 +10:00
|
|
|
import { enginelessExecutor } from '../../lib/testHelpers'
|
2023-03-15 08:15:01 +11:00
|
|
|
|
2024-04-19 14:24:40 -07:00
|
|
|
beforeAll(async () => {
|
|
|
|
await initPromise
|
|
|
|
})
|
2023-03-15 08:15:01 +11:00
|
|
|
|
|
|
|
describe('testing angledLineThatIntersects', () => {
|
2023-06-22 16:43:33 +10:00
|
|
|
it('angledLineThatIntersects should intersect with another line', async () => {
|
2024-10-02 14:19:40 -05:00
|
|
|
const code = (offset: string) => `part001 = startSketchOn('XY')
|
2023-10-05 14:27:48 -07:00
|
|
|
|> startProfileAt([0, 0], %)
|
2024-07-27 17:59:41 -07:00
|
|
|
|> lineTo([2, 2], %, $yo)
|
2023-03-15 08:15:01 +11:00
|
|
|
|> lineTo([3, 1], %)
|
|
|
|
|> angledLineThatIntersects({
|
|
|
|
angle: 180,
|
2024-07-27 17:59:41 -07:00
|
|
|
intersectTag: yo,
|
2023-03-15 08:15:01 +11:00
|
|
|
offset: ${offset},
|
2024-07-27 17:59:41 -07:00
|
|
|
}, %, $yo2)
|
2024-10-02 14:19:40 -05:00
|
|
|
intersect = segEndX(yo2)`
|
2024-10-09 19:38:40 -04:00
|
|
|
const execState = await enginelessExecutor(parse(code('-1')))
|
|
|
|
expect(execState.memory.get('intersect')?.value).toBe(1 + Math.sqrt(2))
|
2024-07-22 19:43:40 -04:00
|
|
|
const noOffset = await enginelessExecutor(parse(code('0')))
|
2024-10-09 19:38:40 -04:00
|
|
|
expect(noOffset.memory.get('intersect')?.value).toBeCloseTo(1)
|
2023-03-15 08:15:01 +11:00
|
|
|
})
|
|
|
|
})
|