File: 055jtm.t

package info (click to toggle)
libtm-perl 1.53-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,780 kB
  • ctags: 594
  • sloc: perl: 34,611; sh: 377; makefile: 50
file content (91 lines) | stat: -rw-r--r-- 2,164 bytes parent folder | download | duplicates (3)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use strict;
use warnings;

use Test::More qw(no_plan);
use TM::Materialized::AsTMa;

require_ok ('TM::Materialized::JTM');
require_ok ('TM::Serializable::JTM');

{
    my $tm = new TM::Materialized::JTM;
    ok ($tm->isa('TM::Materialized::JTM'),'correct class 1');
    ok ($tm->isa('TM::Materialized::Stream'),'correct class 2');
    ok ($tm->isa('TM'),'correct class 3');
}

# prime testdata
my $tm = new TM::Materialized::AsTMa (baseuri=>"tm://", inline=>'
nackertes_topic 

atop
bn: just a topic

btop (ctop)
bn: something
bn@ascope: some other thing

ctop
bn: over the top!
in: something
in: somemore
oc: http://somewhere
in@ascope: scoped
in@ascope (sometype): also typed
oc (sometype): http://typedoc
oc @ascope (sometype): http://typedandscopedoc

(sucks-more-than)
sucker: ctop
winner: atop
winner: others

(sucks-more-than) @ascope
sucker: nobody
winner: nobody

thistop reifies http://rumsti
bn: reification
in: reification
sin: http://nowhere.never.ever
sin: http://nowhere.ever.never

sometopic 
bn: some topic that reifies an internal other topic

othertopic is-reified-by sometopic 
bn: the reified target

# is-reified-by sometopic

(sucks-more-than) is-reified-by atop
winner: nobody
sucker: nobody

')->sync_in;

Class::Trait->apply($tm,"TM::Serializable::JTM");
{
    my ($d,$tm2);
    ok($d=$tm->serialize,"serialize to json works");
    
    ok($tm2 = new TM::Materialized::JTM(baseuri=>"tm://",inline => $d)->sync_in,"deserialize from json works");

    is_deeply( $tm2->{mid2iid},    $tm->{mid2iid},    'toplet structure survived unchanged' );
    is_deeply( $tm2->{assertions}, $tm->{assertions}, 'asserts structure survived unchanged' );
}

{
    my ($d,$tm2);
    ok($d=$tm->serialize(format=>"yaml"),"serialize to yaml works");
    ok($d=~/^---[^{}\[\]]+$/s,"the result is indeed yaml, not just json");
    
    ok($tm2 = new TM::Materialized::JTM(baseuri=>"tm://",format=>"yaml", inline => $d)->sync_in,"deserialize from yaml works");

    is_deeply( $tm2->{mid2iid},    $tm->{mid2iid},    'toplet structure survived unchanged' );
    is_deeply( $tm2->{assertions}, $tm->{assertions}, 'asserts structure survived unchanged' );
}