TM
view release on metacpan or search on metacpan
t/041astmafact.t view on Meta::CPAN
#warn Dumper $ms; exit;
is (scalar $ms->match_forall (type => 'isa', irole => 'class', iplayer => 'tm:bbb'), 2, 'two types for bbb');
ok (eq_array ([
$ms->mids ('aaa', 'bbb', 'ccc')
],
[
'tm:aaa', 'tm:bbb', 'tm:ccc'
]), 'aaa, bbb, ccc internalized');
}
{ #-- structural
my $ms = _parse ('aaa (bbb)
');
#warn Dumper $ms;
is (scalar $ms->match (TM->FORALL, type => 'isa', arole => 'instance', aplayer => 'tm:aaa',
brole => 'class', bplayer => 'tm:bbb'), 1, 'one type for aaa');
ok (eq_array ([
$ms->mids ('aaa', 'bbb')
],
[
'tm:aaa', 'tm:bbb'
]), 'aaa, bbb internalized');
}
{
my $ms = _parse ('aaa
');
#warn Dumper $ms;
is ($ms->mids ('aaa'), 'tm:aaa', 'aaa implicitely internalized');
}
{ # structural topic
my $ms = _parse (q|
aaa is-a bbb
bn: AAA
oc: http://BBB
in: blabla bla
|);
#warn Dumper $ms;
is (scalar $ms->match (TM->FORALL, type => 'isa', irole => 'instance', iplayer => 'tm:aaa' ), 1, 'one type for aaa');
is (scalar $ms->match (TM->FORALL, irole => 'thing', iplayer => 'tm:aaa' ), 4, 'chars for aaa');
is (scalar $ms->match (TM->FORALL, type => 'name', irole => 'thing', iplayer => 'tm:aaa' ), 1, 'basenames for aaa');
is (scalar $ms->match (TM->FORALL, type => 'occurrence', irole => 'thing', iplayer => 'tm:aaa' ), 2, 'occurrences for aaa 1');
}
{ # dangerous IDs
my $ms = _parse (q|
in-a is-a oc-a
in: aaaa
rd-b is-a ex-a
rd: bbbb
this.is.a.valid.topic.name
this.is.even-more.so.a_topic
in-line-with-policy
bn: goals of backup system must be in line with corp policies
in: eg: no backup of desktops
ex-suggested
bn: ex-suggested:
(is-a-variant-of)
in-a : in-line-with-policy
rd-b : ex-suggested
|);
#warn Dumper $ms;
foreach (qw(in-a oc-a rd-b ex-a this.is.a.valid.topic.name this.is.even-more.so.a_topic in-line-with-policy ex-suggested is-a-variant-of)) {
is ($ms->mids ($_), "tm:$_", "dangerous $_");
}
}
#-- syntactic issues ----------------------------------------------------------------
my $npa = scalar keys %{$TM::infrastructure->{assertions}};
my $npt = scalar keys %{$TM::infrastructure->{mid2iid}};
{
my $ms = _parse (q|
# this is AsTMa
|);
#warn Dumper $ms;
is (scalar $ms->match(), $npa, 'empty map 1 (assertions)');
is ($ms->toplets, $npt, 'empty map 2 (toplets)');
}
{ # empty line with blanks
my $ms = _parse (q|
topic1
topic2
|);
##warn Dumper $ms;
is (scalar $ms->toplets(), $npt+2, 'empty line contains blanks');
}
{ # empty lines with \r
my $ms = _parse (q|
topic1
topic2
topic3
|);
is (scalar $ms->toplets(), $npt+3, 'empty line \r contains blanks');
}
{ # using TABs as separators
my $ms = _parse (q|
topic1 ( topic2 )
# comment
|);
#warn Dumper $ms;
is (scalar $ms->toplets, $npt+2, 'using TABs as separators');
}
( run in 2.519 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )