Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (63 sloc) 1.245 kB
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
ba90e17 Tests for while and until loops
duff authored
2
94226b4 t/spec more smartlink fixes
szabgab authored
3 # L<S04/The C<while> and C<until> statements>
4
ba90e17 Tests for while and until loops
duff authored
5 use Test;
6
abbd86a [t/spec] Added test for required whitespace after a built-in statemen…
azawawi authored
7 plan 9;
ba90e17 Tests for while and until loops
duff authored
8
9 {
983f107 [rakudo] while/until statements now parse
particle authored
10 my $i = 0;
11 while $i < 5 { $i++; };
12 is($i, 5, 'while $i < 5 {} works');
ba90e17 Tests for while and until loops
duff authored
13 }
983f107 [rakudo] while/until statements now parse
particle authored
14
ba90e17 Tests for while and until loops
duff authored
15 {
983f107 [rakudo] while/until statements now parse
particle authored
16 my $i = 0;
17 while 5 > $i { $i++; };
18 is($i, 5, 'while 5 > $i {} works');
ba90e17 Tests for while and until loops
duff authored
19 }
983f107 [rakudo] while/until statements now parse
particle authored
20
ba90e17 Tests for while and until loops
duff authored
21 # with parens
22 {
983f107 [rakudo] while/until statements now parse
particle authored
23 my $i = 0;
24 while ($i < 5) { $i++; };
25 is($i, 5, 'while ($i < 5) {} works');
ba90e17 Tests for while and until loops
duff authored
26 }
983f107 [rakudo] while/until statements now parse
particle authored
27
ba90e17 Tests for while and until loops
duff authored
28 {
983f107 [rakudo] while/until statements now parse
particle authored
29 my $i = 0;
30 while (5 > $i) { $i++; };
31 is($i, 5, 'while (5 > $i) {} works');
ba90e17 Tests for while and until loops
duff authored
32 }
33
34 # single value
35 {
983f107 [rakudo] while/until statements now parse
particle authored
36 my $j = 0;
37 while 0 { $j++; };
38 is($j, 0, 'while 0 {...} works');
ba90e17 Tests for while and until loops
duff authored
39 }
983f107 [rakudo] while/until statements now parse
particle authored
40
ba90e17 Tests for while and until loops
duff authored
41 {
983f107 [rakudo] while/until statements now parse
particle authored
42 my $k = 0;
43 while $k { $k++; };
44 is($k, 0, 'while $var {...} works');
ba90e17 Tests for while and until loops
duff authored
45 }
46
983f107 [rakudo] while/until statements now parse
particle authored
47
fae1eae [re-smop] add a fuged ../../t/spec/S04-statements/while.t to TESTS
pmurias authored
48 #?mildew skip 1
ba90e17 Tests for while and until loops
duff authored
49 # L<S04/The C<for> statement/It is also possible to write>
50 # while ... -> $x {...}
51 {
52 my @array = 1..5;
aedfe39 [t/spec] Initialize the collecting string so avoid tangential issues …
colomon authored
53 my $str = "";
ba90e17 Tests for while and until loops
duff authored
54 while @array.pop -> $x {
55 $str ~= $x;
56 }
57 is $str, '54321', 'while ... -> $x {...} worked (1)';
58 }
59
fae1eae [re-smop] add a fuged ../../t/spec/S04-statements/while.t to TESTS
pmurias authored
60 #?mildew skip 1
ba90e17 Tests for while and until loops
duff authored
61 {
62 my @array = 0..5;
aedfe39 [t/spec] Initialize the collecting string so avoid tangential issues …
colomon authored
63 my $str = "";
ba90e17 Tests for while and until loops
duff authored
64 while pop @array -> $x {
65 $str ~= $x;
66 }
67 is $str, '54321', 'while ... -> $x {...} worked (2)';
68 }
abbd86a [t/spec] Added test for required whitespace after a built-in statemen…
azawawi authored
69
fae1eae [re-smop] add a fuged ../../t/spec/S04-statements/while.t to TESTS
pmurias authored
70 #?mildew skip 1
94226b4 t/spec more smartlink fixes
szabgab authored
71 # L<S04/Statement parsing/keywords require whitespace>
abbd86a [t/spec] Added test for required whitespace after a built-in statemen…
azawawi authored
72 {
0cbc065 @lizmat s/eval_dies_ok/eval-dies-ok/g
lizmat authored
73 eval-dies-ok('my $i = 1; while($i < 5) { $i++; }',
abbd86a [t/spec] Added test for required whitespace after a built-in statemen…
azawawi authored
74 'keyword needs at least one whitespace after it');
75 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
76
77 # vim: ft=perl6
Something went wrong with that request. Please try again.