File: 090-issue-8.t

package info (click to toggle)
raku-json-marshal 0.0.25-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 4
file content (52 lines) | stat: -rw-r--r-- 886 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env raku

use v6;

use Test;

use JSON::Marshal;
use JSON::Fast;

class C {

}

class D {
    has Str $.gh;
}

my @tests = (
    {
        description => "class with no attributes",
        type_object => C,
    },
    {
        description => "class with attributes",
        type_object => D,
    },
    {
        description => "Hash type object",
        type_object => Hash,
    },
    {
        description => "Array type object",
        type_object => Array,
    },
);

for @tests -> $test {
    subtest {
        my $out;
        lives-ok { $out = marshal($test<type_object>) }, "marshal type-object";
        my $in = from-json($out);
        nok $in.defined, "roundtripped value not defined";
        ok $in ~~ Any, "it's an Any";
        ok $in !~~ Hash, "and it's not a hash";


    }, $test<description>;
}


done-testing;
# vim: expandtab shiftwidth=4 ft=raku