Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Some tests for "is default" on scalars
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| use v6; | ||
| use Test; | ||
|
|
||
| plan 20; | ||
|
|
||
| # L<S02/Variables Containing Undefined Values | ||
|
|
||
| #?pugs skip "is default NYI" | ||
| #?niecza skip "is default NYI" | ||
| # not specifically typed | ||
| { | ||
| my $a is default(42); | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 42, "uninitialized untyped variable should have its default"; | ||
| lives_ok { $a++ }, "should be able to update untyped variable"; | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 43, "update of untyped variable to 43 was successful"; | ||
| lives_ok { $a = Nil }, "should be able to assign Nil to untyped variable"; | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 42, "untyped variable returned to its default with Nil"; | ||
| lives_ok { $a = 314 }, "should be able to update untyped variable"; | ||
| is $a, 314, "update of untyped variable to 314 was successful"; | ||
| lives_ok { undefine $a }, "should be able to undefine untyped variable"; | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 42, "untyped variable returned to its default with undefine"; | ||
|
|
||
| my $b is default(42) = 768; | ||
| is $b, 768, "untyped variable should be initialized"; | ||
| } #10 | ||
|
|
||
| #?pugs skip "Int is default NYI" | ||
| #?niecza skip "Int is default NYI" | ||
| # typed | ||
| { | ||
| my Int $a is default(42); | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 42, "uninitialized typed variable should have its default"; | ||
| lives_ok { $a++ }, "should be able to update typed variable"; | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 43, "update of typed variable to 43 was successful"; | ||
| lives_ok { $a = Nil }, "should be able to assign Nil to typed variable"; | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 42, "typed variable returned to its default with Nil"; | ||
| lives_ok { $a = 314 }, "should be able to update typed variable"; | ||
| is $a, 314, "update of typed variable to 314 was successful"; | ||
| lives_ok { undefine $a }, "should be able to undefine typed variable"; | ||
| #?rakudo todo "is default not functioning yet" | ||
| is $a, 42, "typed variable returned to its default with undefine"; | ||
|
|
||
| my Int $b is default(42) = 768; | ||
| is $b, 768, "typed variable should be initialized"; | ||
| } #10 | ||
|
|
||
| # vim: ft=perl6 |