File: opt-in.t

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 (26 lines) | stat: -rw-r--r-- 548 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
24
25
26
#!/usr/bin/env raku

use Test;
use JSON::Unmarshal;
use JSON::OptIn;
use JSON::Name;

plan 3;

class OptInClass {

    has Str $.not_opted_in = "original";
    has Str $.opted_in     is json;
}

my $json = '{ "not_opted_in" : "not original", "opted_in" : "something" }';

my $obj;

lives-ok { $obj = unmarshal($json, OptInClass, :opt-in) }, 'unmarshal with opt-in';

is $obj.not_opted_in, 'original', "attribute not marked explicitly not populated from JSON";
is $obj.opted_in, 'something', "attribute marked is set";

done-testing;
# vim: ft=raku