Fix computed properties of KCL objects (#3246)
* Fix computed properties of KCL objects Fixes https://github.com/KittyCAD/modeling-app/issues/3201 * Incorporate Jon's feedback
This commit is contained in:
18
src/wasm-lib/tests/executor/inputs/computed_var.kcl
Normal file
18
src/wasm-lib/tests/executor/inputs/computed_var.kcl
Normal file
@ -0,0 +1,18 @@
|
||||
// This tests computed properties.
|
||||
|
||||
const arr = [0, 0, 0, 10]
|
||||
const i = 3
|
||||
const ten = arr[i]
|
||||
|
||||
assertLessThanOrEq(ten, 10, "oops")
|
||||
assertGreaterThanOrEq(ten, 10, "oops2")
|
||||
|
||||
const p = "foo"
|
||||
const obj = {
|
||||
foo: 1,
|
||||
bar: 0,
|
||||
}
|
||||
const one = obj[p]
|
||||
|
||||
assertLessThanOrEq(one, 1, "oops")
|
||||
assertGreaterThanOrEq(one, 1, "oops2")
|
@ -38,6 +38,13 @@ async fn kcl_test_lego() {
|
||||
assert_out("lego", &result);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_computed_var() {
|
||||
let code = kcl_input!("computed_var");
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
assert_out("computed_var", &result);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_pipe_as_arg() {
|
||||
let code = kcl_input!("pipe_as_arg");
|
||||
|
BIN
src/wasm-lib/tests/executor/outputs/computed_var.png
Normal file
BIN
src/wasm-lib/tests/executor/outputs/computed_var.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
Reference in New Issue
Block a user