Compare commits

...

1 Commits

Author SHA1 Message Date
083103144a add test
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-05-20 11:04:53 -07:00
14 changed files with 370 additions and 0 deletions

View File

@ -3360,3 +3360,24 @@ mod nested_windows_main_kcl {
super::execute(TEST_NAME, true).await super::execute(TEST_NAME, true).await
} }
} }
mod nested_assembly {
const TEST_NAME: &str = "nested_assembly";
/// Test parsing KCL.
#[test]
fn parse() {
super::parse(TEST_NAME)
}
/// Test that parsing and unparsing KCL produces the original KCL input.
#[tokio::test(flavor = "multi_thread")]
async fn unparse() {
super::unparse(TEST_NAME).await
}
/// Test that KCL is executed correctly.
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_execute() {
super::execute(TEST_NAME, true).await
}
}

View File

@ -0,0 +1,184 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact commands nested_main_kcl.kcl
---
[
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "edge_lines_visible",
"hidden": false
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_visible",
"object_id": "[uuid]",
"hidden": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "make_plane",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"x_axis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"y_axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"size": 60.0,
"clobber": false,
"hide": true
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "close_path",
"path_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "enable_sketch_mode",
"entity_id": "[uuid]",
"ortho": false,
"animated": false,
"adjust_camera": false,
"planar_normal": {
"x": 0.0,
"y": 0.0,
"z": 1.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "extend_path",
"path": "[uuid]",
"segment": {
"type": "arc",
"center": {
"x": 15.0,
"y": 0.0
},
"radius": 5.0,
"start": {
"unit": "degrees",
"value": 0.0
},
"end": {
"unit": "degrees",
"value": 360.0
},
"relative": false
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "move_path_pen",
"path": "[uuid]",
"to": {
"x": 20.0,
"y": 0.0,
"z": 0.0
}
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "sketch_mode_disable"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "start_path"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "object_bring_to_front",
"object_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "revolve",
"target": "[uuid]",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"axis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"axis_is_2d": true,
"angle": {
"unit": "degrees",
"value": 360.0
},
"tolerance": 0.0000001,
"opposite": "None"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_get_adjacency_info",
"object_id": "[uuid]",
"edge_id": "[uuid]"
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_get_extrusion_face_info",
"object_id": "[uuid]",
"edge_id": "[uuid]"
}
}
]

View File

@ -0,0 +1,6 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Artifact graph flowchart nested_main_kcl.kcl
extension: md
snapshot_kind: binary
---

View File

@ -0,0 +1,23 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[43, 81, 1]"]
3["Segment<br>[43, 81, 1]"]
4[Solid2d]
end
1["Plane<br>[18, 35, 1]"]
5["Sweep Revolve<br>[89, 142, 1]"]
6[Wall]
%% face_code_ref=Missing NodePath
7["SweepEdge Adjacent"]
1 --- 2
2 --- 3
2 --- 4
2 ---- 5
5 <--x 3
3 --- 6
3 --- 7
5 --- 6
5 --- 7
6 --- 7
```

View File

@ -0,0 +1,73 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing nested_main_kcl.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 0,
"end": 0,
"path": {
"type": "Kcl",
"filename": "nested/foo/bar/main.kcl"
},
"selector": {
"type": "None",
"alias": {
"commentStart": 0,
"end": 0,
"name": "bar",
"start": 0,
"type": "Identifier"
}
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 0,
"end": 0,
"expression": {
"abs_path": false,
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 0,
"end": 0,
"name": "bar",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 0,
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"commentStart": 0,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": []
},
"start": 0
}
}

View File

@ -0,0 +1,3 @@
import "nested/foo/bar/main.kcl" as bar
bar

View File

@ -0,0 +1,7 @@
// A donut shape.
startSketchOn(XY)
|> circle( center = [15, 0], radius = 5 )
|> revolve(
angle = 360,
axis = Y,
)

View File

@ -0,0 +1,3 @@
import "imported.kcl" as imported
imported

View File

@ -0,0 +1,18 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Operations executed nested_main_kcl.kcl
---
[
{
"type": "GroupBegin",
"group": {
"type": "ModuleInstance",
"name": "main.kcl",
"moduleId": 0
},
"sourceRange": []
},
{
"type": "GroupEnd"
}
]

View File

@ -0,0 +1,10 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Variables in memory after executing nested_main_kcl.kcl
---
{
"bar": {
"type": "Module",
"value": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

View File

@ -0,0 +1,7 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing nested_main_kcl.kcl
---
import "nested/foo/bar/main.kcl" as bar
bar

View File

@ -0,0 +1,8 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing tests/nested_assembly/nested/foo/bar/imported.kcl
---
// A donut shape.
startSketchOn(XY)
|> circle(center = [15, 0], radius = 5)
|> revolve(angle = 360, axis = Y)

View File

@ -0,0 +1,7 @@
---
source: kcl-lib/src/simulation_tests.rs
description: Result of unparsing tests/nested_assembly/nested/foo/bar/main.kcl
---
import "imported.kcl" as imported
imported