diff --git a/src/wasm-lib/tests/executor/inputs/fillet_duplicate_tags.kcl b/src/wasm-lib/tests/executor/inputs/fillet_duplicate_tags.kcl new file mode 100644 index 000000000..d8a5e75f6 --- /dev/null +++ b/src/wasm-lib/tests/executor/inputs/fillet_duplicate_tags.kcl @@ -0,0 +1,8 @@ +const part001 = startSketchOn('XY') + |> startProfileAt([0,0], %) + |> line([0, 10], %, $thing) + |> line([10, 0], %) + |> line([0, -10], %, $thing2) + |> close(%) + |> extrude(10, %) + |> fillet({radius: 0.5, tags: [thing, thing]}, %) diff --git a/src/wasm-lib/tests/executor/inputs/sketch_on_face.kcl b/src/wasm-lib/tests/executor/inputs/sketch_on_face.kcl new file mode 100644 index 000000000..344636a24 --- /dev/null +++ b/src/wasm-lib/tests/executor/inputs/sketch_on_face.kcl @@ -0,0 +1,15 @@ +const part001 = startSketchOn('XY') + |> startProfileAt([11.19, 28.35], %) + |> line([28.67, -13.25], %, $here) + |> line([-4.12, -22.81], %) + |> line([-33.24, 14.55], %) + |> close(%) + |> extrude(5, %) + +const part002 = startSketchOn(part001, here) + |> startProfileAt([0, 0], %) + |> line([0, 10], %) + |> line([10, 0], %) + |> line([0, -10], %) + |> close(%) + |> extrude(5, %) diff --git a/src/wasm-lib/tests/executor/inputs/sketch_on_face_end.kcl b/src/wasm-lib/tests/executor/inputs/sketch_on_face_end.kcl new file mode 100644 index 000000000..26d8e96fd --- /dev/null +++ b/src/wasm-lib/tests/executor/inputs/sketch_on_face_end.kcl @@ -0,0 +1,20 @@ +fn cube = (pos, scale) => { + const sg = startSketchOn('XY') + |> startProfileAt(pos, %) + |> line([0, scale], %) + |> line([scale, 0], %) + |> line([0, -scale], %) + + return sg +} +const part001 = cube([0,0], 20) + |> close(%) + |> extrude(20, %) + +const part002 = startSketchOn(part001, "END") + |> startProfileAt([0, 0], %) + |> line([0, 10], %) + |> line([10, 0], %) + |> line([0, -10], %) + |> close(%) + |> extrude(5, %) diff --git a/src/wasm-lib/tests/executor/inputs/sketch_on_face_end_negative_extrude.kcl b/src/wasm-lib/tests/executor/inputs/sketch_on_face_end_negative_extrude.kcl new file mode 100644 index 000000000..abad043c8 --- /dev/null +++ b/src/wasm-lib/tests/executor/inputs/sketch_on_face_end_negative_extrude.kcl @@ -0,0 +1,20 @@ +fn cube = (pos, scale) => { + const sg = startSketchOn('XY') + |> startProfileAt(pos, %) + |> line([0, scale], %) + |> line([scale, 0], %) + |> line([0, -scale], %) + + return sg +} +const part001 = cube([0,0], 20) + |> close(%) + |> extrude(20, %) + +const part002 = startSketchOn(part001, "END") + |> startProfileAt([0, 0], %) + |> line([0, 10], %) + |> line([10, 0], %) + |> line([0, -10], %) + |> close(%) + |> extrude(-5, %) diff --git a/src/wasm-lib/tests/executor/inputs/sketch_on_face_start.kcl b/src/wasm-lib/tests/executor/inputs/sketch_on_face_start.kcl new file mode 100644 index 000000000..f6236adea --- /dev/null +++ b/src/wasm-lib/tests/executor/inputs/sketch_on_face_start.kcl @@ -0,0 +1,20 @@ +fn cube = (pos, scale) => { + const sg = startSketchOn('XY') + |> startProfileAt(pos, %) + |> line([0, scale], %) + |> line([scale, 0], %) + |> line([0, -scale], %) + + return sg +} +const part001 = cube([0,0], 20) + |> close(%) + |> extrude(20, %) + +const part002 = startSketchOn(part001, "start") + |> startProfileAt([0, 0], %) + |> line([0, 10], %) + |> line([10, 0], %) + |> line([0, -10], %) + |> close(%) + |> extrude(5, %) diff --git a/src/wasm-lib/tests/executor/main.rs b/src/wasm-lib/tests/executor/main.rs index 452e544a8..599166b84 100644 --- a/src/wasm-lib/tests/executor/main.rs +++ b/src/wasm-lib/tests/executor/main.rs @@ -69,22 +69,7 @@ async fn execute_and_snapshot(code: &str, units: UnitLength) -> Result startProfileAt([11.19, 28.35], %) - |> line([28.67, -13.25], %, $here) - |> line([-4.12, -22.81], %) - |> line([-33.24, 14.55], %) - |> close(%) - |> extrude(5, %) - -const part002 = startSketchOn(part001, here) - |> startProfileAt([0, 0], %) - |> line([0, 10], %) - |> line([10, 0], %) - |> line([0, -10], %) - |> close(%) - |> extrude(5, %) -"#; + let code = include_str!("inputs/sketch_on_face.kcl"); let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap(); twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face.png", &result, MIN_DIFF); @@ -121,27 +106,7 @@ async fn serial_test_pentagon_fillet_sugar() { #[tokio::test(flavor = "multi_thread")] async fn serial_test_sketch_on_face_start() { - let code = r#"fn cube = (pos, scale) => { - const sg = startSketchOn('XY') - |> startProfileAt(pos, %) - |> line([0, scale], %) - |> line([scale, 0], %) - |> line([0, -scale], %) - - return sg -} -const part001 = cube([0,0], 20) - |> close(%) - |> extrude(20, %) - -const part002 = startSketchOn(part001, "start") - |> startProfileAt([0, 0], %) - |> line([0, 10], %) - |> line([10, 0], %) - |> line([0, -10], %) - |> close(%) - |> extrude(5, %) -"#; + let code = include_str!("inputs/sketch_on_face_start.kcl"); let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap(); twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face_start.png", &result, MIN_DIFF); @@ -156,27 +121,7 @@ async fn serial_test_mike_stress_lines() { #[tokio::test(flavor = "multi_thread")] async fn serial_test_sketch_on_face_end() { - let code = r#"fn cube = (pos, scale) => { - const sg = startSketchOn('XY') - |> startProfileAt(pos, %) - |> line([0, scale], %) - |> line([scale, 0], %) - |> line([0, -scale], %) - - return sg -} -const part001 = cube([0,0], 20) - |> close(%) - |> extrude(20, %) - -const part002 = startSketchOn(part001, "END") - |> startProfileAt([0, 0], %) - |> line([0, 10], %) - |> line([10, 0], %) - |> line([0, -10], %) - |> close(%) - |> extrude(5, %) -"#; + let code = include_str!("inputs/sketch_on_face_end.kcl"); let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap(); twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face_end.png", &result, MIN_DIFF); @@ -184,27 +129,7 @@ const part002 = startSketchOn(part001, "END") #[tokio::test(flavor = "multi_thread")] async fn serial_test_sketch_on_face_end_negative_extrude() { - let code = r#"fn cube = (pos, scale) => { - const sg = startSketchOn('XY') - |> startProfileAt(pos, %) - |> line([0, scale], %) - |> line([scale, 0], %) - |> line([0, -scale], %) - - return sg -} -const part001 = cube([0,0], 20) - |> close(%) - |> extrude(20, %) - -const part002 = startSketchOn(part001, "END") - |> startProfileAt([0, 0], %) - |> line([0, 10], %) - |> line([10, 0], %) - |> line([0, -10], %) - |> close(%) - |> extrude(-5, %) -"#; + let code = include_str!("inputs/sketch_on_face_end_negative_extrude.kcl"); let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap(); twenty_twenty::assert_image( @@ -216,15 +141,7 @@ const part002 = startSketchOn(part001, "END") #[tokio::test(flavor = "multi_thread")] async fn serial_test_fillet_duplicate_tags() { - let code = r#"const part001 = startSketchOn('XY') - |> startProfileAt([0,0], %) - |> line([0, 10], %, $thing) - |> line([10, 0], %) - |> line([0, -10], %, $thing2) - |> close(%) - |> extrude(10, %) - |> fillet({radius: 0.5, tags: [thing, thing]}, %) -"#; + let code = include_str!("inputs/fillet_duplicate_tags.kcl"); let result = execute_and_snapshot(code, UnitLength::Mm).await; assert!(result.is_err());