Permalink
Browse files

move heredoc tests into their own file.

  • Loading branch information...
1 parent 649d8b2 commit 79af6257d1ca4f57fabc3a8ca89515a1f6dfe017 @timo timo committed Jul 12, 2013
Showing with 92 additions and 52 deletions.
  1. +91 −0 S02-literals/heredocs.t
  2. +1 −52 S02-literals/quoting.t
@@ -0,0 +1,91 @@
+use Test;
+plan 10;
+
+my $foo = "FOO";
+my $bar = "BAR";
+
+sub no-r(Str $in) { $in.subst(/\r/, '', :g) }
+
+# L<S02/Heredocs/Heredocs are no longer written>
+{ # qq:to
+ my @q = ();
+
+ @q = qq:to/FOO/;
+blah
+$bar
+blah
+$foo
+FOO
+
+ is(+@q, 1, "q:to// is singular");
+ is(no-r(@q[0]), "blah\nBAR\nblah\nFOO\n", "here doc interpolated");
+};
+
+{ # qq:to
+ my @q = ();
+
+ @q = qq:to/FOO/;
+ blah
+ $bar
+ blah
+ $foo
+ FOO
+
+ is(no-r(@q[0]), "blah\nBAR\nblah\nFOO\n", "here doc interpolating with indentation");
+};
+
+# L<S02/Optional whitespace/Heredocs allow optional whitespace>
+{ # q:to indented
+ my @q = ();
+
+ @q = q:to/FOO/;
+ blah blah
+ $foo
+ FOO
+
+ is(+@q, 1, "q:to// is singular, also when indented");
+ is(no-r(@q[0]), "blah blah\n\$foo\n", "indentation stripped");
+};
+
+{ # q:heredoc backslash bug
+ my @q = q:heredoc/FOO/
+yoink\n
+splort\\n
+FOO
+;
+ is(+@q, 1, "q:heredoc// is singular");
+ is(no-r(@q[0]), "yoink\\n\nsplort\\n\n", "backslashes");
+}
+
+my $multiline = "Hello\nWorld";
+
+# some dedent tests
+{
+ my @q = qq:to/END/;
+ first line
+ $multiline
+ another line
+ END
+
+ is no-r(@q[0]), "first line\nHello\nWorld\nanother line\n", "indent with multiline interpolation";
+}
+
+$multiline = "Hello\n World";
+{
+ my @q = qq:to/END/;
+ first line
+ $multiline
+ another line
+ END
+
+ is no-r(@q[0]), "first line\nHello\n World\nanother line\n", "indent with multiline interpolation with spaces at the beginning";
+}
+{
+ my @q = qq:to/END/;
+ first line
+ $multiline something
+ another line
+ END
+
+ is no-r(@q[0]), "first line\nHello\n World something\nanother line\n", "extra spaces after interpolation will be kept";
+}
@@ -1,6 +1,6 @@
use v6;
use Test;
-plan 162;
+plan 155;
my $foo = "FOO";
my $bar = "BAR";
@@ -281,57 +281,6 @@ Note that non-ASCII tests are kept in quoting-unicode.t
is(@q2[2], '$bar', 'single quoted $bar was not interpolated');
};
-# L<S02/Heredocs/Heredocs are no longer written>
-{ # qq:to
- my @q = ();
-
- @q = qq:to/FOO/;
-blah
-$bar
-blah
-$foo
-FOO
-
- is(+@q, 1, "q:to// is singular");
- is(@q[0].subst(/\r/, '', :g), "blah\nBAR\nblah\nFOO\n", "here doc interpolated");
-};
-
-{ # qq:to
- my @q = ();
-
- @q = qq:to/FOO/;
- blah
- $bar
- blah
- $foo
- FOO
-
- is(@q[0].subst(/\r/, '', :g), "blah\nBAR\nblah\nFOO\n", "here doc interpolating with indentation");
-};
-
-# L<S02/Optional whitespace/Heredocs allow optional whitespace>
-{ # q:to indented
- my @q = ();
-
- @q = q:to/FOO/;
- blah blah
- $foo
- FOO
-
- is(+@q, 1, "q:to// is singular, also when indented");
- is(@q[0].subst(/\r/, '', :g), "blah blah\n\$foo\n", "indentation stripped");
-};
-
-{ # q:heredoc backslash bug
- my @q = q:heredoc/FOO/
-yoink\n
-splort\\n
-FOO
-;
- is(+@q, 1, "q:heredoc// is singular");
- is(@q[0].subst(/\r/, '', :g), "yoink\\n\nsplort\\n\n", "backslashes");
-}
-
#?pugs skip 'parsefail'
{ # Q L<S02/Literals/No escapes at all>
my @q = ();

0 comments on commit 79af625

Please sign in to comment.