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:
Adam Chalmers
2024-08-03 00:24:00 -05:00
committed by GitHub
parent 22f9df73ed
commit 7bf6bc3048
4 changed files with 150 additions and 30 deletions

View 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")

View File

@ -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");

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB