Skip to content

Commit

Permalink
tests for Nil.method/.[]/.{}/[]/{}
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Dec 29, 2013
1 parent f355189 commit 5ffc8ff
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion S02-types/nil.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Test;

# Nil may be a type now. Required?

plan 37;
plan 48;

sub empty_sub {}
sub empty_do { do {} }
Expand Down Expand Up @@ -105,6 +105,26 @@ ok !Nil.new.defined, 'Nil.new is not defined';
ok $_.VAR.default === Nil, '$_ has Nil as default';
}

# calling methods and similar things on Nil should return Nil again
{
sub niltest { return Nil };

ok niltest() === Nil, "sanity";
ok niltest.foo === Nil, "calling methods on Nil gives Nil again I";
ok niltest.foo.bar === Nil, "calling methods on Nil gives Nil again II";
ok niltest.foo.bar.baz === Nil, "calling methods on Nil gives Nil again III";

ok niltest[0] === Nil, "array access on Nil gives Nil again I";
ok niltest[0][2] === Nil, "array access on Nil gives Nil again II";
ok niltest[0][2][4] === Nil, "array access on Nil gives Nil again III";

ok niltest<foo> === Nil, "hash access on Nil gives Nil again I";
ok niltest<foo><bar> === Nil, "hash access on Nil gives Nil again II";
ok niltest<foo><bar><A> === Nil, "hash access on Nil gives Nil again II";

ok niltest.foo.bar.<bar>.[12].[99].<foo> === Nil, ".<> and .[] works properly, too";
}

done;

# vim: ft=perl6

0 comments on commit 5ffc8ff

Please sign in to comment.