Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (44 sloc) 1.009 kb
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-statem...
dr_df0 authored
1 use v6;
2
3 use Test;
4
bdf4af4 @TimToady test scoping of "{$_}" given ...
TimToady authored
5 plan 7;
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-statem...
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 minor...
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-statem...
dr_df0 authored
20 is($a, 6, "post given");
21 }
22
23 {
10b3165 [spec] all tests in S04-statement-modifiers fudged for rakudo plus minor...
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-statem...
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-statem...
dr_df0 authored
37 {
10b3165 [spec] all tests in S04-statement-modifiers fudged for rakudo plus minor...
dr_df0 authored
38 my $i = 0;
fde97fb [spec] moved all tests from t/statemens/modifiers into t/spec/S04-statem...
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
282b062 @usev6 Unfudge some more passing tests for Parrot
usev6 authored
46 #?rakudo.moar todo "RT #100746"
47 #?rakudo.jvm todo "RT #100746"
bdf4af4 @TimToady test scoping of "{$_}" given ...
TimToady authored
48 {
49 $_ = 'bogus';
50 my @r = gather { take "{$_}" given 'cool' }
51 is @r[0], 'cool', 'given modifies the $_ that is visible to the {} interpolator';
52 }
53
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
54 # vim: ft=perl6
Something went wrong with that request. Please try again.