Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 149 lines (120 sloc) 3.446 kb
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
1 use v6;
2
3 use Test;
4
1a356d7d »
2009-02-13 [t/spec] tests for RT #61034
5 plan 24;
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
6
7 # L<S04/The do-once loop/"can't" put "statement modifier">
d2862052 »
2010-04-01 [t/spec] Correct and unfudge some tests.
8 # Note in accordance with STD, conditionals are OK, loops are not.
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
9 eval_dies_ok 'my $i = 1; do { $i++ } while $i < 5;',
10 "'do' can't take the 'while' modifier";
11
12 eval_dies_ok 'my $i = 1; do { $i++ } until $i > 4;',
13 "'do' can't take the 'until' modifier";
14
15 eval_dies_ok 'my $i; do { $i++ } for 1..3;',
16 "'do' can't take the 'for' modifier";
17
18 eval_dies_ok 'my $i; do { $i++ } given $i;',
19 "'do' can't take the 'given' modifier";
20
d2862052 »
2010-04-01 [t/spec] Correct and unfudge some tests.
21 eval_lives_ok 'my $i; do { $i++ } unless $i;',
22 "'do' can take the 'unless' modifier";
23
24 eval_lives_ok 'my $i = 1; do { $i++ } if $i;',
25 "'do' can take the 'if' modifier";
26
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
27 # L<S04/The do-once loop/statement "prefixing with" do>
28 {
29 my $x;
30 my ($a, $b, $c) = 'a' .. 'c';
31
32 $x = do if $a { $b } else { $c };
33 is $x, 'b', "prefixing 'if' statement with 'do' (then)";
34
35 $x = do if !$a { $b } else { $c };
36 is $x, 'c', "prefixing 'if' statement with 'do' (else)";
4d3ec378 »
2008-12-22 [t/spec]: Unfudge a spectest in do.t.
37 }
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
38
39 =begin comment
40 If the final statement is a conditional which does not execute
8f9a1198 »
2009-11-25 [t/] unify compartmentalized undef and Object concepts into Mu
41 any branch, the return value is undefined in item context and ()
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
42 in list context.
43 =end comment
8f9a1198 »
2009-11-25 [t/] unify compartmentalized undef and Object concepts into Mu
44 #?rakudo skip 'if returning Nil'
4d3ec378 »
2008-12-22 [t/spec]: Unfudge a spectest in do.t.
45 {
e704067f »
2009-02-10 [t/spec] some more variable declaration fixes
46 my $x = do if 0 { 1 } elsif 0 { 2 };
8f9a1198 »
2009-11-25 [t/] unify compartmentalized undef and Object concepts into Mu
47 ok !$x.defined, 'when if does not execute any branch, return undefined';
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
48 }
49
50 {
51 my $ret = do given 3 {
52 when 3 { 1 }
53 };
54 is($ret, 1, 'do STMT works');
55 }
56
57 {
58 my $ret = do { given 3 {
59 when 3 { 1 }
60 } };
61 is($ret, 1, 'do { STMT } works');
62 }
63
64 # L<S04/The do-once loop/"you may use" do "on an expression">
65 {
66 my $ret = do 42;
67 is($ret, 42, 'do EXPR should also work (single number)');
68
69 $ret = do 3 + 2;
70 is($ret, 5, 'do EXPR should also work (simple + expr)');
71
72 $ret = do do 5;
73 is($ret, 5, 'nested do (1)');
74
75 $ret = do {do 5};
76 is($ret, 5, 'nested do (2)');
77
78 # precedence decisions do not cross a do boundary
79 $ret = 2 * do 2 + 5;
2e3530bc »
2009-01-09 [t/spec] Typo - s/ precendence / precedence /
80 is($ret, 14, 'do affects precedence correctly');
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
81 }
82
83 # L<S04/The do-once loop/"can take" "loop control statements">
0da6e8ff »
2009-05-17 [t/spec] stop rakudo from prematurely aborting do.t
84 #?rakudo skip 'next() should also work on do blocks (?)'
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
85 {
86 my $i;
87 do {
88 $i++;
89 next;
90 $i--;
91 };
92 is $i, 1, "'next' works in 'do' block";
93 }
94
95 #?rakudo skip 'last not implemented'
96 {
97 is eval('
98 my $i;
99 do {
100 $i++;
101 last;
102 $i--;
103 };
104 $i;
105 '), 1, "'last' works in 'do' block";
106 }
107
108 # IRC notes:
109 # <agentzh> audreyt: btw, can i use redo in the do-once loop?
110 # <audreyt> it can, and it will redo it
111 #?rakudo skip 'redo not implemented'
112 {
113 is eval('
114 my $i;
115 do {
116 $i++;
117 redo if $i < 3;
118 $i--;
119 };
120 $i;
121 '), 2, "'redo' works in 'do' block";
122 }
123
3152b01e »
2008-08-04 [t] some updates to README, and fixed all but one smartlink in t/spec/
124 # L<S04/The do-once loop/"bare block is not a do-once">
499fea91 »
2008-07-17 [gsoc_spectest] moved do.t into spec, added tests, fudged for rakudo.…
125 {
126 eval_dies_ok 'my $i; { $i++; next; $i--; }',
127 "bare block can't take 'next'";
128
129 eval_dies_ok 'my $i; { $i++; last; $i--; }',
130 "bare block can't take 'last'";
131
132 eval_dies_ok 'my $i; { $i++; redo; $i--; }',
133 "bare block can't take 'last'";
134 }
135
136 # L<S04/Statement parsing/"final closing curly on a line"
137 # reverts to semicolon>
138 {
139 my $a = do {
140 1 + 2;
141 } # no trailing `;'
142 is $a, 3, "final `}' on a line reverted to `;'";
143 }
1a356d7d »
2009-02-13 [t/spec] tests for RT #61034
144
f11daa54 »
2010-03-12 [t/spec] re-fudge do.t for rakudo
145 #?rakudo todo 'regression on RT 61034'
146 lives_ok { my $a = do given 5 {} }, 'empty do block lives (RT 61034)';
1a356d7d »
2009-02-13 [t/spec] tests for RT #61034
147
148 # vim: ft=perl6
Something went wrong with that request. Please try again.