1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#!/usr/bin/env raku
use v6.*;
use Test;
use JSON::Unmarshal;
plan 4;
my Str $json = '{ "attr" : null }';
my @tests = %( "class" => class { has Int $.attr; }, description => "Int attribute" ),
%( "class" => class { has Num $.attr; }, description => "Num attribute" ),
%( "class" => class { has Rat $.attr; }, description => "Rat attribute" ),
%( "class" => class { has Str $.attr; }, description => "Str attribute" ),;
for @tests -> $test {
my $obj;
lives-ok { $obj = unmarshal($json, $test<class> ) }, $test<description>;
}
done-testing;
# vim: expandtab shiftwidth=4 ft=raku
|