Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 79 lines (64 sloc) 1.596 kb
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-sta…
dr_df0 authored
1 use v6;
2
3 use Test;
4
f113f3f @jnthn Tests covering regression in given/for s.m.
jnthn authored
5 plan 11;
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-sta…
dr_df0 authored
6
7 # L<S04/"Conditional statements"/Conditional statement modifiers work as in Perl 5>
8
9 # test the ``given'' statement modifier
10 {
10b3165 [spec] all tests in S04-statement-modifiers fudged for rakudo plus mi…
dr_df0 authored
11 my $a = 0;
12 $a = $_ given 2 * 3;
13 is($a, 6, "post given");
14 }
15
16 # test the ``given'' statement modifier
17 {
18 my $a;
19 $a = $_ given 2 * 3;
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-sta…
dr_df0 authored
20 is($a, 6, "post given");
21 }
22
23 {
10b3165 [spec] all tests in S04-statement-modifiers fudged for rakudo plus mi…
dr_df0 authored
24 my $a = '';
1e0f570 [t/spec]: Eliminate some "Redeclared variable" warnings in tests
pmichaud authored
25 $a = $_ given 'a';
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-sta…
dr_df0 authored
26 is($a, 'a', "post given");
27 }
28
282b062 @usev6 Unfudge some more passing tests for Parrot
usev6 authored
29 # RT #121049
ce545c7 @raydiak Add test for RT #121049 - postfix given in a loop
raydiak authored
30 {
282b062 @usev6 Unfudge some more passing tests for Parrot
usev6 authored
31 my $a = '';
32 for ^2 { my $b = $_ given 'a'; $a ~= $b; }
33 is($a, 'aa', 'post given in a loop');
ce545c7 @raydiak Add test for RT #121049 - postfix given in a loop
raydiak authored
34 }
35
48992f8 [t/spec] fix all remaining broken smartlinks
moritz authored
36 # L<S04/The C<for> statement/for and given privately temporize>
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-sta…
dr_df0 authored
37 {
10b3165 [spec] all tests in S04-statement-modifiers fudged for rakudo plus mi…
dr_df0 authored
38 my $i = 0;
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-sta…
dr_df0 authored
39 $_ = 10;
40 $i += $_ given $_+3;
41 is $_, 10, 'outer $_ did not get updated in lhs of given';
42 is $i, 13, 'postfix given worked';
43 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
44
bdf4af4 @TimToady test scoping of "{$_}" given ...
TimToady authored
45 # RT #100746
46 {
47 $_ = 'bogus';
48 my @r = gather { take "{$_}" given 'cool' }
49 is @r[0], 'cool', 'given modifies the $_ that is visible to the {} interpolator';
50 }
51
8c29100 @jnthn Tests for RT #111704.
jnthn authored
52 # RT #111704
53 {
54 my $a = 'many ';
55 try { $a ~= $_ } given 'pelmeni';
56 is $a, 'many pelmeni', 'Correct $_ in try block in statement-modifying given';
57 }
58
8ab25b4 @jnthn Tests for block s.m. given/if/unless.
jnthn authored
59 {
60 my $a;
61 { $a = $^x } given 69;
62 is $a, 69, 'given modifier with $_-using block runs block with correct arg';
63 }
64
65 {
66 my $a;
67 { $a = $^x } given 42;
68 is $a, 42, 'given modifier with placeholder block runs block with correct arg';
69 }
70
f113f3f @jnthn Tests covering regression in given/for s.m.
jnthn authored
71 {
72 # Covers a bug where the block to first got compiled in the 'given' thunk
73 my @a;
74 for ^2 -> \c { 1 given first { @a.push(c); 0 }, ^2; };
75 is @a, (0, 0, 1, 1), 'given thunk does not mess up statement modifier closures';
76 }
77
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
78 # vim: ft=perl6
Something went wrong with that request. Please try again.