lang: funcs: core: test: Make a new instance for each test

Since this special one_instance function uses global state, if it's
re-used in more than one test, this won't work since they still all use
the whole global state. Make new ones for each test.

This also breaks the count=2 feature (any number other than 1) when
running these, which is not ideal. Create a cleanup API that we can run
between tests to reset the global state.
This commit is contained in:
James Shubin
2023-12-27 18:24:02 -05:00
parent 1c0a98a0cc
commit fa5949e191
4 changed files with 136 additions and 20 deletions

View File

@@ -5,14 +5,14 @@ $double = func($x) {
$x + $x
}
# one_instance_a should only produce one value, and will error if initialized twice
# one_instance_g should only produce one value, and will error if initialized twice
test "test1" {
anotherstr => $double(test.one_instance_a()),
anotherstr => $double(test.one_instance_g()),
}
# one_instance_b should only produce one value, and will error if initialized twice
# one_instance_h should only produce one value, and will error if initialized twice
test "test2" {
anotherstr => $double(test.one_instance_b()),
anotherstr => $double(test.one_instance_h()),
}
-- OUTPUT --
Vertex: test[test1]