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
Added tests for .perl on hashes, explicitely typed or not
- Loading branch information
Showing
1 changed file
with
45 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,45 @@ | ||
| use v6; | ||
| use Test; | ||
|
|
||
| plan 12; | ||
|
|
||
| #?pugs todo "cannot roundtrip hashes" | ||
| #?niecza todo "cannot roundtrip hashes" | ||
| # simple hash | ||
| { | ||
| my %h = a => 1, b => 2; | ||
| is %h.perl, '("a" => 1, "b" => 2).hash', | ||
| 'can we serialize a simple hash'; | ||
| my $rh = eval(%h.perl); | ||
| is_deeply $rh, %h, 'can we roundtrip simple hash'; | ||
| ok $rh.of =:= Mu, 'make sure any value can be stored'; | ||
| ok $rh.keyof =:= Any, 'make sure keys are Any'; | ||
| } #4 | ||
|
|
||
| #?pugs todo "cannot roundtrip hashes with constrained values" | ||
| #?niecza todo "cannot roundtrip hashes with constrained values" | ||
| # hash with constrained values | ||
| { | ||
| my Int %h = a => 1, b => 2; | ||
| is %h.perl, 'Hash[Int].new("a" => 1, "b" => 2)', | ||
| 'can we serialize a hash with constrained values'; | ||
| my $rh = eval(%h.perl); | ||
| is_deeply $rh, %h, 'can we roundtrip hash constrained values'; | ||
| ok $rh.of =:= Int, 'make sure roundtripped values are Int'; | ||
| ok $rh.keyof =:= Any, 'make sure roundtripped keys are Any'; | ||
| } #4 | ||
|
|
||
| #?pugs todo "cannot roundtrip hashes with constrained keys & values" | ||
| #?niecza todo "cannot roundtrip hashes with constrained keys & values" | ||
| # hash with constrained keys & values | ||
| { | ||
| my Int %h{Str} = a => 1, b => 2; | ||
| is %h.perl, 'Hash[Int,Str].new("a" => 1, "b" => 2)', | ||
| 'can we serialize a hash with constrained keys & values'; | ||
| my $rh = eval(%h.perl); | ||
| is_deeply $rh, %h, 'can we roundtrip hash constrained keys & values'; | ||
| ok $rh.of =:= Int, 'make sure roundtripped values are Int'; | ||
| ok $rh.keyof =:= Str, 'make sure roundtripped keys are Str'; | ||
| } #4 | ||
|
|
||
| #vim: ft=perl6 |