Replace plane strings with literals (#6592)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -78,7 +78,7 @@ async fn cache_test(
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_cache_change_grid_visualizes_grid_off_to_on() {
|
||||
let code = r#"part001 = startSketchOn('XY')
|
||||
let code = r#"part001 = startSketchOn(XY)
|
||||
|> startProfile(at = [5.5229, 5.25217])
|
||||
|> line(end = [10.50433, -1.19122])
|
||||
|> line(end = [8.01362, -5.48731])
|
||||
@ -254,7 +254,7 @@ extrude(profile001, length = 100)"#
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_cache_add_line_preserves_artifact_commands() {
|
||||
let code = r#"sketch001 = startSketchOn('XY')
|
||||
let code = r#"sketch001 = startSketchOn(XY)
|
||||
|> startProfile(at = [5.5229, 5.25217])
|
||||
|> line(end = [10.50433, -1.19122])
|
||||
|> line(end = [8.01362, -5.48731])
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
startProfile(startSketchOn("XY"), at = [0, 0])
|
||||
startProfile(startSketchOn(XY), at = [0, 0])
|
||||
|> xLine(length = 10, tag = $line000)
|
||||
|> yLine(length = 10, tag = $line001)
|
||||
|> xLine(endAbsolute = profileStartX(%), tag = $line002)
|
||||
|
||||
@ -15,7 +15,7 @@ tabThk = 4
|
||||
|
||||
// define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn('xy')
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfile(at = [pos[0] - (w / 2), pos[1] - (l / 2)])
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge01)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge02)
|
||||
|
||||
@ -15,7 +15,7 @@ tabThk = 4
|
||||
|
||||
// define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn('xy')
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfile(at = [pos[0] - (w / 2), pos[1] - (l / 2)])
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge01)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge02)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
part001 = startSketchOn('-XZ')
|
||||
part001 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(endAbsolute = [100, 100])
|
||||
|> line(endAbsolute = [100, 0])
|
||||
|
||||
@ -10,7 +10,7 @@ plane94894440791888 = {
|
||||
}
|
||||
|
||||
// create a sketch with UID 94894440902176
|
||||
sketch94894440902176 = startSketchOn('-XZ')
|
||||
sketch94894440902176 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [-0.005, -0.005])
|
||||
|> line(end = [0.01, 0.0], tag = $line94894439494384)
|
||||
|> line(end = [0.0, 0.01], tag = $line94894439429616)
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
}
|
||||
|
||||
// create a sketch with UID 94894440902176
|
||||
sketch94894440902176 = startSketchOn('-XZ')
|
||||
sketch94894440902176 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [-0.005, -0.005])
|
||||
|> line(end = [0.01, 0.0], tag = $line94894439494384)
|
||||
|> line(end = [0.0, 0.01], tag = $line94894439429616)
|
||||
|
||||
@ -9,7 +9,7 @@ front_length = 6
|
||||
Fx = 0.5
|
||||
Fy = 0.5
|
||||
|
||||
sketch001 = startSketchOn('-YZ')
|
||||
sketch001 = startSketchOn(-YZ)
|
||||
|> startProfile(at = [back_walls_width / 2, 0])
|
||||
|> xLine(length = wall_thickness / 2)
|
||||
|> angledLine(angle = 45, endAbsoluteX = back_walls_width, tag = $seg01)
|
||||
@ -34,7 +34,7 @@ part001 = revolve({
|
||||
}
|
||||
}, sketch001)
|
||||
|
||||
sketch002 = startSketchOn('-YZ')
|
||||
sketch002 = startSketchOn(-YZ)
|
||||
|> startProfile(at = [back_walls_width / 2, 0])
|
||||
|> xLine(length = wall_thickness / 2)
|
||||
|> angledLine(angle = 45, endAbsoluteX = back_walls_width, tag = $seg02)
|
||||
|
||||
@ -197,11 +197,11 @@ fn box(sk1, sk2, scale, plane) {
|
||||
return boxsketch
|
||||
}
|
||||
|
||||
box(0, 0, 5, 'xy')
|
||||
box(10, 23, 8, 'xz')
|
||||
box(30, 43, 18, '-xy')
|
||||
thing = box(-12, -15, 10, 'yz')
|
||||
box(-20, -5, 10, 'xy')"#;
|
||||
box(0, 0, 5, XY)
|
||||
box(10, 23, 8, XZ)
|
||||
box(30, 43, 18, -XY)
|
||||
thing = box(-12, -15, 10, YZ)
|
||||
box(-20, -5, 10, XY)"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await.unwrap();
|
||||
assert_out("different_planes_same_drawing", &result);
|
||||
@ -242,13 +242,13 @@ part001 = startSketchOn(XY)
|
||||
|> close()
|
||||
|> extrude(length = 4)
|
||||
|
||||
part002 = startSketchOn('-XZ')
|
||||
part002 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [-9.35, 19.18])
|
||||
|> line(end = [32.14, -2.47])
|
||||
|> line(end = [8.39, -3.73])
|
||||
|> close()
|
||||
|
||||
part003 = startSketchOn('-XZ')
|
||||
part003 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [13.82, 16.51])
|
||||
|> line(end = [-6.24, -30.82])
|
||||
|> line(end = [8.39, -3.73])
|
||||
@ -818,55 +818,6 @@ part002 = startSketchOn(part001, face = END)
|
||||
assert_out("sketch_on_face_circle", &result);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_stdlib_kcl_error_circle() {
|
||||
let code = r#"// Mounting Plate
|
||||
// A flat piece of material, often metal or plastic, that serves as a support or base for attaching, securing, or mounting various types of equipment, devices, or components.
|
||||
|
||||
// Create a function that defines the body width and length of the mounting plate. Tag the corners so they can be passed through the fillet function.
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfile(at = [pos[0] - (w / 2), pos[1] - (l / 2)])
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|
||||
|> line(endAbsolute = [pos[0] - (w / 2), pos[1] + l / 2], tag = $edge3)
|
||||
|> close(tag = $edge4)
|
||||
return rr
|
||||
}
|
||||
|
||||
// Define the hole radius and x, y location constants
|
||||
holeRadius = 1
|
||||
holeIndex = 6
|
||||
|
||||
// Create the mounting plate extrusion, holes, and fillets
|
||||
part = rectShape([0, 0], 20, 20)
|
||||
|> subtract2d(tool = circle('XY', center = [-holeIndex, holeIndex], radius = holeRadius))
|
||||
|> subtract2d(tool = circle('XY', center = [holeIndex, holeIndex], radius = holeRadius))
|
||||
|> subtract2d(tool = circle('XY', center = [-holeIndex, -holeIndex], radius = holeRadius))
|
||||
|> subtract2d(tool = circle('XY', center = [holeIndex, -holeIndex], radius = holeRadius))
|
||||
|> extrude(length = 2)
|
||||
|> fillet(
|
||||
radius = 4,
|
||||
tags = [
|
||||
getNextAdjacentEdge(edge1),
|
||||
getNextAdjacentEdge(edge2),
|
||||
getNextAdjacentEdge(edge3),
|
||||
getNextAdjacentEdge(edge4)
|
||||
]
|
||||
)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, None).await;
|
||||
let err = result.err().unwrap();
|
||||
let ExecError::Kcl(err) = err else {
|
||||
panic!("Expected KCL error, found {err}");
|
||||
};
|
||||
assert_eq!(
|
||||
err.error.message(),
|
||||
"This function expected the input argument to be of type SketchOrSurface but it's actually of type string (text)"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_simple_revolve() {
|
||||
let code = r#"part001 = startSketchOn(XY)
|
||||
@ -1334,7 +1285,7 @@ bracket = startSketchOn(XY)
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_error_empty_start_sketch_on_string() {
|
||||
let code = r#"part001 = startSketchOn('-XZ')
|
||||
let code = r#"part001 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [75.75, 184.25])
|
||||
|> line(end = [190.03, -118.13])
|
||||
|> line(end = [-33.38, -202.86])
|
||||
|
||||
Reference in New Issue
Block a user