--- /dev/null +++ b/tests/golden_destruct/mutual_recursive_cross.jsonnet @@ -0,0 +1,4 @@ +local + {a, b, c} = {a: y, b: c, c: x}, + {x, y, z} = {x: a, y: 2, z: b}; +z == 2 --- /dev/null +++ b/tests/golden_destruct/mutual_recursive_fields.jsonnet @@ -0,0 +1 @@ +local {a, b, c} = {a: b+1, b:c+1,c:3}; a --- /dev/null +++ b/tests/golden_destruct/mutual_recursive_locals.jsonnet @@ -0,0 +1 @@ +local {a= b+1, b = c+1, c = 3} = {}; a --- /dev/null +++ b/tests/golden_destruct/omit.jsonnet @@ -0,0 +1,2 @@ +// ...rest works like removeField, but freezes the object core so it still can access the fields +local {a, b, ...c} = {a: 1, b: 2, c: self.a, d: self.b}; c --- /dev/null +++ b/tests/golden_destruct/params.jsonnet @@ -0,0 +1,3 @@ +local myFun({a, b, c}) = a + b + c; + +myFun({a: 1, b: 2, c: 3}) --- a/tests/tests/golden.rs +++ b/tests/tests/golden.rs @@ -55,3 +55,13 @@ assert_snapshot!(result); }); } + +#[test] +#[cfg(feature = "exp-destruct")] +fn golden_destruct() { + glob!("../", "golden_destruct/*.jsonnet", |path| { + let result = run(path); + + assert_snapshot!(result); + }); +} --- /dev/null +++ b/tests/tests/snapshots/golden__golden_destruct@mutual_recursive_cross.jsonnet.snap @@ -0,0 +1,6 @@ +--- +source: tests/tests/golden.rs +expression: result +input_file: tests/golden_destruct/mutual_recursive_cross.jsonnet +--- +true --- /dev/null +++ b/tests/tests/snapshots/golden__golden_destruct@mutual_recursive_fields.jsonnet.snap @@ -0,0 +1,6 @@ +--- +source: tests/tests/golden.rs +expression: result +input_file: tests/golden_destruct/mutual_recursive_fields.jsonnet +--- +5 --- /dev/null +++ b/tests/tests/snapshots/golden__golden_destruct@mutual_recursive_locals.jsonnet.snap @@ -0,0 +1,6 @@ +--- +source: tests/tests/golden.rs +expression: result +input_file: tests/golden_destruct/mutual_recursive_locals.jsonnet +--- +5 --- /dev/null +++ b/tests/tests/snapshots/golden__golden_destruct@omit.jsonnet.snap @@ -0,0 +1,9 @@ +--- +source: tests/tests/golden.rs +expression: result +input_file: tests/golden_destruct/omit.jsonnet +--- +{ + "c": 1, + "d": 2 +} --- /dev/null +++ b/tests/tests/snapshots/golden__golden_destruct@params.jsonnet.snap @@ -0,0 +1,6 @@ +--- +source: tests/tests/golden.rs +expression: result +input_file: tests/golden_destruct/params.jsonnet +--- +6