Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 363 lines (282 sloc) 10.106 kb
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
08d48bd [t] Test suite refactoring.
cosimo authored
2 use Test;
bcf79d0 @lizmat Replace cargo-culted BEGIN {@*INC...} by use lib
lizmat authored
3 use lib 't/spec/packages';
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
4 use Test::Util;
08d48bd [t] Test suite refactoring.
cosimo authored
5
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
6 =begin pod
08d48bd [t] Test suite refactoring.
cosimo authored
7
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
8 'Mu' and 'undefine' tests
08d48bd [t] Test suite refactoring.
cosimo authored
9
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
10 This test file contains two sections: a port of the perl5 'undef.t' tests, and
08d48bd [t] Test suite refactoring.
cosimo authored
11 perl6-specific tests.
12
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
13 =end pod
08d48bd [t] Test suite refactoring.
cosimo authored
14
15 # Note: See thread "Undef issues" by Adrian Taylor on p6l
16 # L<http://groups.google.com/groups?threadm=20050601002444.GB32060@wall.org>
17 # On Tue, May 24, 2005 at 10:53:59PM +1000, Stuart Cook wrote:
18 # : I'm not sure whether this behaviour is supposed to be changing.
19 #
20 # It is. I think we decided to make the value undef, and the function
21 # undefine(). (But these days most values of undef really ought to
22 # be constructed and returned (or thrown) using fail().)
23 #
24 # Larry
25
9a695d3 @Mouq Add tests for RT #117777
Mouq authored
26 plan 93;
08d48bd [t] Test suite refactoring.
cosimo authored
27
28 our $GLOBAL;
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
29
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
30 # L<S32::Basics/Mu/=item defined>
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
31
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
32 ok(!defined(Mu), "Mu is not defined");
08d48bd [t] Test suite refactoring.
cosimo authored
33
34 {
35 my $a;
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
36 ok(!defined($a), "uninitialized lexicals are undefined");
08d48bd [t] Test suite refactoring.
cosimo authored
37
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
38 ok(!defined($GLOBAL), "uninitialized package vars are undefined");
08d48bd [t] Test suite refactoring.
cosimo authored
39
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
40 $a += 1;
08d48bd [t] Test suite refactoring.
cosimo authored
41 ok(defined($a), "initialized var is defined");
7e4bed3 @colomon Clean up niecza fudging.
colomon authored
42 #?niecza todo
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
43 is_run( 'my $a; $a += 1', { err => '', out => '', status => 0 },
44 'increment of undefined variable does not warn' );
08d48bd [t] Test suite refactoring.
cosimo authored
45
46 undefine $a;
8871f15 @dwarring supress a couple of warnings
dwarring authored
47 ok(!defined($a), 'undefine($a) does');
08d48bd [t] Test suite refactoring.
cosimo authored
48
49 $a = "hi";
50 ok(defined($a), "string");
51
52 my $b;
53 $a = $b;
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
54 ok(!defined($a), "assigning another undefined lexical");
08d48bd [t] Test suite refactoring.
cosimo authored
55
56 $a = $GLOBAL;
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
57 ok(!defined($a), "assigning another undefined global");
08d48bd [t] Test suite refactoring.
cosimo authored
58 }
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
59
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
60 # L<S32::Basics/Mu/"=item undefine">
08d48bd [t] Test suite refactoring.
cosimo authored
61 {
62 my @ary = "arg1";
63 my $a = @ary.pop;
64 ok(defined($a), "pop from array");
65 $a = @ary.pop;
66 ok(!defined($a), "pop from empty array");
67
68 @ary = "arg1";
69 $a = @ary.shift;
70 ok(defined($a), "shift from array");
71 $a = @ary.shift;
72 ok(!defined($a), "shift from empty array");
73
74 my %hash = ( bar => 'baz', quux => 'quuz' );
75 ok(defined(%hash<bar>), "hash subscript");
76 ok(!defined(%hash<bargho>), "non-existent hash subscript");
77
78 undefine %hash<bar>;
79 ok(!defined(%hash<bar>), "undefine hash subscript");
80
81 %hash<bar> = "baz";
6f3f981 @lizmat Replace use of .delete by :delete or .delete_key as appropriate
lizmat authored
82 %hash<bar>:delete;
08d48bd [t] Test suite refactoring.
cosimo authored
83 ok(!defined(%hash<bar>), "delete hash subscript");
84
85 ok(defined(@ary), "aggregate array defined");
86 ok(defined(%hash), "aggregate hash defined");
87
88 undefine(@ary);
9c40515 @dnmfarrell fixed appended RT number to be within quoted string
dnmfarrell authored
89 #?rakudo todo 'definedness of array RT #124563'
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
90 #?niecza todo 'definedness of array'
a20c69c [t/spec/*.t] :todo whackage
lwall authored
91 ok(!defined(@ary), "undefine array");
08d48bd [t] Test suite refactoring.
cosimo authored
92
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
93 #?niecza emit #
08d48bd [t] Test suite refactoring.
cosimo authored
94 undefine(%hash);
9c40515 @dnmfarrell fixed appended RT number to be within quoted string
dnmfarrell authored
95 #?rakudo todo 'definedness of hash RT #124564'
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
96 #?niecza todo 'definedness of hash'
a20c69c [t/spec/*.t] :todo whackage
lwall authored
97 ok(!defined(%hash), "undefine hash");
08d48bd [t] Test suite refactoring.
cosimo authored
98
99 @ary = (1);
100 ok(defined(@ary), "define array again");
101 %hash = (1,1);
102 ok(defined(%hash), "define hash again");
103 }
104
9c40515 @dnmfarrell fixed appended RT number to be within quoted string
dnmfarrell authored
105 #?rakudo skip 'access to &your_sub RT #124565'
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
106 #?niecza skip 'huh?'
08d48bd [t] Test suite refactoring.
cosimo authored
107 {
108 sub a_sub { "møøse" }
109
110 ok(defined(&a_sub), "defined sub");
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
111 ok(EVAL('defined(%«$?PACKAGE\::»<&a_sub>)'), "defined sub (symbol table)");
08d48bd [t] Test suite refactoring.
cosimo authored
112
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
113 ok(EVAL('!defined(&a_subwoofer)'), "undefined sub");
114 ok(EVAL('!defined(%«$?PACKAGE\::»<&a_subwoofer>)'), "undefined sub (symbol table)");
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
115
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
116 dies-ok { undefine &a_sub }, 'die trying to undefine a sub';
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
117 ok defined &a_sub, 'sub is still defined after attempt to undefine';
08d48bd [t] Test suite refactoring.
cosimo authored
118 }
119
120 # TODO: find a read-only value to try and assign to, since we don't
121 # have rules right now to play around with (the p5 version used $1)
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
122 #EVAL { "constant" = "something else"; };
08d48bd [t] Test suite refactoring.
cosimo authored
123 #is($!, "Modification of a read", "readonly write yields exception");
124
125 # skipped tests for tied things
126
127 # skipped test for attempt to undef a bareword -- no barewords here.
128
129 # TODO: p5 "bugid 3096
130 # undefing a hash may free objects with destructors that then try to
131 # modify the hash. To them, the hash should appear empty."
132
133
134 # Test LHS assignment to undef:
297e783 [t] and [t/spec]
moritz authored
135 # XXX shouldn't that be * instead of undef?
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
136 # yes, this chunk should move to a different file --Larry
08d48bd [t] Test suite refactoring.
cosimo authored
137
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
138 {
139 my $interesting;
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
140 (*, *, $interesting) = (1,2,3);
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
141 is($interesting, 3, "Undef on LHS of list assignment");
08d48bd [t] Test suite refactoring.
cosimo authored
142
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
143 (*, $interesting, *) = (1,2,3);
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
144 is($interesting, 2, "Undef on LHS of list assignment");
08d48bd [t] Test suite refactoring.
cosimo authored
145
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
146 ($interesting, *, *) = (1,2,3);
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
147 is($interesting, 1, "Undef on LHS of list assignment");
08d48bd [t] Test suite refactoring.
cosimo authored
148
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
149 sub two_elements() { (1,2) };
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
150 (*,$interesting) = two_elements();
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
151 is($interesting, 2, "Undef on LHS of function assignment");
08d48bd [t] Test suite refactoring.
cosimo authored
152
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
153 ($interesting, *) = two_elements();
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
154 is($interesting, 1, "Undef on LHS of function assignment");
155 }
08d48bd [t] Test suite refactoring.
cosimo authored
156
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
157 =begin pod
08d48bd [t] Test suite refactoring.
cosimo authored
158
159 Perl6-specific tests
160
f660aa6 [t/spec] Possibly converted all remaining pod markers to pod6
cosimo authored
161 =end pod
08d48bd [t] Test suite refactoring.
cosimo authored
162
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
163 #?niecza skip 'fun with undefine'
08d48bd [t] Test suite refactoring.
cosimo authored
164 {
165 # aggregate references
166
167 my @ary = (<a b c d e>);
168 my $ary_r = @ary; # ref
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
169 isa-ok($ary_r, Array);
08d48bd [t] Test suite refactoring.
cosimo authored
170 ok(defined($ary_r), "array reference");
171
172 undefine @ary;
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
173 ok(!+$ary_r, "undefine array referent");
08d48bd [t] Test suite refactoring.
cosimo authored
174
175 is(+$ary_r, 0, "dangling array reference");
176
177 my %hash = (1, 2, 3, 4);
178 my $hash_r = %hash;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
179 isa-ok($hash_r, "Hash");
08d48bd [t] Test suite refactoring.
cosimo authored
180 ok(defined($hash_r), "hash reference");
181 undefine %hash;
182 ok(defined($hash_r), "undefine hash referent:");
183 is(+$hash_r.keys, 0, "dangling hash reference");
184 }
185
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
186 #?niecza skip 'push does not vivify'
08d48bd [t] Test suite refactoring.
cosimo authored
187 {
188 my Array $an_ary;
189 ok(!defined($an_ary), "my Array");
827e592 @moritz rakudo un/refudges
moritz authored
190 nok( defined($an_ary[0]) , "my Array subscript - Mu");
191 $an_ary.push("blergh");
192 ok(defined($an_ary.pop), "push");
193 nok(defined($an_ary.pop), "comes to shove");
02df239 Unfudge some passing autoviv tests.
pmichaud authored
194 }
08d48bd [t] Test suite refactoring.
cosimo authored
195
02df239 Unfudge some passing autoviv tests.
pmichaud authored
196 {
08d48bd [t] Test suite refactoring.
cosimo authored
197 my Hash $a_hash;
198
a850bf0 @moritz simplify tests
moritz authored
199 nok(defined($a_hash), "my Hash");
200 nok(defined($a_hash<blergh>), "my Hash subscript - Mu");
201 nok(defined($a_hash<blergh>), "my Hash subscript - Mu, no autovivification happened");
08d48bd [t] Test suite refactoring.
cosimo authored
202
203 $a_hash<blergh> = 1;
6f3f981 @lizmat Replace use of .delete by :delete or .delete_key as appropriate
lizmat authored
204 ok(defined($a_hash<blergh>:delete), "delete");
205 nok(defined($a_hash<blergh>:delete), " - once only");
02df239 Unfudge some passing autoviv tests.
pmichaud authored
206 }
207
08d48bd [t] Test suite refactoring.
cosimo authored
208
02df239 Unfudge some passing autoviv tests.
pmichaud authored
209 {
08d48bd [t] Test suite refactoring.
cosimo authored
210 class Dog {};
211 my Dog $spot;
212
213 ok(!defined($spot), "Unelaborated mutt");
214 $spot .= new;
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
215 ok(defined($spot), " - now real");
08d48bd [t] Test suite refactoring.
cosimo authored
216 }
217
218 # rules
219 # TODO. refer to S05
220 # L<S05/Match objects/"they will all be undefined" closure
221 # "let keyword">
222
ea2ee24 [STD] various bugs
lwall authored
223 # - unmatched alternative should bind to undef
9c40515 @dnmfarrell fixed appended RT number to be within quoted string
dnmfarrell authored
224 #?rakudo skip 'Cannot use bind operator with this left-hand side RT #124566'
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
225 #?niecza skip 'unspeclike use of %MY::'
ece272c [t/spec] fudged undef.t for rakudo
moritz authored
226 #?DOES 10
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
227 {
4ad9719 [undef.t] there is no my() function...declarators require space
lwall authored
228 my ($num, $alpha);
8dc7d4b [t/spec] mark various tests that intentionally declare things that ar…
lwall authored
229 my ($rx1, $rx2); #OK not used
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
230 EVAL '
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
231 $rx1 = rx
232 / [ (\d+) { let $<num> := $0 }
233 | (<alpha>+) { let $<alpha> := $1 }
234 ]
235 /;
236 $rx2 = rx
237 / [ $<num> := (\d+)
238 | $<alpha>:= (<alpha>+)
239 ]
240 /;
241 ';
242 for (<rx1 rx2>) {
243 # I want symbolic lookups because I need the rx names for test results.
244
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
245 EVAL '"1" ~~ %MY::{$_}';
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
246 ok(defined($num), '{$_}: successful hypothetical');
247 ok(!defined($alpha), '{$_}: failed hypothetical');
248
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
249 EVAL '"A" ~~ %MY::{$_}';
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
250 ok(!defined($num), '{$_}: failed hypothetical (2nd go)');
251 ok(defined($alpha), '{$_}: successful hypothetical (2nd go)');
252 }
08d48bd [t] Test suite refactoring.
cosimo authored
253
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
254 # - binding to hash keys only would leave values undefined
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
255 EVAL '"a=b\nc=d\n" ~~ / $<matches> := [ (\w) = \N+ ]* /';
256 ok(EVAL('$<matches> ~~ all(<a b>)'), "match keys exist");
08d48bd [t] Test suite refactoring.
cosimo authored
257
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
258 #ok(!defined($<matches><a>) && !defined($<matches><b>), "match values don't");
259 ok(0 , "match values don't");
260 }
3604100 more buglets
lwall authored
261
ece272c [t/spec] fudged undef.t for rakudo
moritz authored
262 #?DOES 1
08d48bd [t] Test suite refactoring.
cosimo authored
263 {
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
264 # - $0, $1 etc. should all be undefined after a failed match
08d48bd [t] Test suite refactoring.
cosimo authored
265 # (except for special circumstances)
972b6e4 [t/spec] simplify a few tests to use /../ instead of rx/../
moritz authored
266 "abcde" ~~ /(.)(.)(.)/;
267 "abcde" ~~ /(\d)/;
08d48bd [t] Test suite refactoring.
cosimo authored
268 ok((!try { grep { defined($_) }, ($0, $1, $2, $3, $4, $5) }),
269 "all submatches undefined after failed match") or
5bab36f @FROGGS eval => EVAL in S14 to S32
FROGGS authored
270 diag("match state: " ~ EVAL '$/');
08d48bd [t] Test suite refactoring.
cosimo authored
271
272 # XXX write me: "special circumstances"
273 }
274
275
276 # subroutines
277 {
278 sub bar ($bar, $baz?, :$quux) {
279 is($bar, "BAR", "defined param"); # sanity
280
60d29c6 fix some legacy smartlink syntax
szabgab authored
281 # L<S06/Optional parameters/Missing optional arguments>
08d48bd [t] Test suite refactoring.
cosimo authored
282 ok(!defined($baz), "unspecified optional param");
283
60d29c6 fix some legacy smartlink syntax
szabgab authored
284 # L<S06/Named parameters/Named parameters are optional>
08d48bd [t] Test suite refactoring.
cosimo authored
285 ok(!defined($quux), "unspecified optional param");
286 }
287
288 bar("BAR");
289
290 }
291
292 # autoloading
293 # L<S10/Autoloading>
294
295 # Currently waiting on
296 # - packages
297 # - symtable hash
298 # - autoloading itself
299
300 # Extra tests added due to apparent bugs
173bb69 [t/spec] correct undef.t, and fudge for rakudo
moritz authored
301 is((Any) + 1, 1, 'Any + 1');
302 is(1 + (Any), 1, '1 + Any');
303 is((Any) * 2, 0, 'Any * 2');
304 is(2 * (Any), 0, '2 * Any');
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
305 is-deeply([(Any) xx 2], [Any, Any], 'Any xx 2');
173bb69 [t/spec] correct undef.t, and fudge for rakudo
moritz authored
306 is((Any) * (Any), 0, 'Any * Any');
08d48bd [t] Test suite refactoring.
cosimo authored
307
308 # L<http://colabti.de/irclogger/irclogger_log/perl6?date=2006-09-12,Tue&sel=145#l186>
309 # See log above. From IRC, TimToady says that both of these
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
310 # should be false. (At time of writing, @(Mu,) is true.)
9c40515 @dnmfarrell fixed appended RT number to be within quoted string
dnmfarrell authored
311 #?rakudo 2 todo 'todo: lists, defined, truthness RT #124567'
702aa34 @coke niecza auto-unfudge
coke authored
312 #?niecza 2 todo 'huh?'
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
313 is ?(@(Mu,)), Bool::False, '?(@(Mu,)) is false';
314 is ?(list(Mu,)), Bool::False, '?(@(Mu,)) is false';
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
315
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
316 #?niecza todo 'dubious'
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
317 lives-ok { uc(EVAL("")) }, 'can use EVAL("") in further expressions';
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
318
319 {
320 sub lie { Bool::False }
321 ok lie() ~~ Bool, 'sub returns a bool';
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
322 dies-ok { undefine lie }, 'attempt to undefine returned Bool type dies';
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
323 ok lie() ~~ Bool, 'sub still returns a bool';
324 }
325
326 {
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
327 sub def is rw { my $x = [] } #OK not used
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
328 ok def() ~~ Array, 'sub returns array';
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
329 lives-ok { undefine def }, 'attempt to undefine returned array lives';
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
330 ok def() ~~ Array, 'sub still returns array';
331
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
332 dies-ok { undefine &def }, 'attempt to undefine sub dies';
33dd00a @sorear Fudge S32-scalar/undef.t for niecza
sorear authored
333 ok defined(&def), 'attempt to undefine sub fails';
f000672 [t/spec] Test suggested by moritz++
kyle authored
334 ok def() ~~ Array, 'can still call sub after attempt to undefine it';
ae01205 [t/spec] Tests inspired by IRC: http://irclog.perlgeek.de/perl6/2009-…
kyle authored
335 }
336
29deb7f [t/spec] test that you can undefine a lexical variable twice; RT #69238
moritz authored
337 # RT #69238
338 {
339 sub foo { my $a = "baz"; undefine $a; undefine $a; $a; }
340 ok !defined(foo()), 'can undefine $a twice without any troubles';
341 }
342
9a695d3 @Mouq Add tests for RT #117777
Mouq authored
343 # RT #117777
344 {
345 my $a = "foo";
346 undefine($a) = "bar";
347 is $a, "bar", "undefine is rw";
348 my $b = my $c = my $d is default(42) = "foo";
349 {
350 undefine temp $b;
351 temp undefine($c);
352 temp undefine($d) = "baz";
353 is $b, Any, "Can undefine temp \$var";
354 is $c, Any, "Can temp undefine \$var";
355 is $d, "baz", "Can temp undefine \$var + assignment";
356 }
357 is $b, "foo", "temp restores value before undefine";
358 is $c, Any, "temp restores value after undefine";
359 is $d, 42, "temp restore default value after undefine";
360 }
361
5f0915d [t/spec] partially fudge undef.t for rakudo. Pending fudge bugs.
moritz authored
362 # vim: ft=perl6
Something went wrong with that request. Please try again.