Skip to content

Commit 34ef6de

Browse files
committed
Removed some bogus tests, added some more Nil related tests
1 parent f962b6d commit 34ef6de

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

S02-types/undefined-types.t

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use v6;
22
use Test;
3-
plan 41;
3+
plan 49;
44

55
# L<S02/Names and Variables/The empty>
66

@@ -10,23 +10,24 @@ plan 41;
1010
ok ().defined, '() is defined';
1111
my @a= 1, Nil, 3;
1212
is @a.elems, 2, 'Nil as part of list, is empty list';
13-
@a.push: Nil;
13+
ok (@a.push: Nil) =:= @a, "Pushing Nil returns same array";
1414
is @a.elems, 2, 'Pushing Nil in list context is empty list';
15-
@a.unshift: Nil;
15+
ok (@a.unshift: Nil) =:= @a, "Unshifting Nil returns same array";
1616
is @a.elems, 2, 'Unshifting Nil in list context is empty list';
17-
} #5
17+
is (@a = Nil), Nil, "Setting to Nil returns Nil";
18+
is @a.elems, 0, 'Setting to Nil restores original state';
19+
} #7
1820

1921
# typed scalar
2022
#?pugs skip "doesn't know typed stuff"
2123
#?niecza skip "doesn't know typed stuff"
22-
#?rakudo skip "not allowed to assign Nil to Int scalar"
2324
{
2425
my Int $a = 1;
25-
is $a.WHAT, '(Int)', "Check that we have an 'Int' scalar";
26-
ok !defined($a = Nil), "assigning Nil to Int should work";
26+
#?rakudo skip "not allowed to assign Nil to Int scalar"
27+
is ($a = Nil), Nil, "assigning Nil to Int should work";
28+
#?rakudo todo "not allowed to assign Nil to Int scalar"
2729
ok !$a.defined, "Nil makes undefined here";
28-
is $a.WHAT, '(Int)', "Nil keeps Int type on scalar";
29-
} #4
30+
} #2
3031

3132
# typed array
3233
#?pugs skip "doesn't know typed stuff"
@@ -36,15 +37,19 @@ plan 41;
3637
#?rakudo todo ".clone doesn't copy typedness"
3738
is @a.of, '(Int)', "Check that we have an 'Int' array";
3839
is @a.elems, 2, 'Nil as part of Int list, is empty list';
39-
@a.push: Nil;
40+
ok ( @a.push: Nil ) =:= @a, "assigning Nil returns same array";
4041
is @a.elems, 2, 'Pushing Nil in Int list context is empty list';
41-
@a.unshift: Nil;
42+
ok ( @a.unshift: Nil ) =:= @a, "assigning Nil returns same array";
4243
is @a.elems, 2, 'Unshifting Nil in Int list context is empty list';
43-
#?rakudo 3 skip "not allowed to assign Nil to Int scalar"
44+
#?rakudo skip "not allowed to assign Nil to Int scalar"
4445
ok !defined(@a[1] = Nil), "assigning Nil to Int should work";
46+
#?rakudo todo "not allowed to assign Nil to Int scalar"
4547
ok !@a[1].defined, "Nil makes undefined here";
46-
is @a[1].WHAT, '(Int)', "Nil keeps Int type on scalar";
47-
} #7
48+
is ( @a = Nil ), Nil, "setting to Nil returns Nil";
49+
#?rakudo todo ".clone doesn't copy typedness"
50+
is @a.of, '(Int)', "Check that we still have an 'Int' array";
51+
is @a.elems, 0, 'Setting to Nil restores original state';
52+
} #11
4853

4954
# typed hash
5055
#?pugs skip "doesn't know typed stuff"
@@ -54,11 +59,14 @@ plan 41;
5459
#?rakudo todo ".clone doesn't copy typedness"
5560
is %a.of, '(Int)', "Check that we have an 'Int' hash";
5661
is %a.elems, 2, 'Nil as part of Int list, is empty pair';
57-
#?rakudo 3 skip "not allowed to assign Nil to Int scalar"
58-
ok !defined( %a<b> = Nil ), "assigning Nil to hash element should work";
62+
#?rakudo skip "not allowed to assign Nil to Int scalar"
63+
is ( %a<b> = Nil ), Nil, "assigning Nil to hash element should work";
5964
ok !%a<b>.defined, "Nil makes undefined here";
60-
is %a<b>.WHAT, '(Int)', "Nil keeps Int type on scalar";
61-
} #5
65+
is ( %a = Nil ), Nil, "setting to Nil returns Nil";
66+
#?rakudo todo ".clone doesn't copy typedness"
67+
is %a.of, '(Int)', "Check that we still have an 'Int' hash";
68+
is %a.elems, 0, 'Setting to Nil restores original state';
69+
} #7
6270

6371
# sink context returns Nil
6472
{

0 commit comments

Comments
 (0)