File: 130-custom-accessor.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 (27 lines) | stat: -rw-r--r-- 454 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
#!/usr/bin/env raku

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

class CustomAttr {
    has Int $.int = 10;

    has Str $.string;

    method string( --> Str ) {
        "TESTSTRING";
    }

}

my $obj = CustomAttr.new;

my $json = marshal($obj);
my $data = from-json($json);

is $data<int>, $obj.int, "got the right value for straight accessor";
is $data<string>, $obj.string, "got the right value for custom accessor";

done-testing;
# vim: ft=raku