KCL: More simulation tests (#4359)

Demonstrate simulation tests where we don't care about visuals, e.g. the double-map test. 

The `just new-sim-test` now accepts an optional argument, `render_to_png` which can be either  "true" or "false" (defaults to "true"). Tests like double_map that don't render anything can use false, rather than rendering an empty PNG with nothing in it.

This means the [tests under `no_visuals/`](https://github.com/KittyCAD/modeling-app/tree/v0.26.2/src/wasm-lib/tests/executor/inputs/no_visuals) can be entirely replaced by simulation tests. This is much better! For example, I moved `double_map.kcl` from a no_visuals test to a simulation test. Here's the file:

```
fn increment = (i) => {
  return i + 1
}

xs = [0..2]
ys = xs
  |> map(%, increment)
  |> map(%, increment)
```

Previously the `no_visuals` test just checked that the program ran successfully without panicking. Now the simulation test lets you see the value of `xs` and `ys` and immediately see they're correct. If our map logic changes (for example, we have an off-by-one error and don't apply the `map` to the last element) it'll show up in the program memory snapshot.
This commit is contained in:
Adam Chalmers
2024-10-31 11:43:14 -05:00
committed by GitHub
parent 26e995dc3f
commit 26951364cf
18 changed files with 1730 additions and 33 deletions

View File

@ -1,4 +0,0 @@
const part001 = startSketchOn('XY')
|> circle({ center: [5, 5], radius: 10 }, %)
|> extrude(10, %)
|> helix({revolutions: 16, angle_start: 0, ccw: true}, %)

View File

@ -1,6 +0,0 @@
fn increment = (i) => { return i + 1 }
xs = [0..2]
ys = xs
|> map(%, increment)
|> map(%, increment)

View File

@ -153,14 +153,6 @@ async fn kcl_test_helix_defaults_negative_extrude() {
assert_out("helix_defaults_negative_extrude", &result);
}
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_helix_ccw() {
let code = kcl_input!("helix_ccw");
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
assert_out("helix_ccw", &result);
}
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_helix_with_length() {
let code = kcl_input!("helix_with_length");

View File

@ -172,7 +172,6 @@ gen_test_parse_fail!(
// "syntax: Can import only import at the top level"
// );
gen_test!(add_lots);
gen_test!(double_map);
gen_test!(array_elem_push);
gen_test_fail!(
array_elem_push_fail,