Skip to content

Commit

Permalink
Move KCL from Rust strings into files (#3467)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers authored Aug 15, 2024
1 parent 8f9bef9 commit 4fd5e26
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> angledLineToX([
-angleToMatchLengthX(seg01, 3, %),
3
], %)
|> close(%)
|> extrude(10, %)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> angledLineToX([
-angleToMatchLengthY(seg01, 3, %),
3
], %)
|> close(%)
|> extrude(10, %)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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")
|> circle([0, 0], 5, %, $myCircle)
|> extrude(5, %)
5 changes: 5 additions & 0 deletions src/wasm-lib/tests/executor/inputs/tangential_arc.kcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const boxSketch = startSketchAt([0, 0])
|> line([0, 10], %)
|> tangentialArc({radius: 5, offset: 90}, %)
|> line([5, -15], %)
|> extrude(10, %)
71 changes: 0 additions & 71 deletions src/wasm-lib/tests/executor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,6 @@ async fn kcl_test_negative_args() {
assert_out("negative_args", &result);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_basic_tangential_arc() {
let code = r#"const boxSketch = startSketchAt([0, 0])
|> line([0, 10], %)
|> tangentialArc({radius: 5, offset: 90}, %)
|> line([5, -15], %)
|> extrude(10, %)
"#;

let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("tangential_arc", &result);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_basic_tangential_arc_with_point() {
let code = r#"const boxSketch = startSketchAt([0, 0])
Expand Down Expand Up @@ -837,30 +824,6 @@ const part002 = startSketchOn(part001, "end")
assert_out("sketch_on_face_circle", &result);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_sketch_on_face_circle_tagged() {
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")
|> circle([0, 0], 5, %, $myCircle)
|> extrude(5, %)
"#;

let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("sketch_on_face_circle_tagged", &result);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_stdlib_kcl_error_circle() {
let code = r#"// Mounting Plate
Expand Down Expand Up @@ -907,40 +870,6 @@ const part = rectShape([0, 0], 20, 20)
);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_big_number_angle_to_match_length_x() {
let code = r#"const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> angledLineToX([
-angleToMatchLengthX(seg01, 3, %),
3
], %)
|> close(%)
|> extrude(10, %)
"#;

let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("big_number_angle_to_match_length_x", &result);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_big_number_angle_to_match_length_y() {
let code = r#"const part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> angledLineToX([
-angleToMatchLengthY(seg01, 3, %),
3
], %)
|> close(%)
|> extrude(10, %)
"#;

let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("big_number_angle_to_match_length_y", &result);
}

#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_simple_revolve() {
let code = r#"const part001 = startSketchOn('XY')
Expand Down
10 changes: 10 additions & 0 deletions src/wasm-lib/tests/executor/visuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ macro_rules! kcl_test {
}

kcl_test!("sketch_on_face", kcl_test_sketch_on_face);
kcl_test!("tangential_arc", kcl_test_tangential_arc);
kcl_test!(
"big_number_angle_to_match_length_x",
kcl_test_big_number_angle_to_match_length_x
);
kcl_test!(
"big_number_angle_to_match_length_y",
kcl_test_big_number_angle_to_match_length_y
);
kcl_test!("sketch_on_face_circle_tagged", kcl_test_sketch_on_face_circle_tagged);
kcl_test!("basic_fillet_cube_start", kcl_test_basic_fillet_cube_start);
kcl_test!(
"basic_fillet_cube_next_adjacent",
Expand Down

0 comments on commit 4fd5e26

Please sign in to comment.