Changed expression evaluation opening and closing pattern.

This commit is contained in:
2026-01-04 14:30:49 +01:00
parent 60d4bbecd9
commit 5a86e498d2
7 changed files with 18 additions and 18 deletions

View File

@@ -195,8 +195,8 @@ Export attribute
key: key:
- GID-1510554_step_1 - GID-1510554_step_1
report: report:
reported_list: <@ random.sample(range(0,20), k=10) @> reported_list: @| random.sample(range(0,20), k=10) |
reported_float: <@ math.sqrt(float(1)) @> reported_float: @| math.sqrt(float(1)) |
reported_str: This is my reported sentence reported_str: This is my reported sentence

View File

@@ -63,7 +63,7 @@ The parameter file can be specified in the `.tum` file root:
parameter1: value1 parameter1: value1
parameter2: 1234 parameter2: 1234
parameter3: <@ 12.34 * 2 @> parameter3: @| 12.34 * 2 |
parameter4: parameter4:
- $(parameter1) - $(parameter1)
- $(parameter3) - $(parameter3)
@@ -202,7 +202,7 @@ The variable substitution is recursive and checks all the occurrences of the
``$(x)`` pattern in a string. ``$(x)`` pattern in a string.
It is also possible to perform evaluation of python substrings during parameters passing. It is also possible to perform evaluation of python substrings during parameters passing.
It is done by using the ``<@ expr @>`` pattern in a string. It is done by using the ``@| expr |`` pattern in a string.
`expr` may then be a correct python expression. `expr` may then be a correct python expression.
Below are illustrated simple and more complicated cases of expansion and evaluation depending on Below are illustrated simple and more complicated cases of expansion and evaluation depending on
@@ -215,10 +215,10 @@ their pattern.
name: Dynamic variables expansion name: Dynamic variables expansion
key: $(test)_PASS key: $(test)_PASS
values: values:
- expanse_select: <@"$(expanse_select)".replace("o", "a")@> - expanse_select: @|"$(expanse_select)".replace("o", "a")|
- expanse_index: $(expanse_index_$(expanse_select)) - expanse_index: $(expanse_index_$(expanse_select))
- expanse_table: $(expanse_table_$(expanse_select)) - expanse_table: $(expanse_table_$(expanse_select))
- expanse_eval: <@$(expanse_index) == 1@> - expanse_eval: @|$(expanse_index) == 1|
Test Items Test Items
-------------------- --------------------

View File

@@ -313,12 +313,12 @@ def _preprocess_string(value, parent=None):
def _eval_param(value): def _eval_param(value):
"""This function parses a string value to check if patterns corresponding """This function parses a string value to check if patterns corresponding
to <@xxx@ exists. to @|xxx| exists.
When this kind of pattern is found, an attempt to evaluate its When this kind of pattern is found, an attempt to evaluate its
content is done. content is done.
If it is not evaluable, not replaced. If it is not evaluable, not replaced.
""" """
return _parse_and_process("<@", "@>", value, evaluate) return _parse_and_process("@|", "|", value, evaluate)
def _process_recursively(func, param_value, *fparams): def _process_recursively(func, param_value, *fparams):

View File

@@ -138,7 +138,7 @@
- py_func: - py_func:
name: Return True expect False but no_fail expansed name: Return True expect False but no_fail expansed
no_fail: <@ bool(0) == False @> no_fail: @| bool(0) == False |
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)results$(psep)results.py file: $(test_path)$(psep)results$(psep)results.py
func_name: echo func_name: echo
@@ -147,7 +147,7 @@
- py_func: - py_func:
name: Return True expect False but no_fail expansed (must fail) name: Return True expect False but no_fail expansed (must fail)
no_fail: <@ bool(1) == False @> no_fail: @| bool(1) == False |
key: $(test)_FAIL key: $(test)_FAIL
file: $(test_path)$(psep)results$(psep)results.py file: $(test_path)$(psep)results$(psep)results.py
func_name: echo func_name: echo

View File

@@ -9,4 +9,4 @@ expanse_index_blo: 1
expanse_index: $(expanse_index_$(expanse_select)) expanse_index: $(expanse_index_$(expanse_select))
expanse_table: $(expanse_table_$(expanse_select)) expanse_table: $(expanse_table_$(expanse_select))
expanse_eval: <@$(expanse_index) == 1@> expanse_eval: @|$(expanse_index) == 1|

View File

@@ -10,10 +10,10 @@
name: Dynamic variables expansion name: Dynamic variables expansion
key: $(test)_PASS key: $(test)_PASS
values: values:
- expanse_select: <@"$(expanse_select)".replace("o", "a")@> - expanse_select: @|"$(expanse_select)".replace("o", "a")|
- expanse_index: $(expanse_index_$(expanse_select)) - expanse_index: $(expanse_index_$(expanse_select))
- expanse_table: $(expanse_table_$(expanse_select)) - expanse_table: $(expanse_table_$(expanse_select))
- expanse_eval: <@$(expanse_index) == 1@> - expanse_eval: @|$(expanse_index) == 1|
- check: - check:
name: Check variables expansion is correct (PASS) name: Check variables expansion is correct (PASS)
@@ -33,7 +33,7 @@
- var4: blo - var4: blo
- expanse_var_bla: 3 - expanse_var_bla: 3
- expanse_blo_var: 5 - expanse_blo_var: 5
- expanse_complex: <@<@$(expanse_$(var2)_$(var3))*6@> + <@4*$($(var1)_$(var4)_$(var2))@>@> - expanse_complex: @|@|$(expanse_$(var2)_$(var3))*6| + @|4*$($(var1)_$(var4)_$(var2))||
- check: - check:
name: Check complex variables expansion is correct (PASS) name: Check complex variables expansion is correct (PASS)
@@ -50,10 +50,10 @@
- expanse_var_2: 6 - expanse_var_2: 6
- expanse_object: - expanse_object:
[ [
{ a: $(expanse_var_2), $(expanse_key): <@2**3@> }, { a: $(expanse_var_2), $(expanse_key): @|2**3| },
{ {
'<@"bla".replace("a", "o")@>': '@|"bla".replace("a", "o")|':
[<@$(expanse_var)*$(expanse_var_2)@>, 25], [@|$(expanse_var)*$(expanse_var_2)|, 25],
}, },
] ]

View File

@@ -1,5 +1,5 @@
# All sub directory in items are evaluated as a list # All sub directory in items are evaluated as a list
items: <@ [os.path.basename(f.path) for f in os.scandir(os.path.join(r"$(test_directory)", "items")) if f.is_dir()] @> items: @| [os.path.basename(f.path) for f in os.scandir(os.path.join(r"$(test_directory)", "items")) if f.is_dir()] |
# - common # - common
# - check # - check
# - console # - console