Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
some fudging of S02-literals/quoting, S04-declarations/{my, state}; f…
…ixes
  • Loading branch information
sorear committed Jul 12, 2011
1 parent d71768c commit 8cc349a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
34 changes: 22 additions & 12 deletions S02-literals/quoting.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 153;
plan 152;

my $foo = "FOO";
my $bar = "BAR";
Expand Down Expand Up @@ -145,6 +145,7 @@ Note that non-ASCII tests are kept in quoting-unicode.t
# L<S02/Literals/using the \qq>
#?rakudo skip 'q[..] with variations'
#?niecza skip 'backslash q'
{ # \qq[] constructs interpolate in q[]
my ( @q1, @q2, @q3, @q4 ) = ();
@q1 = q[$foo \qq[$bar]];
Expand All @@ -164,12 +165,12 @@ Note that non-ASCII tests are kept in quoting-unicode.t
is(@q4[0], '$foo $bar', "and interpolates correctly");
}
{ # quote with \0 as delimiters L<news:20050101220112.GF25432@plum.flirble.org>
my @q = ();
eval "\@q = (q\0foo bar\0)";
is(+@q, 1, "single quote with \\0 delims are parsed ok");
is(@q[0], "foo bar", "and return correct value");
};
# quote with \0 as delimiters, forbidden by STD
# but see L<news:20050101220112.GF25432@plum.flirble.org>
#?rakudo skip 'retriage'
{
eval_dies_ok "(q\0foo bar\0)";
}
{ # traditional quote word
my @q = ();
Expand Down Expand Up @@ -329,8 +330,6 @@ FOO
{ # Q L<S02/Literals/No escapes at all>
my @q = ();
my $backslash = "\\";
@q = (Q/foo\\bar$foo/);
is(+@q, 1, "Q// is singular");
Expand Down Expand Up @@ -358,6 +357,7 @@ FOO
};
#?rakudo skip '\c97 etc'
#?niecza skip 'charspec'
{ # weird char escape sequences
is("\c97", "a", '\c97 is "a"');
is("\c102oo", "foo", '\c102 is "f", works next to other letters');
Expand Down Expand Up @@ -403,11 +403,11 @@ Hello, World
# Q
{
my $s1 = "hello";
my $s1 = "hello"; #OK not used
my $t1 = Q /$s1, world/;
is $t1, '$s1, world', "Testing for Q operator.";
my $s2 = "你好";
my $s2 = "你好"; #OK not used
my $t2 = Q /$s2, 世界/;
is $t2, '$s2, 世界', "Testing for Q operator. (utf8)";
}
Expand All @@ -426,31 +426,36 @@ Hello, World
# q:x
#?rakudo skip 'q:x'
#?niecza skip 'q:x'
{
my $result = %*VM.perl ~~ /MSWIN32/ ?? "hello\r\n" !! "hello\n";
is q:x/echo hello/, $result, "Testing for q:x operator.";
}
# utf8
#?rakudo skip 'q:x'
#?niecza skip 'q:x'
{
# 一 means "One" in Chinese.
is q:x/echo 一/, "\n", "Testing for q:x operator. (utf8)";
}
#?rakudo skip 'qq:x'
#?niecza skip ':x'
{
my $world = 'world';
is qq:x/echo hello $world/, "hello world\n", 'Testing qq:x operator';
}
#?rakudo skip 'q:x assigned to array'
#?niecza skip ':x'
{
my @two_lines = q:x/echo hello ; echo world/;
is @two_lines, ("hello\n", "world\n"), 'testing q:x assigned to array';
}
#?rakudo skip 'q:x assigned to array'
#?niecza skip ':x'
{
my $hello = 'howdy';
my @two_lines = qq:x/echo $hello ; echo world/;
Expand All @@ -471,6 +476,7 @@ Hello, World
# q:f
#?rakudo skip 'quoting adverbs'
#?niecza skip '& escape'
{
my sub f { "hello" };
my $t = q:f /&f(), world/;
Expand All @@ -491,6 +497,7 @@ Hello, World
# q:a
#?rakudo skip 'quoting adverbs'
#?niecza skip 'zen slices'
{
my @t = qw/a b c/;
my $s = q:a /@t[]/;
Expand All @@ -511,15 +518,17 @@ Hello, World
# multiple quoting modes
#?rakudo skip 'quoting adverbs'
#?niecza skip 'zen slices'
{
my $s = 'string';
my @a = <arr1 arr2>;
my %h = (foo => 'bar');
my %h = (foo => 'bar'); #OK not used
is(q:s:a'$s@a[]%h', $s ~ @a ~ '%h', 'multiple modifiers interpolate only what is expected');
}
# shorthands:
#?rakudo skip 'quoting adverbs'
#?niecza skip '& escape, zen slices'
{
my $alpha = 'foo';
my $beta = 'bar';
Expand Down Expand Up @@ -555,6 +564,7 @@ Hello, World
eval_dies_ok 'rx:g{foo}', 'g does not make sense on rx//';
}
#?niecza skip 'qx'
{
my $var = 'world';
is qx/echo world/.chomp, "world", 'qx';
Expand Down
15 changes: 11 additions & 4 deletions S04-declarations/my.t
Expand Up @@ -22,6 +22,7 @@ plan 68;
{
my $ret = 42;
lives_ok { $ret = (my $x) ~ $x }, 'my() variable is visible (1)';
#?niecza skip 'Any()Any()'
is $ret, "", 'my() variable is visible (2)';
}

Expand Down Expand Up @@ -188,27 +189,31 @@ my $z = 42;
}

# &variables don't need to be pre-declared
# (but they need to exist by CHECK)
{
#?rakudo todo '&-sigiled variables'
eval_lives_ok '&x; 1', '&x does not need to be pre-declared';
eval_lives_ok '&x; 1; sub x {}', '&x does not need to be pre-declared';
eval_dies_ok '&x()', '&x() dies when empty';
}

# RT #62766
{
eval_lives_ok 'my $a;my $x if 0;$a = $x', 'my $x if 0';

#?niecza skip 'CATCH'
eval_lives_ok 'my $a;do { 1/0; my $x; CATCH { $a = $x.defined } }';

{
#?rakudo 2 todo 'OUTER and SETTING'
#?niecza 2 skip 'OUTER and SETTING'
ok eval('not OUTER::<$x>.defined'), 'OUTER::<$x>';
ok eval('not SETTING:<$x>.defined'), 'SETTING::<$x>';
my $x;
}

{
my $a;
#?niecza 2 skip 'CATCH'
#?rakudo todo 'fails'
eval_lives_ok 'do { 1/0;my Int $x;CATCH { $a = ?($x ~~ Int) } }';
#?rakudo todo 'previous test skipped'
Expand All @@ -231,15 +236,16 @@ my $z = 42;
}

# used to be RT #76366, #76466
#?rakudo skip 'nom regression'
#?rakudo skip 'nom regression, OUR::'
{
nok access_lexical_a().defined,
nok OUR::access_lexical_a().defined,
'can call our-sub that accesses a lexical before the block was run';
{
my $a = 42;
our sub access_lexical_a() { $a }
}
is access_lexical_a(), 42,
#?niecza skip 'NYI'
is OUR::access_lexical_a(), 42,
'can call our-sub that accesses a lexical after the block was run';

}
Expand All @@ -254,6 +260,7 @@ eval_lives_ok 'my $x = 3; class A { has $.y = $x; }; say A.new.y',

{
#?rakudo skip 'RT 72814'
#?niecza skip 'a not predeclared'
lives_ok {my ::a $a}, 'typing a my-declared variable as ::a works.'; #OK not used
}

Expand Down
1 change: 0 additions & 1 deletion S04-declarations/state.t
Expand Up @@ -266,7 +266,6 @@ plan 38;
is $seensize, 11, "[list] assignment state in fib memoizes";
}

#?niecza skip 'subset'
{
# now we're just being plain evil:
subset A of Int where { $_ < state $x++ };
Expand Down

0 comments on commit 8cc349a

Please sign in to comment.