add Parallel helper (#60)

This commit is contained in:
Kurt Hutten
2023-03-15 08:15:01 +11:00
committed by GitHub
parent 1de21b8bdd
commit d31ff80a19
6 changed files with 98 additions and 2 deletions

26
src/lang/std/std.test.ts Normal file
View File

@ -0,0 +1,26 @@
import { abstractSyntaxTree } from '../abstractSyntaxTree'
import { executor } from '../executor'
import { lexer } from '../tokeniser'
import { initPromise } from '../rust'
beforeAll(() => initPromise)
describe('testing angledLineThatIntersects', () => {
it('angledLineThatIntersects should intersect with another line', () => {
const code = (offset: string) => `const part001 = startSketchAt([0, 0])
|> lineTo({to:[2, 2], tag: "yo"}, %)
|> lineTo([3, 1], %)
|> angledLineThatIntersects({
angle: 180,
intersectTag: 'yo',
offset: ${offset},
tag: "yo2"
}, %)
const intersect = segEndX('yo2', part001)
show(part001)`
const { root } = executor(abstractSyntaxTree(lexer(code('-1'))))
expect(root.intersect.value).toBe(1 + Math.sqrt(2))
const { root: noOffset } = executor(abstractSyntaxTree(lexer(code('0'))))
expect(noOffset.intersect.value).toBeCloseTo(1)
})
})