diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-10 18:37:24 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-10 18:37:24 +0200 |
commit | 9ea4368ff1e4842286e0e7a6aec58a2c2c799d5b (patch) | |
tree | 47d31fa6d686dd50220edfa505fcc21ce6c860fe /tests | |
parent | 39164c57d893b02f9a253c661abc2459bcd57e5c (diff) |
treewide: implement default lstrip_blocks and trim_blocks behaviour
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/00_syntax/04_statement_blocks | 8 | ||||
-rw-r--r-- | tests/00_syntax/07_embedded_single_line_comments | 3 | ||||
-rw-r--r-- | tests/00_syntax/08_embedded_multi_line_comments | 3 | ||||
-rw-r--r-- | tests/00_syntax/12_block_whitespace_control | 3 | ||||
-rw-r--r-- | tests/00_syntax/15_function_declarations | 8 | ||||
-rw-r--r-- | tests/00_syntax/16_for_loop | 9 | ||||
-rw-r--r-- | tests/00_syntax/17_while_loop | 3 | ||||
-rw-r--r-- | tests/00_syntax/18_if_condition | 6 | ||||
-rw-r--r-- | tests/01_arithmetic/04_inc_dec | 1 |
9 files changed, 20 insertions, 24 deletions
diff --git a/tests/00_syntax/04_statement_blocks b/tests/00_syntax/04_statement_blocks index faafd9a..920ed71 100644 --- a/tests/00_syntax/04_statement_blocks +++ b/tests/00_syntax/04_statement_blocks @@ -8,11 +8,13 @@ Alternatively print it: {% -- End -- -- Testcase -- -The result of 3 * 7 is {% print(3 * 7) %}. -A statement block may contain multiple statements: {% +The result of 3 * 7 is {%+ print(3 * 7) %}. +A statement block may contain multiple statements: {%+ print("Hello "); print("World"); %} + To escape the start tag, output it as string expression: {{ "{%" }} -Alternatively print it: {% print("{%") %} +Alternatively print it: {%+ print("{%") %} + -- End -- diff --git a/tests/00_syntax/07_embedded_single_line_comments b/tests/00_syntax/07_embedded_single_line_comments index 8c5fd4a..43f188c 100644 --- a/tests/00_syntax/07_embedded_single_line_comments +++ b/tests/00_syntax/07_embedded_single_line_comments @@ -11,10 +11,11 @@ Statement blocks may use C++ comments too: Test Another test. The result of 5 + 9 is {{ // The block end tag is ignored: }} // And the expression block continues here! 5 + 9 }}. -Statement blocks may use C++ comments too: {% +Statement blocks may use C++ comments too: {%+ print("Test"); // A comment. // Another comment. print(" Another test."); %} + -- End -- diff --git a/tests/00_syntax/08_embedded_multi_line_comments b/tests/00_syntax/08_embedded_multi_line_comments index b27554f..75aba5f 100644 --- a/tests/00_syntax/08_embedded_multi_line_comments +++ b/tests/00_syntax/08_embedded_multi_line_comments @@ -12,7 +12,7 @@ Statement blocks may use C comments too: Test Another test. The final test. -- Testcase -- The result of 12 - 4 is {{ /* A comment before */ 12 - /* or even within */ 4 /* or after an expression */ }}. -Statement blocks may use C comments too: {% +Statement blocks may use C comments too: {%+ print("Test"); /* A comment. */ /* Another comment. */ @@ -20,4 +20,5 @@ Statement blocks may use C comments too: {% print(/* A comment within */ " The final test."); %} + -- End -- diff --git a/tests/00_syntax/12_block_whitespace_control b/tests/00_syntax/12_block_whitespace_control index 23f7380..911171c 100644 --- a/tests/00_syntax/12_block_whitespace_control +++ b/tests/00_syntax/12_block_whitespace_control @@ -22,7 +22,7 @@ expected too.This is after the block. -- Testcase -- Whitespace control applies to all block types: Comment before: | {#- test #} |, after: | {#- test #} |, both: | {#- test -#} | -Statement before: | {%- print("test") %} |, after: | {% print("test") -%} |, both: | {%- print("test") -%} | +Statement before: | {%- print("test") %} |, after: | {%+ print("test") -%} |, both: | {%- print("test") -%} | Expression before: | {{- "test" }} |, after: | {{ "test" -}} |, both: | {{- "test" -}} | By default whitespace {{ "around a block" }} is retained. @@ -37,6 +37,7 @@ Stripping works across multiple lines as well: print("test") %} + Likewise, stripping over multiple lines of trailing whitespace works as expected too. diff --git a/tests/00_syntax/15_function_declarations b/tests/00_syntax/15_function_declarations index 846f379..cb391a4 100644 --- a/tests/00_syntax/15_function_declarations +++ b/tests/00_syntax/15_function_declarations @@ -17,9 +17,9 @@ function() { ... } function test_fn(a, b) { ... } function test2_fn(a, b) { ... } - A function declaration using the alternative syntax: The function was called with arguments 123 and 456. + -- End -- -- Testcase -- @@ -50,10 +50,8 @@ The function was called with arguments 123 and 456. %} A function declaration using the alternative syntax: - -{%- function test3_fn(a, b): %} +{% function test3_fn(a, b): %} The function was called with arguments {{ a }} and {{ b }}. -{%- endfunction -%} - +{% endfunction %} {{ test3_fn(123, 456) }} -- End -- diff --git a/tests/00_syntax/16_for_loop b/tests/00_syntax/16_for_loop index 61e86a1..4c233bc 100644 --- a/tests/00_syntax/16_for_loop +++ b/tests/00_syntax/16_for_loop @@ -20,7 +20,6 @@ Iteration 7 Iteration 8 Iteration 9 - If the loop body consists of only one statement, the curly braces may be omitted: Iteration 0 @@ -34,7 +33,6 @@ Iteration 7 Iteration 8 Iteration 9 - Any of the init-, test- and increment expressions may be omitted. Loop without initialization statement: @@ -42,30 +40,25 @@ Iteration null Iteration 1 Iteration 2 - Loop without test statement: Iteration 0 Iteration 1 Iteration 2 - Loop without init-, test- or increment statement: Iteration 1 Iteration 2 Iteration 3 - For-in loop enumerating object properties: Key: foo Key: bar - For-in loop enumerating array items: Item: one Item: two Item: three - A counting for-loop using the alternative syntax: Iteration 0 Iteration 1 @@ -78,12 +71,10 @@ Iteration 7 Iteration 8 Iteration 9 - A for-in loop using the alternative syntax: Item 123 Item 456 Item 789 - -- End -- -- Testcase -- diff --git a/tests/00_syntax/17_while_loop b/tests/00_syntax/17_while_loop index 6d6dc4a..4dfaccc 100644 --- a/tests/00_syntax/17_while_loop +++ b/tests/00_syntax/17_while_loop @@ -18,7 +18,6 @@ Iteration 7 Iteration 8 Iteration 9 - If the loop body consists of only one statement, the curly braces may be omitted: Iteration 0 @@ -32,7 +31,6 @@ Iteration 7 Iteration 8 Iteration 9 - A counting while-loop using the alternative syntax: Iteration null Iteration 1 @@ -44,7 +42,6 @@ Iteration 6 Iteration 7 Iteration 8 Iteration 9 - -- End -- -- Testcase -- diff --git a/tests/00_syntax/18_if_condition b/tests/00_syntax/18_if_condition index 0148466..9601f11 100644 --- a/tests/00_syntax/18_if_condition +++ b/tests/00_syntax/18_if_condition @@ -40,6 +40,7 @@ This should print "one": } %} + This should print "two": {% x = 1; @@ -52,6 +53,7 @@ This should print "two": } %} + Multiple conditions can be used by chaining if/else statements: {% x = 2; @@ -70,6 +72,7 @@ Multiple conditions can be used by chaining if/else statements: } %} + If the conditional block consists of only one statement, the curly braces may be omitted: {% @@ -81,6 +84,7 @@ braces may be omitted: print("two"); %} + An if-condition using the alternative syntax: {% if (x == 1): -%} Variable x was set to one. @@ -88,6 +92,7 @@ Variable x was set to one. Variable x has another value. {% endif %} + Ternary expressions function similar to if/else statements but only allow for a single expression in the true and false branches: {% @@ -96,4 +101,5 @@ only allow for a single expression in the true and false branches: print(s); %} + -- End -- diff --git a/tests/01_arithmetic/04_inc_dec b/tests/01_arithmetic/04_inc_dec index 6647ced..5a048fe 100644 --- a/tests/01_arithmetic/04_inc_dec +++ b/tests/01_arithmetic/04_inc_dec @@ -28,7 +28,6 @@ Incrementing a non-numeric value will convert it to a number: 3.5 2 NaN - -- End -- -- Testcase -- |