| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
5754
|
use 5.008001; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
180
|
|
|
2
|
2
|
|
|
2
|
|
13
|
use utf8; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
14
|
|
|
3
|
2
|
|
|
2
|
|
49
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
81
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings FATAL => 'all'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
87
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
762
|
use Muldis::DB::Interface; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
########################################################################### |
|
9
|
|
|
|
|
|
|
########################################################################### |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ package Muldis::DB::Validator; # module |
|
12
|
|
|
|
|
|
|
our $VERSION = 0.004000; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Test::More; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
########################################################################### |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub main { |
|
19
|
|
|
|
|
|
|
my ($args) = @_; |
|
20
|
|
|
|
|
|
|
my ($engine_name, $dbms_config) |
|
21
|
|
|
|
|
|
|
= @{$args}{'engine_name', 'dbms_config'}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
plan( 'tests' => 12 ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
print |
|
26
|
|
|
|
|
|
|
"#### Muldis::DB::Validator starting test of $engine_name ####\n"; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Instantiate a Muldis DB DBMS / virtual machine. |
|
29
|
|
|
|
|
|
|
my $dbms = Muldis::DB::Interface::new_dbms({ |
|
30
|
|
|
|
|
|
|
'engine_name' => $engine_name, 'dbms_config' => $dbms_config }); |
|
31
|
|
|
|
|
|
|
does_ok( $dbms, 'Muldis::DB::Interface::DBMS' ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
_scenario_foods_suppliers_shipments_v1( $dbms ); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
print |
|
36
|
|
|
|
|
|
|
"#### Muldis::DB::Validator finished test of $engine_name ####\n"; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
########################################################################### |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _scenario_foods_suppliers_shipments_v1 { |
|
44
|
|
|
|
|
|
|
my ($dbms) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Declare our Perl-lexical variables to use for source data. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $src_suppliers |
|
49
|
|
|
|
|
|
|
= $dbms->new_var({ 'decl_type' => 'sys.Core.Relation.Relation' }); |
|
50
|
|
|
|
|
|
|
does_ok( $src_suppliers, 'Muldis::DB::Interface::Var' ); |
|
51
|
|
|
|
|
|
|
my $src_foods |
|
52
|
|
|
|
|
|
|
= $dbms->new_var({ 'decl_type' => 'sys.Core.Relation.Relation' }); |
|
53
|
|
|
|
|
|
|
does_ok( $src_foods, 'Muldis::DB::Interface::Var' ); |
|
54
|
|
|
|
|
|
|
my $src_shipments |
|
55
|
|
|
|
|
|
|
= $dbms->new_var({ 'decl_type' => 'sys.Core.Relation.Relation' }); |
|
56
|
|
|
|
|
|
|
does_ok( $src_shipments, 'Muldis::DB::Interface::Var' ); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Load our example literal source data sets into said Perl-lexicals. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$src_suppliers->store_ast({ |
|
61
|
|
|
|
|
|
|
'ast' => [ 'Relation', 'sys.Core.Relation.Relation', [ |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Hodgesons' ], |
|
64
|
|
|
|
|
|
|
'country' => [ 'NEText', 'Canada' ], |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Beckers' ], |
|
68
|
|
|
|
|
|
|
'country' => [ 'NEText', 'England' ], |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Wickets' ], |
|
72
|
|
|
|
|
|
|
'country' => [ 'NEText', 'Canada' ], |
|
73
|
|
|
|
|
|
|
}, |
|
74
|
|
|
|
|
|
|
] ], |
|
75
|
|
|
|
|
|
|
}); |
|
76
|
|
|
|
|
|
|
pass( 'no death from loading example suppliers data into VM' ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$src_foods->store_ast({ |
|
79
|
|
|
|
|
|
|
'ast' => [ 'Relation', 'sys.Core.Relation.Relation', [ |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Bananas' ], |
|
82
|
|
|
|
|
|
|
'colour' => [ 'NEText', 'yellow' ], |
|
83
|
|
|
|
|
|
|
}, |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Carrots' ], |
|
86
|
|
|
|
|
|
|
'colour' => [ 'NEText', 'orange' ], |
|
87
|
|
|
|
|
|
|
}, |
|
88
|
|
|
|
|
|
|
{ |
|
89
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Oranges' ], |
|
90
|
|
|
|
|
|
|
'colour' => [ 'NEText', 'orange' ], |
|
91
|
|
|
|
|
|
|
}, |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Kiwis' ], |
|
94
|
|
|
|
|
|
|
'colour' => [ 'NEText', 'green' ], |
|
95
|
|
|
|
|
|
|
}, |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Lemons' ], |
|
98
|
|
|
|
|
|
|
'colour' => [ 'NEText', 'yellow' ], |
|
99
|
|
|
|
|
|
|
}, |
|
100
|
|
|
|
|
|
|
] ], |
|
101
|
|
|
|
|
|
|
}); |
|
102
|
|
|
|
|
|
|
pass( 'no death from loading example foods data into VM' ); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$src_shipments->store_ast({ |
|
105
|
|
|
|
|
|
|
'ast' => [ 'Relation', 'sys.Core.Relation.Relation', [ |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Hodgesons' ], |
|
108
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Kiwis' ], |
|
109
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 100 ], |
|
110
|
|
|
|
|
|
|
}, |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Hodgesons' ], |
|
113
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Lemons' ], |
|
114
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 130 ], |
|
115
|
|
|
|
|
|
|
}, |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Hodgesons' ], |
|
118
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Oranges' ], |
|
119
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 10 ], |
|
120
|
|
|
|
|
|
|
}, |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Hodgesons' ], |
|
123
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Carrots' ], |
|
124
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 50 ], |
|
125
|
|
|
|
|
|
|
}, |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Beckers' ], |
|
128
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Carrots' ], |
|
129
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 90 ], |
|
130
|
|
|
|
|
|
|
}, |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Beckers' ], |
|
133
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Bananas' ], |
|
134
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 120 ], |
|
135
|
|
|
|
|
|
|
}, |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
|
|
|
|
|
|
'farm' => [ 'NEText', 'Wickets' ], |
|
138
|
|
|
|
|
|
|
'food' => [ 'NEText', 'Lemons' ], |
|
139
|
|
|
|
|
|
|
'qty' => [ 'PInt', 'perl_pint', 30 ], |
|
140
|
|
|
|
|
|
|
}, |
|
141
|
|
|
|
|
|
|
] ], |
|
142
|
|
|
|
|
|
|
}); |
|
143
|
|
|
|
|
|
|
pass( 'no death from loading example shipments data into VM' ); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Execute a query against the virtual machine, to look at our sample |
|
146
|
|
|
|
|
|
|
# data and see what suppliers there are for foods coloured 'orange'. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $desi_colour |
|
149
|
|
|
|
|
|
|
= $dbms->new_var({ 'decl_type' => 'sys.Core.Text.Text' }); |
|
150
|
|
|
|
|
|
|
does_ok( $desi_colour, 'Muldis::DB::Interface::Var' ); |
|
151
|
|
|
|
|
|
|
$desi_colour->store_ast({ 'ast' => [ 'NEText', 'orange' ] }); |
|
152
|
|
|
|
|
|
|
pass( 'no death from loading desired colour into VM' ); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $matched_suppl = $dbms->call_func({ |
|
155
|
|
|
|
|
|
|
'func_name' => 'sys.Core.Relation.semijoin', |
|
156
|
|
|
|
|
|
|
'args' => { |
|
157
|
|
|
|
|
|
|
'source' => $src_suppliers, |
|
158
|
|
|
|
|
|
|
'filter' => $dbms->call_func({ |
|
159
|
|
|
|
|
|
|
'func_name' => 'sys.Core.Relation.join', |
|
160
|
|
|
|
|
|
|
'args' => { |
|
161
|
|
|
|
|
|
|
'topic' => [ 'QuasiSet', |
|
162
|
|
|
|
|
|
|
'sys.Core.Spec.QuasiSetOfRelation', [ |
|
163
|
|
|
|
|
|
|
$src_shipments, |
|
164
|
|
|
|
|
|
|
$src_foods, |
|
165
|
|
|
|
|
|
|
[ 'Relation', 'sys.Core.Relation.Relation', [ |
|
166
|
|
|
|
|
|
|
{ |
|
167
|
|
|
|
|
|
|
'colour' => $desi_colour, |
|
168
|
|
|
|
|
|
|
}, |
|
169
|
|
|
|
|
|
|
] ], |
|
170
|
|
|
|
|
|
|
] ], |
|
171
|
|
|
|
|
|
|
}, |
|
172
|
|
|
|
|
|
|
}), |
|
173
|
|
|
|
|
|
|
}, |
|
174
|
|
|
|
|
|
|
}); |
|
175
|
|
|
|
|
|
|
pass( 'no death from executing search query' ); |
|
176
|
|
|
|
|
|
|
does_ok( $matched_suppl, 'Muldis::DB::Interface::Var' ); |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $matched_suppl_ast = $matched_suppl->fetch_ast(); |
|
179
|
|
|
|
|
|
|
pass( 'no death from fetching search results from VM' ); |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# Finally, use the result somehow (not done here). |
|
182
|
|
|
|
|
|
|
# The result should be: |
|
183
|
|
|
|
|
|
|
# [ 'Relation', 'sys.Core.Relation.Relation', [ |
|
184
|
|
|
|
|
|
|
# { |
|
185
|
|
|
|
|
|
|
# 'farm' => [ 'NEText', 'Hodgesons' ], |
|
186
|
|
|
|
|
|
|
# 'country' => [ 'NEText', 'Canada' ], |
|
187
|
|
|
|
|
|
|
# }, |
|
188
|
|
|
|
|
|
|
# { |
|
189
|
|
|
|
|
|
|
# 'farm' => [ 'NEText', 'Beckers' ], |
|
190
|
|
|
|
|
|
|
# 'country' => [ 'NEText', 'England' ], |
|
191
|
|
|
|
|
|
|
# }, |
|
192
|
|
|
|
|
|
|
# ] ] |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
print "# debug: orange food suppliers found:\n"; |
|
195
|
|
|
|
|
|
|
# print "# " . $rel_def_matched_suppl->as_perl() . "\n"; |
|
196
|
|
|
|
|
|
|
print "# TODO, as_perl()\n"; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
return; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
########################################################################### |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# This does_ok exists for code parity with the Perl 6 Validator.pm, where |
|
204
|
|
|
|
|
|
|
# a does_ok is a modified clone of Test.pm's isa_ok, that tests using |
|
205
|
|
|
|
|
|
|
# .does rather than .isa; in Perl 5, they mean the same thing. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
*does_ok = \&isa_ok; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
########################################################################### |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
} # module Muldis::DB::Validator |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
########################################################################### |
|
214
|
|
|
|
|
|
|
########################################################################### |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; # Magic true value required at end of a reusable file's code. |
|
217
|
|
|
|
|
|
|
__END__ |