Skip to content

Commit

Permalink
Update executor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers committed Dec 17, 2024
1 parent 74ea8e9 commit e99f814
Show file tree
Hide file tree
Showing 65 changed files with 2,466 additions and 2,389 deletions.
2 changes: 1 addition & 1 deletion src/wasm-lib/kcl/src/parsing/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,7 @@ my14 = 4 ^ 2 - 3 ^ 2 * 2
kw_function_decl_with_default_and_type,
r#"fn foo(x?: number = 2) { return 1 }"#
);
snapshot_test!(kw_function_to_draw_square, r#"val = 1 |> f(arg = x)"#);
snapshot_test!(kw_function_call_in_pipe, r#"val = 1 |> f(arg = x)"#);
}

#[allow(unused)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
source: kcl/src/parsing/parser.rs
expression: actual
snapshot_kind: text
---
{
"body": [
{
"declaration": {
"end": 107,
"end": 113,
"id": {
"end": 14,
"name": "cylinder",
Expand Down Expand Up @@ -122,18 +123,19 @@ expression: actual
{
"arguments": [
{
"end": 103,
"raw": "14",
"start": 101,
"type": "Literal",
"type": "Literal",
"value": 14.0
},
{
"end": 106,
"start": 105,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "length"
},
"arg": {
"end": 112,
"raw": "14",
"start": 110,
"type": "Literal",
"type": "Literal",
"value": 14.0
}
}
],
"callee": {
Expand All @@ -142,27 +144,28 @@ expression: actual
"start": 93,
"type": "Identifier"
},
"end": 107,
"end": 113,
"start": 93,
"type": "CallExpression",
"type": "CallExpression"
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"end": 107,
"end": 113,
"start": 17,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 6,
"type": "VariableDeclarator"
},
"end": 107,
"end": 113,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 108,
"end": 114,
"start": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
source: kcl/src/parsing/parser.rs
expression: actual
snapshot_kind: text
---
{
"body": [
{
"declaration": {
"end": 21,
"id": {
"end": 3,
"name": "val",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"end": 7,
"raw": "1",
"start": 6,
"type": "Literal",
"type": "Literal",
"value": 1.0
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "arg"
},
"arg": {
"end": 20,
"name": "x",
"start": 19,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"end": 12,
"name": "f",
"start": 11,
"type": "Identifier"
},
"end": 21,
"start": 11,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"end": 21,
"start": 6,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 21,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 21,
"start": 0
}
12 changes: 6 additions & 6 deletions src/wasm-lib/tests/executor/inputs/angled_line.kcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const part001 = startSketchOn('XY')
|> startProfileAt([4.83, 12.56], %)
|> line([15.1, 2.48], %)
|> line([3.15, -9.85], %, $seg01)
|> line([-15.17, -4.1], %)
|> line(to = [15.1, 2.48])
|> line(to = [3.15, -9.85], tag = $seg01)
|> line(to = [-15.17, -4.1])
|> angledLine([segAng(seg01), 12.35], %)
|> line([-13.02, 10.03], %)
|> close(%)
|> extrude(4, %)
|> line(to = [-13.02, 10.03])
|> close()
|> extrude(length = 4)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %)
|> line([0, -10], %, $thing2)
|> close(%, $thing3)
|> extrude(10, %)
|> line(to = [0, 10], tag = $thing)
|> line(to = [10, 0])
|> line(to = [0, -10], tag = $thing2)
|> close(tag = $thing3)
|> extrude(length = 10)
|> fillet({radius: 2, tags: [thing3, getOppositeEdge(thing3)]}, %)
10 changes: 5 additions & 5 deletions src/wasm-lib/tests/executor/inputs/basic_fillet_cube_end.kcl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %)
|> line([0, -10], %, $thing2)
|> close(%)
|> extrude(10, %)
|> line(to = [0, 10], tag = $thing)
|> line(to = [10, 0])
|> line(to = [0, -10], tag = $thing2)
|> close()
|> extrude(length = 10)
|> fillet({radius: 2, tags: [thing, getOppositeEdge(thing)]}, %)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %, $thing1)
|> line([0, -10], %, $thing2)
|> close(%, $thing3)
|> extrude(10, %)
|> line(to = [0, 10], tag = $thing)
|> line(to = [10, 0], tag = $thing1)
|> line(to = [0, -10], tag = $thing2)
|> close(tag = $thing3)
|> extrude(length = 10)
|> fillet({radius: 2, tags: [getNextAdjacentEdge(thing3)]}, %)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %, $thing1)
|> line([0, -10], %, $thing2)
|> close(%, $thing3)
|> extrude(10, %)
|> line(to = [0, 10], tag = $thing)
|> line(to = [10, 0], tag = $thing1)
|> line(to = [0, -10], tag = $thing2)
|> close(tag = $thing3)
|> extrude(length = 10)
|> fillet({radius: 2, tags: [getPreviousAdjacentEdge(thing3)]}, %)
10 changes: 5 additions & 5 deletions src/wasm-lib/tests/executor/inputs/basic_fillet_cube_start.kcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0,0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %)
|> line([0, -10], %, $thing2)
|> close(%)
|> extrude(10, %)
|> line(to = [0, 10], tag = $thing)
|> line(to = [10, 0])
|> line(to = [0, -10], tag = $thing2)
|> close()
|> extrude(length = 10)
|> fillet({radius: 2, tags: [thing, thing2]}, %)

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> line(to = [1, 3.82], tag = $seg01)
|> angledLineToX([
-angleToMatchLengthX(seg01, 3, %),
3
], %)
|> close(%)
|> extrude(10, %)
|> close()
|> extrude(length = 10)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> line(to = [1, 3.82], tag = $seg01)
|> angledLineToX([
-angleToMatchLengthY(seg01, 3, %),
3
], %)
|> close(%)
|> extrude(10, %)
|> close()
|> extrude(length = 10)
14 changes: 7 additions & 7 deletions src/wasm-lib/tests/executor/inputs/broken-code-test.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const filletR = 0.25
// Sketch the bracket and extrude with fillets
const bracket = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, wallMountL], %, 'outerEdge')
|> line([-shelfMountL, 0], %)
|> line([0, -thickness], %)
|> line([shelfMountL - thickness, 0], %, 'innerEdge')
|> line([0, -wallMountL + thickness], %)
|> close(%)
|> extrude(width, %)
|> line(to = [0, wallMountL], tag = 'outerEdge')
|> line(to = [-shelfMountL, 0])
|> line(to = [0, -thickness])
|> line(to = [shelfMountL - thickness, 0], tag = 'innerEdge')
|> line(to = [0, -wallMountL + thickness])
|> close()
|> extrude(length = width)
|> fillet({
radius: filletR,
tags: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0, 2], %)
|> line([3, 1], %)
|> line([0, -4], %)
|> close(%)
|> extrude(1, %)
|> line(to = [0, 2])
|> line(to = [3, 1])
|> line(to = [0, -4])
|> close()
|> extrude(length = 1)

pattn1 = patternLinear3d({
axis: [1, 0, 0],
Expand Down
4 changes: 2 additions & 2 deletions src/wasm-lib/tests/executor/inputs/close_arc.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const height = 3
const body = startSketchOn('XY')
|> startProfileAt([center[0]+radius, center[1]], %)
|> arc({angle_end: 360, angle_start: 0, radius: radius}, %)
|> close(%)
|> extrude(height, %)
|> close()
|> extrude(length = height)
12 changes: 6 additions & 6 deletions src/wasm-lib/tests/executor/inputs/cube.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ fn cube(length, center) {
p3 = [ l + x, -l + y]

return startSketchAt(p0)
|> lineTo(p1, %)
|> lineTo(p2, %)
|> lineTo(p3, %)
|> lineTo(p0, %)
|> close(%)
|> extrude(length, %)
|> line(end = p1)
|> line(end = p2)
|> line(end = p3)
|> line(end = p0)
|> close()
|> extrude(length = length)
}

myCube = cube(40, [0,0])
2 changes: 1 addition & 1 deletion src/wasm-lib/tests/executor/inputs/cylinder.kcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const cylinder = startSketchOn('XY')
|> circle({ center: [0, 0], radius: 22 }, %)
|> extrude(14, %)
|> extrude(length = 14)
10 changes: 5 additions & 5 deletions src/wasm-lib/tests/executor/inputs/dimensions_match.kcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const part001 = startSketchOn('XY')
|> startProfileAt([-10, -10], %)
|> line([20, 0], %)
|> line([0, 20], %)
|> line([-20, 0], %)
|> close(%)
|> extrude(10, %)
|> line(to = [20, 0])
|> line(to = [0, 20])
|> line(to = [-20, 0])
|> close()
|> extrude(length = 10)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const sketch001 = startSketchOn('XZ')
|> startProfileAt([75.8, 317.2], %)
|> angledLine([0, 268.43], %, $rectangleSegmentA001)
|> angledline(to = [0, 268.43], tag = $rectangleSegmentA001)
|> angledLine([
segAng(rectangleSegmentA001) - 90,
217.26
Expand All @@ -9,9 +9,9 @@ const sketch001 = startSketchOn('XZ')
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %, $yo)
|> lineTo([profileStartX(%), profileStartY(%)], %, $seg02)
|> close(%)
const extrude001 = extrude(100, sketch001)
|> line(end = [profileStartX(%), profileStartY(%)])
|> close()
const extrude001 = extrude(sketch001, length = 100)
const chamf = chamfer({
length: 30,
tags: [
Expand Down
Loading

0 comments on commit e99f814

Please sign in to comment.