Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 107 lines (84 sloc) 1.995 kb
a203f3a [spec] moved statements/repeat.t to spec/, cleaned up a test
moritz authored
1 use v6;
2
3 use Test;
4
5 plan 16;
6
7 # L<S04/The C<repeat> statement/"more Pascal-like repeat loop">
8
9 {
10 my $x = 0; repeat { $x++ } while $x < 10;
11 is($x, 10, 'repeat {} while');
12 }
13
14 {
15 my $x = 1; repeat { $x++ } while 0;
16 is($x, 2, 'ensure repeat {} while runs at least once');
17 }
18
19 {
20 my $x = 0;
21 repeat { $x++; redo if $x < 10 } while 0;
22 is($x, 10, 'redo works in repeat');
23 }
24
25 # L<S04/The C<repeat> statement/"or equivalently">
26
27 {
28 my $x = 0; repeat { $x++ } until $x >= 10;
29 is($x, 10, 'repeat {} until');
30 }
31
32 {
33 my $x = 1; repeat { $x++ } until 1;
34 is($x, 2, 'ensure repeat {} until runs at least once');
35 }
36
37 {
1a543c0 [t/spec] Unfudge some redo tests.
pmichaud authored
38 my $x = 0; repeat { $x++; redo if $x < 10 } until 1;
a203f3a [spec] moved statements/repeat.t to spec/, cleaned up a test
moritz authored
39 is($x, 10, 'redo works in repeat {} until');
40 }
41
42 # L<S04/The C<repeat> statement/"loop conditional" on
43 # "repeat block" required>
44 {
45 my $x = 0;
46 repeat {
47 $x++;
48 $x += 2;
49 } while $x < 10;
50
51 is $x, 12, 'repeat with "} while"';
52 }
53
54 {
55 my $x = 0;
56 repeat {
57 $x++;
58 $x += 2;
59 }
60 while $x < 10;
61
62 is $x, 12, 'repeat with "}\n while"';
63 }
64
65 # L<S04/The C<repeat> statement/put "loop conditional" "at the front">
66 {
67 my $x = 0; repeat while $x < 10 { $x++ }
68 is($x, 10, 'repeat {} while');
69 }
70
71 {
72 my $x = 1; repeat while 0 { $x++ }
73 is($x, 2, 'ensure repeat {} while runs at least once');
74 }
75
76 {
1a543c0 [t/spec] Unfudge some redo tests.
pmichaud authored
77 my $x = 0; repeat while 0 { $x++; redo if $x < 10 };
a203f3a [spec] moved statements/repeat.t to spec/, cleaned up a test
moritz authored
78 is($x, 10, 'redo works in repeat');
79 }
80
81 {
82 my $x = 0; repeat until $x >= 10 { $x++ }
83 is($x, 10, 'repeat until {}');
84 }
85
86 # L<S04/The C<repeat> statement/"bind the result">
299bab9 [spec] fudged repeat.t
moritz authored
87 #?rakudo skip 'point block on loop'
a203f3a [spec] moved statements/repeat.t to spec/, cleaned up a test
moritz authored
88 {
89 my $x = 0; repeat until $x >= 10 -> $another_x {
90 pass('repeat until with binding starts undefined') unless $another_x.defined;
91 $x++
92 }
93 is($x, 10, 'repeat until -> {}');
94 }
95
96 {
97 my $x = 1; repeat until 1 { $x++ }
98 is($x, 2, 'ensure repeat until {} runs at least once');
99 }
100
101 {
1a543c0 [t/spec] Unfudge some redo tests.
pmichaud authored
102 my $x = 0; repeat until 1 { $x++; redo if $x < 10 };
a203f3a [spec] moved statements/repeat.t to spec/, cleaned up a test
moritz authored
103 is($x, 10, 'redo works in repeat until {}');
104 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
105
106 # vim: ft=perl6
Something went wrong with that request. Please try again.