Factor ExecutionCtx into its own fn
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
use anyhow::Result;
|
||||
use kcl_lib::executor::ExecutorSettings;
|
||||
use kcl_lib::{
|
||||
executor::{ExecutorContext, ExecutorSettings},
|
||||
settings::types::UnitLength,
|
||||
};
|
||||
|
||||
/// Executes a kcl program and takes a snapshot of the result.
|
||||
/// This returns the bytes of the snapshot.
|
||||
async fn execute_and_snapshot(code: &str, units: kcl_lib::settings::types::UnitLength) -> Result<image::DynamicImage> {
|
||||
async fn new_context(units: UnitLength) -> Result<ExecutorContext> {
|
||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||
let http_client = reqwest::Client::builder()
|
||||
.user_agent(user_agent)
|
||||
@ -28,13 +29,7 @@ async fn execute_and_snapshot(code: &str, units: kcl_lib::settings::types::UnitL
|
||||
client.set_base_url(addr);
|
||||
}
|
||||
|
||||
// Create a temporary file to write the output to.
|
||||
let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
||||
|
||||
let tokens = kcl_lib::token::lexer(code)?;
|
||||
let parser = kcl_lib::parser::Parser::new(tokens);
|
||||
let program = parser.ast()?;
|
||||
let ctx = kcl_lib::executor::ExecutorContext::new(
|
||||
let ctx = ExecutorContext::new(
|
||||
&client,
|
||||
ExecutorSettings {
|
||||
units,
|
||||
@ -43,6 +38,18 @@ async fn execute_and_snapshot(code: &str, units: kcl_lib::settings::types::UnitL
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(ctx)
|
||||
}
|
||||
|
||||
/// Executes a kcl program and takes a snapshot of the result.
|
||||
/// This returns the bytes of the snapshot.
|
||||
async fn execute_and_snapshot(code: &str, units: UnitLength) -> Result<image::DynamicImage> {
|
||||
let ctx = new_context(units).await?;
|
||||
let tokens = kcl_lib::token::lexer(code)?;
|
||||
let parser = kcl_lib::parser::Parser::new(tokens);
|
||||
let program = parser.ast()?;
|
||||
// Create a temporary file to write the output to.
|
||||
let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
||||
|
||||
let _ = ctx.run(program, None).await?;
|
||||
|
||||
@ -104,45 +111,35 @@ const part002 = startSketchOn(part001, "here")
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::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, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_riddle_small() {
|
||||
let code = include_str!("inputs/riddle_small.kcl");
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/riddle_small.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_lego() {
|
||||
let code = include_str!("inputs/lego.kcl");
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/lego.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_pipe_as_arg() {
|
||||
let code = include_str!("inputs/pipe_as_arg.kcl");
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/pipe_as_arg.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_pentagon_fillet_sugar() {
|
||||
let code = include_str!("inputs/pentagon_fillet_sugar.kcl");
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Cm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Cm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/pentagon_fillet_sugar.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -170,18 +167,14 @@ const part002 = startSketchOn(part001, "start")
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::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, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_mike_stress_lines() {
|
||||
let code = include_str!("inputs/mike_stress_test.kcl");
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/mike_stress_test.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -209,9 +202,7 @@ const part002 = startSketchOn(part001, "END")
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::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, 0.999);
|
||||
}
|
||||
|
||||
@ -239,9 +230,7 @@ const part002 = startSketchOn(part001, "END")
|
||||
|> extrude(-5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::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_negative_extrude.png",
|
||||
&result,
|
||||
@ -261,7 +250,7 @@ async fn serial_test_fillet_duplicate_tags() {
|
||||
|> fillet({radius: 0.5, tags: ["thing", "thing"]}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -281,9 +270,7 @@ async fn serial_test_basic_fillet_cube_start() {
|
||||
|> fillet({radius: 2, tags: ["thing", "thing2"]}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/basic_fillet_cube_start.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -300,9 +287,7 @@ async fn serial_test_basic_fillet_cube_end() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/basic_fillet_cube_end.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -319,9 +304,7 @@ async fn serial_test_basic_fillet_cube_close_opposite() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/basic_fillet_cube_close_opposite.png",
|
||||
&result,
|
||||
@ -341,9 +324,7 @@ async fn serial_test_basic_fillet_cube_next_adjacent() {
|
||||
|> fillet({radius: 2, tags: [getNextAdjacentEdge("thing3", %)]}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/basic_fillet_cube_next_adjacent.png",
|
||||
&result,
|
||||
@ -363,9 +344,7 @@ async fn serial_test_basic_fillet_cube_previous_adjacent() {
|
||||
|> fillet({radius: 2, tags: [getPreviousAdjacentEdge("thing3", %)]}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/basic_fillet_cube_previous_adjacent.png",
|
||||
&result,
|
||||
@ -390,9 +369,7 @@ async fn serial_test_execute_with_function_sketch() {
|
||||
const fnBox = box(3, 6, 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/function_sketch.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -412,9 +389,7 @@ async fn serial_test_execute_with_function_sketch_with_position() {
|
||||
|
||||
const thing = box([0,0], 3, 6, 10)"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/function_sketch_with_position.png",
|
||||
&result,
|
||||
@ -435,9 +410,7 @@ async fn serial_test_execute_with_angled_line() {
|
||||
|> extrude(4, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/angled_line.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -463,9 +436,7 @@ const bracket = startSketchOn('XY')
|
||||
|> extrude(width, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/parametric.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -499,9 +470,7 @@ const bracket = startSketchAt([0, 0])
|
||||
|> extrude(width, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/parametric_with_tan_arc.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -516,7 +485,7 @@ async fn serial_test_execute_engine_error_return() {
|
||||
|> extrude(4, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -529,9 +498,7 @@ async fn serial_test_execute_i_shape() {
|
||||
// This is some code from lee that starts a pipe expression with a variable.
|
||||
let code = include_str!("inputs/i_shape.kcl");
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/i_shape.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -540,9 +507,7 @@ async fn serial_test_execute_i_shape() {
|
||||
async fn serial_test_execute_pipes_on_pipes() {
|
||||
let code = include_str!("inputs/pipes_on_pipes.kcl");
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/pipes_on_pipes.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -550,9 +515,7 @@ async fn serial_test_execute_pipes_on_pipes() {
|
||||
async fn serial_test_execute_cylinder() {
|
||||
let code = include_str!("inputs/cylinder.kcl");
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cylinder.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -560,9 +523,7 @@ async fn serial_test_execute_cylinder() {
|
||||
async fn serial_test_execute_kittycad_svg() {
|
||||
let code = include_str!("inputs/kittycad_svg.kcl");
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/kittycad_svg.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -587,9 +548,7 @@ const pt1 = b1.value[0]
|
||||
const pt2 = b2.value[0]
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/member_expression_sketch_group.png",
|
||||
&result,
|
||||
@ -605,9 +564,7 @@ async fn serial_test_helix_defaults() {
|
||||
|> helix({revolutions: 16, angle_start: 0}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/helix_defaults.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -619,9 +576,7 @@ async fn serial_test_helix_defaults_negative_extrude() {
|
||||
|> helix({revolutions: 16, angle_start: 0}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/helix_defaults_negative_extrude.png",
|
||||
&result,
|
||||
@ -637,9 +592,7 @@ async fn serial_test_helix_ccw() {
|
||||
|> helix({revolutions: 16, angle_start: 0, ccw: true}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/helix_ccw.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -651,9 +604,7 @@ async fn serial_test_helix_with_length() {
|
||||
|> helix({revolutions: 16, angle_start: 0, length: 3}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/helix_with_length.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -668,9 +619,7 @@ async fn serial_test_dimensions_match() {
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/dimensions_match.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -687,9 +636,7 @@ const body = startSketchOn('XY')
|
||||
|> extrude(height, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/close_arc.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -715,9 +662,7 @@ box(10, 23, 8)
|
||||
let thing = box(-12, -15, 10)
|
||||
box(-20, -5, 10)"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/negative_args.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -730,9 +675,7 @@ async fn serial_test_basic_tangential_arc() {
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/tangential_arc.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -745,9 +688,7 @@ async fn serial_test_basic_tangential_arc_with_point() {
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/tangential_arc_with_point.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -760,9 +701,7 @@ async fn serial_test_basic_tangential_arc_to() {
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/tangential_arc_to.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -789,9 +728,7 @@ box(30, 43, 18, '-xy')
|
||||
let thing = box(-12, -15, 10, 'yz')
|
||||
box(-20, -5, 10, 'xy')"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/different_planes_same_drawing.png",
|
||||
&result,
|
||||
@ -853,9 +790,7 @@ const part004 = startSketchOn('YZ')
|
||||
|> close(%)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/lots_of_planes.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -872,9 +807,7 @@ async fn serial_test_holes() {
|
||||
|> extrude(2, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/holes.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -893,9 +826,7 @@ async fn optional_params() {
|
||||
|
||||
const thing = other_circle([2, 2], 20)
|
||||
"#;
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/optional_params.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -931,9 +862,7 @@ const part = roundedRectangle([0, 0], 20, 20, 4)
|
||||
|> extrude(2, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/rounded_with_holes.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -941,9 +870,7 @@ const part = roundedRectangle([0, 0], 20, 20, 4)
|
||||
async fn serial_test_top_level_expression() {
|
||||
let code = r#"startSketchOn('XY') |> circle([0,0], 22, %) |> extrude(14, %)"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/top_level_expression.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -957,9 +884,7 @@ const part = startSketchOn('XY')
|
||||
|> extrude(1, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/patterns_linear_basic_with_math.png",
|
||||
&result,
|
||||
@ -975,9 +900,7 @@ async fn serial_test_patterns_linear_basic() {
|
||||
|> extrude(1, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/patterns_linear_basic.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -993,9 +916,7 @@ async fn serial_test_patterns_linear_basic_3d() {
|
||||
|> patternLinear3d({axis: [1, 0, 1], repetitions: 3, distance: 6}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/patterns_linear_basic_3d.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1007,9 +928,7 @@ async fn serial_test_patterns_linear_basic_negative_distance() {
|
||||
|> extrude(1, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/patterns_linear_basic_negative_distance.png",
|
||||
&result,
|
||||
@ -1025,9 +944,7 @@ async fn serial_test_patterns_linear_basic_negative_axis() {
|
||||
|> extrude(1, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/patterns_linear_basic_negative_axis.png",
|
||||
&result,
|
||||
@ -1052,9 +969,7 @@ const rectangle = startSketchOn('XY')
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/patterns_linear_basic_holes.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1066,9 +981,7 @@ async fn serial_test_patterns_circular_basic_2d() {
|
||||
|> extrude(1, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/patterns_circular_basic_2d.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1084,9 +997,7 @@ async fn serial_test_patterns_circular_basic_3d() {
|
||||
|> patternCircular3d({axis: [0,0, 1], center: [-20, -20, -20], repetitions: 40, arcDegrees: 360, rotateDuplicates: false}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/patterns_circular_basic_3d.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1102,9 +1013,7 @@ async fn serial_test_patterns_circular_3d_tilted_axis() {
|
||||
|> patternCircular3d({axis: [1,1,0], center: [10, 0, 10], repetitions: 10, arcDegrees: 360, rotateDuplicates: true}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/patterns_circular_3d_tilted_axis.png",
|
||||
&result,
|
||||
@ -1116,7 +1025,7 @@ async fn serial_test_patterns_circular_3d_tilted_axis() {
|
||||
async fn serial_test_import_file_doesnt_exist() {
|
||||
let code = r#"const model = import("thing.obj")"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -1128,9 +1037,7 @@ async fn serial_test_import_file_doesnt_exist() {
|
||||
async fn serial_test_import_obj_with_mtl() {
|
||||
let code = r#"const model = import("tests/executor/inputs/cube.obj")"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/import_obj_with_mtl.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1138,9 +1045,7 @@ async fn serial_test_import_obj_with_mtl() {
|
||||
async fn serial_test_import_obj_with_mtl_units() {
|
||||
let code = r#"const model = import("tests/executor/inputs/cube.obj", {type: "obj", units: "m"})"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/import_obj_with_mtl_units.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1148,9 +1053,7 @@ async fn serial_test_import_obj_with_mtl_units() {
|
||||
async fn serial_test_import_gltf_with_bin() {
|
||||
let code = r#"const model = import("tests/executor/inputs/cube.gltf")"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/import_gltf_with_bin.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1158,9 +1061,7 @@ async fn serial_test_import_gltf_with_bin() {
|
||||
async fn serial_test_import_gltf_embedded() {
|
||||
let code = r#"const model = import("tests/executor/inputs/cube-embedded.gltf")"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/import_gltf_embedded.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1168,9 +1069,7 @@ async fn serial_test_import_gltf_embedded() {
|
||||
async fn serial_test_import_glb() {
|
||||
let code = r#"const model = import("tests/executor/inputs/cube.glb")"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/import_glb.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1178,9 +1077,7 @@ async fn serial_test_import_glb() {
|
||||
async fn serial_test_import_glb_no_assign() {
|
||||
let code = r#"import("tests/executor/inputs/cube.glb")"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/import_glb_no_assign.png", &result, 0.999);
|
||||
}
|
||||
|
||||
@ -1188,7 +1085,7 @@ async fn serial_test_import_glb_no_assign() {
|
||||
async fn serial_test_import_ext_doesnt_match() {
|
||||
let code = r#"const model = import("tests/executor/inputs/cube.gltf", {type: "obj", units: "m"})"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -1213,9 +1110,7 @@ async fn serial_test_cube_mm() {
|
||||
const myCube = cube([0,0], 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cube_mm.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1236,9 +1131,7 @@ async fn serial_test_cube_cm() {
|
||||
const myCube = cube([0,0], 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Cm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Cm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cube_cm.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1259,9 +1152,7 @@ async fn serial_test_cube_m() {
|
||||
const myCube = cube([0,0], 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::M)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::M).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cube_m.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1282,9 +1173,7 @@ async fn serial_test_cube_in() {
|
||||
const myCube = cube([0,0], 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::In)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::In).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cube_in.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1305,9 +1194,7 @@ async fn serial_test_cube_ft() {
|
||||
const myCube = cube([0,0], 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Ft)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Ft).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cube_ft.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1328,9 +1215,7 @@ async fn serial_test_cube_yd() {
|
||||
const myCube = cube([0,0], 10)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Yd)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Yd).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/cube_yd.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1358,7 +1243,7 @@ const part002 = startSketchOn(part001, "here")
|
||||
|> extrude(1, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
@ -1399,9 +1284,7 @@ const part003 = startSketchOn(part002, "end")
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face_of_face.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1418,7 +1301,7 @@ async fn serial_test_stdlib_kcl_error_right_code_path() {
|
||||
|> extrude(2, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -1446,9 +1329,7 @@ const part002 = startSketchOn(part001, "end")
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face_circle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1472,9 +1353,7 @@ const part002 = startSketchOn(part001, "end")
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/sketch_on_face_circle_tagged.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1516,7 +1395,7 @@ const part = rectShape([0, 0], 20, 20)
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -1537,9 +1416,7 @@ async fn serial_test_big_number_angle_to_match_length_x() {
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/big_number_angle_to_match_length_x.png",
|
||||
&result,
|
||||
@ -1560,9 +1437,7 @@ async fn serial_test_big_number_angle_to_match_length_y() {
|
||||
|> extrude(10, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image(
|
||||
"tests/executor/outputs/big_number_angle_to_match_length_y.png",
|
||||
&result,
|
||||
@ -1586,9 +1461,7 @@ async fn serial_test_simple_revolve() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1608,9 +1481,7 @@ async fn serial_test_simple_revolve_uppercase() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_uppercase.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1630,9 +1501,7 @@ async fn serial_test_simple_revolve_negative() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_negative.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1652,7 +1521,7 @@ async fn serial_test_revolve_bad_angle_low() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
@ -1677,7 +1546,7 @@ async fn serial_test_revolve_bad_angle_high() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
@ -1702,9 +1571,7 @@ async fn serial_test_simple_revolve_custom_angle() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_custom_angle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1724,9 +1591,7 @@ async fn serial_test_simple_revolve_custom_axis() {
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_custom_axis.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1750,9 +1615,7 @@ const sketch001 = startSketchOn(box, "end")
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_edge.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1776,7 +1639,7 @@ const sketch001 = startSketchOn(box, "revolveAxis")
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
@ -1803,9 +1666,7 @@ const sketch001 = startSketchOn(box, "END")
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_face_circle_edge.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1827,9 +1688,7 @@ const sketch001 = startSketchOn(box, "END")
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_face_circle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1855,9 +1714,7 @@ const sketch001 = startSketchOn(box, "end")
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_face.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1871,9 +1728,7 @@ async fn serial_test_basic_revolve_circle() {
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/basic_revolve_circle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1900,9 +1755,7 @@ const part002 = startSketchOn(part001, 'end')
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_sketch_on_edge.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1963,9 +1816,7 @@ const plumbus1 = make_circle(p, 'b', [0, 0], 2.5)
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/plumbus_fillets.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -1973,7 +1824,7 @@ const plumbus1 = make_circle(p, 'b', [0, 0], 2.5)
|
||||
async fn serial_test_empty_file_is_ok() {
|
||||
let code = r#""#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
@ -2003,9 +1854,7 @@ async fn serial_test_member_expression_in_params() {
|
||||
capScrew([0, 0.5, 0], 50, 37.5, 50, 25)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/member_expression_in_params.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -2050,7 +1899,7 @@ const bracket = startSketchOn('XY')
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -2074,7 +1923,7 @@ const secondSketch = startSketchOn(part001, '')
|
||||
|> extrude(20, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -2105,7 +1954,7 @@ const extrusion = startSketchOn('XY')
|
||||
|> extrude(height, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm).await;
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
@ -2123,9 +1972,7 @@ async fn serial_test_xz_plane() {
|
||||
|> extrude(5 + 7, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/xz_plane.png", &result, 1.0);
|
||||
}
|
||||
|
||||
@ -2139,8 +1986,6 @@ async fn serial_test_neg_xz_plane() {
|
||||
|> extrude(5 + 7, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/neg_xz_plane.png", &result, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user