Move KCL tests into files (#3169)
This commit is contained in:
@ -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]}, %)
|
15
src/wasm-lib/tests/executor/inputs/sketch_on_face.kcl
Normal file
15
src/wasm-lib/tests/executor/inputs/sketch_on_face.kcl
Normal file
@ -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, %)
|
20
src/wasm-lib/tests/executor/inputs/sketch_on_face_end.kcl
Normal file
20
src/wasm-lib/tests/executor/inputs/sketch_on_face_end.kcl
Normal file
@ -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, %)
|
@ -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, %)
|
20
src/wasm-lib/tests/executor/inputs/sketch_on_face_start.kcl
Normal file
20
src/wasm-lib/tests/executor/inputs/sketch_on_face_start.kcl
Normal file
@ -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, %)
|
@ -69,22 +69,7 @@ async fn execute_and_snapshot(code: &str, units: UnitLength) -> Result<image::Dy
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn serial_test_sketch_on_face() {
|
async fn serial_test_sketch_on_face() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = include_str!("inputs/sketch_on_face.kcl");
|
||||||
|> 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 result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||||
twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face.png", &result, MIN_DIFF);
|
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")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn serial_test_sketch_on_face_start() {
|
async fn serial_test_sketch_on_face_start() {
|
||||||
let code = r#"fn cube = (pos, scale) => {
|
let code = include_str!("inputs/sketch_on_face_start.kcl");
|
||||||
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 result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
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);
|
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")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn serial_test_sketch_on_face_end() {
|
async fn serial_test_sketch_on_face_end() {
|
||||||
let code = r#"fn cube = (pos, scale) => {
|
let code = include_str!("inputs/sketch_on_face_end.kcl");
|
||||||
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 result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
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);
|
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")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn serial_test_sketch_on_face_end_negative_extrude() {
|
async fn serial_test_sketch_on_face_end_negative_extrude() {
|
||||||
let code = r#"fn cube = (pos, scale) => {
|
let code = include_str!("inputs/sketch_on_face_end_negative_extrude.kcl");
|
||||||
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 result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
@ -216,15 +141,7 @@ const part002 = startSketchOn(part001, "END")
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn serial_test_fillet_duplicate_tags() {
|
async fn serial_test_fillet_duplicate_tags() {
|
||||||
let code = r#"const part001 = startSketchOn('XY')
|
let code = include_str!("inputs/fillet_duplicate_tags.kcl");
|
||||||
|> 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 result = execute_and_snapshot(code, UnitLength::Mm).await;
|
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
Reference in New Issue
Block a user