Skip to content

Commit

Permalink
Basic testing for escapes
Browse files Browse the repository at this point in the history
Could be hardened further...
  • Loading branch information
Polgár Márton committed Mar 20, 2023
1 parent cbb6a62 commit 1d0c3b0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions t/10-challenge-escape.rakutest
@@ -0,0 +1,39 @@
use Test;
use Template6;

my Template6 $t .= new();

plan 5;

$t.add-template('brackets_after_space_hardcoded',q:to<END>);
{{ foo }}
END

is $t.process('brackets_after_space_hardcoded').chomp, ' {{ foo }}', 'Brackets after a space, hardcoded.';

$t.add-template('brackets_beginning_hardcoded',q:to<END>);
{{ foo }}
END

is $t.process('brackets_beginning_hardcoded').chomp, '{{ foo }}', 'Brackets at the very beginning, hardcoded.';

$t.add-template('unescape_attempt',Q:to<END>);
\qq{{ foo }}
END

is $t.process('unescape_attempt').chomp, '\\qq{{ foo }}', 'Attempting to break out of literal quoting.';

my $template-content = Q:to<END>;
END1END2END3
END1
END2
END4
END
$t.add-template('heredoc_terminal_attempt',$template-content);
my $used-delimiter = $t.service.context.parser.get-safe-delimiter($template-content);


is $t.process('heredoc_terminal_attempt').chomp, "END1END2END3\nEND1\nEND2\nEND4", 'Attempting to break out of heredoc.';
is $used-delimiter, 'END3', 'The right delimiter was used in the internal form.';

# vim: expandtab shiftwidth=4

0 comments on commit 1d0c3b0

Please sign in to comment.