File: 030-null.rakutest

package info (click to toggle)
raku-json-unmarshal 0.15-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: makefile: 4
file content (23 lines) | stat: -rw-r--r-- 631 bytes parent folder | download
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