pione 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -1
- data/example/AbstractRule/AbstractRule.pione +40 -0
- data/example/Fib/Fib.pione +12 -5
- data/example/LucasNumber/LucasNumber.pione +1 -1
- data/example/MakePair/MakePair.pione +21 -6
- data/example/OddSelector/OddSelector.pione +17 -0
- data/example/OddSelector/data/1.i +0 -0
- data/example/OddSelector/data/10.i +0 -0
- data/example/OddSelector/data/2.i +0 -0
- data/example/OddSelector/data/3.i +0 -0
- data/example/OddSelector/data/4.i +0 -0
- data/example/OddSelector/data/5.i +0 -0
- data/example/OddSelector/data/6.i +0 -0
- data/example/OddSelector/data/7.i +0 -0
- data/example/OddSelector/data/8.i +0 -0
- data/example/OddSelector/data/9.i +0 -0
- data/example/SequentialParameter/SequentialParameter.pione +4 -0
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +31 -43
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +1 -1
- data/example/Touch/Touch.pione +3 -0
- data/lib/pione/command/pione-syntax-checker.rb +4 -4
- data/lib/pione/model/assignment.rb +6 -1
- data/lib/pione/model/basic-model.rb +92 -278
- data/lib/pione/model/binary-operator.rb +5 -1
- data/lib/pione/model/block.rb +17 -0
- data/lib/pione/model/boolean.rb +54 -22
- data/lib/pione/model/constraints.rb +34 -0
- data/lib/pione/model/data-expr.rb +184 -297
- data/lib/pione/model/feature-expr.rb +13 -4
- data/lib/pione/model/float.rb +24 -41
- data/lib/pione/model/integer.rb +75 -41
- data/lib/pione/model/keyed-sequence.rb +143 -0
- data/lib/pione/model/list.rb +12 -8
- data/lib/pione/model/message.rb +8 -4
- data/lib/pione/model/ordinal-sequence.rb +75 -0
- data/lib/pione/model/package.rb +6 -2
- data/lib/pione/model/parameters.rb +61 -9
- data/lib/pione/model/pione-method.rb +146 -0
- data/lib/pione/model/rule-expr.rb +44 -38
- data/lib/pione/model/rule-io.rb +11 -3
- data/lib/pione/model/rule.rb +105 -155
- data/lib/pione/model/sequence.rb +273 -0
- data/lib/pione/model/string.rb +75 -29
- data/lib/pione/model/ticket-expr.rb +17 -29
- data/lib/pione/model/type.rb +242 -0
- data/lib/pione/model/variable-table.rb +52 -53
- data/lib/pione/model/variable.rb +8 -4
- data/lib/pione/model.rb +34 -0
- data/lib/pione/parser/block-parser.rb +44 -20
- data/lib/pione/parser/common-parser.rb +2 -1
- data/lib/pione/parser/document-parser.rb +6 -1
- data/lib/pione/parser/expr-parser.rb +57 -11
- data/lib/pione/parser/flow-element-parser.rb +2 -2
- data/lib/pione/parser/rule-definition-parser.rb +23 -1
- data/lib/pione/patch/rinda-patch.rb +1 -5
- data/lib/pione/rule-handler/action-handler.rb +5 -5
- data/lib/pione/rule-handler/basic-handler.rb +30 -7
- data/lib/pione/rule-handler/empty-handler.rb +14 -0
- data/lib/pione/rule-handler/flow-handler.rb +132 -115
- data/lib/pione/rule-handler/root-handler.rb +6 -2
- data/lib/pione/rule-handler/update-criteria.rb +152 -0
- data/lib/pione/rule-handler.rb +14 -0
- data/lib/pione/system/identifier.rb +9 -9
- data/lib/pione/transformer/block-transformer.rb +4 -0
- data/lib/pione/transformer/expr-transformer.rb +1 -1
- data/lib/pione/transformer/flow-element-transformer.rb +4 -2
- data/lib/pione/transformer/literal-transformer.rb +14 -3
- data/lib/pione/transformer/rule-definition-transformer.rb +17 -5
- data/lib/pione/tuple-space/data-finder.rb +15 -52
- data/lib/pione/version.rb +1 -1
- data/lib/pione.rb +12 -38
- data/test/agent/spec_task-worker.rb +13 -12
- data/test/model/spec_assignment.rb +2 -2
- data/test/model/spec_binary-operator.rb +10 -10
- data/test/model/spec_block.rb +8 -8
- data/test/model/spec_boolean.rb +1 -72
- data/test/model/spec_boolean.yml +134 -0
- data/test/model/spec_data-expr.rb +50 -237
- data/test/model/spec_data-expr.yml +16 -45
- data/test/model/spec_data-expr_match.yml +45 -0
- data/test/model/spec_feature-expr.rb +2 -43
- data/test/model/spec_feature-expr.yml +0 -28
- data/test/model/spec_feature-expr_decide.yml +28 -0
- data/test/model/spec_float.rb +1 -119
- data/test/model/spec_float.yml +17 -0
- data/test/model/spec_integer.rb +1 -119
- data/test/model/spec_integer.yml +57 -0
- data/test/model/spec_keyed-sequence.rb +5 -0
- data/test/model/spec_keyed-sequence.yml +22 -0
- data/test/model/spec_message.rb +7 -7
- data/test/model/spec_parameters.rb +50 -63
- data/test/model/spec_pione-method.rb +56 -0
- data/test/model/spec_rule-expr.rb +18 -8
- data/test/model/spec_rule.rb +12 -12
- data/test/model/spec_sequence.rb +5 -0
- data/test/model/spec_sequence.yml +60 -0
- data/test/model/spec_string.rb +3 -70
- data/test/model/spec_string.yml +83 -0
- data/test/model/spec_ticket-expr.rb +4 -54
- data/test/model/spec_ticket-expr.yml +11 -0
- data/test/model/spec_variable-table.rb +41 -42
- data/test/model/spec_variable.rb +20 -22
- data/test/parser/spec_block-parser.yml +9 -0
- data/test/parser/spec_expr-parser.yml +0 -17
- data/test/parser/spec_flow-element-parser.yml +1 -1
- data/test/parser/spec_rule-definition-parser.yml +0 -4
- data/test/rule-handler/spec_update-criteria.pione +39 -0
- data/test/rule-handler/spec_update-criteria.rb +53 -0
- data/test/rule-handler/spec_update-criteria.yml +158 -0
- data/test/test-util.rb +25 -0
- data/test/transformer/spec_block-transformer.rb +7 -0
- data/test/transformer/spec_expr-transformer.rb +64 -19
- data/test/transformer/spec_flow-element-transformer.rb +11 -11
- data/test/transformer/spec_literal-transformer.rb +29 -29
- data/test/transformer/spec_rule-definition-transformer.rb +39 -21
- metadata +57 -11
- data/lib/pione/model/undefined-value.rb +0 -24
- data/lib/pione/tuple-space/update-criteria.rb +0 -97
- data/test/model/spec_list.rb +0 -26
- data/test/model/spec_rule-io.rb +0 -32
- data/test/spec_update-criteria.rb +0 -83
@@ -18,13 +18,17 @@ module Pione
|
|
18
18
|
inputs = Naming::InputLine.values(conditions)
|
19
19
|
outputs = Naming::OutputLine.values(conditions)
|
20
20
|
params = Parameters.merge(*Naming::ParamLine.values(conditions))
|
21
|
-
features = Feature
|
22
|
-
|
21
|
+
features = Feature.empty if Naming::FeatureLine.values(conditions).empty?
|
22
|
+
features = Feature::AndExpr.new(*Naming::FeatureLine.values(conditions)) unless features
|
23
|
+
constraints = Constraints.new(Naming::ConstraintLine.values(conditions))
|
24
|
+
condition = RuleCondition.new(inputs, outputs, params: params, features: features, constraints: constraints)
|
23
25
|
case block
|
24
26
|
when ActionBlock
|
25
27
|
ActionRule
|
26
28
|
when FlowBlock
|
27
29
|
FlowRule
|
30
|
+
when EmptyBlock
|
31
|
+
EmptyRule
|
28
32
|
end.new(rule_expr, condition, block)
|
29
33
|
}
|
30
34
|
|
@@ -34,15 +38,15 @@ module Pione
|
|
34
38
|
Naming.InputLine(data_expr)
|
35
39
|
}
|
36
40
|
|
37
|
-
# Transform
|
41
|
+
# Transform +output_line+ as Naming::OutputLine.
|
38
42
|
rule(:output_line => simple(:data_expr)) {
|
39
43
|
TypeDataExpr.check(data_expr)
|
40
44
|
Naming.OutputLine(data_expr)
|
41
45
|
}
|
42
46
|
|
43
|
-
# Transform
|
47
|
+
# Transform +param_line+ as Naming::ParamLine.
|
44
48
|
rule(:param_line => simple(:param)) {
|
45
|
-
unless TypeAssignment.match(param) or TypeParameters.match(param)
|
49
|
+
unless TypeAssignment.match(param) or TypeParameters.match(param) or param.kind_of?(Variable)
|
46
50
|
raise PioneModelTypeError.new(param, TypeAssignment)
|
47
51
|
end
|
48
52
|
Naming.ParamLine(param)
|
@@ -53,6 +57,14 @@ module Pione
|
|
53
57
|
TypeFeature.check(feature)
|
54
58
|
Naming.FeatureLine(feature)
|
55
59
|
}
|
60
|
+
|
61
|
+
rule(:constraint_line => simple(:constraint)) {
|
62
|
+
Naming.ConstraintLine(constraint)
|
63
|
+
}
|
64
|
+
|
65
|
+
rule(:annotation_line => simple(:expr)) {
|
66
|
+
Naming.AnnotationLine(expr)
|
67
|
+
}
|
56
68
|
end
|
57
69
|
end
|
58
70
|
end
|
@@ -61,10 +61,13 @@ module Pione
|
|
61
61
|
# @return [DataFinderResult]
|
62
62
|
# query result
|
63
63
|
def find_by_expr(expr)
|
64
|
-
|
65
|
-
|
64
|
+
name = expr
|
65
|
+
name = expr.first if expr.kind_of?(DataExprSequence)
|
66
|
+
name = DataExpr.new(expr) if expr.kind_of?(String)
|
67
|
+
query = Tuple[:data].new(name: name, domain: @domain)
|
66
68
|
return tuple_space_server.read_all(query).map do |tuple|
|
67
|
-
tuple.update_criteria = expr.update_criteria
|
69
|
+
tuple.update_criteria = expr.update_criteria if expr.kind_of?(DataExprSequence)
|
70
|
+
tuple
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
@@ -99,14 +102,14 @@ module Pione
|
|
99
102
|
# make combination results
|
100
103
|
prefix = (type == :input ? "I" : "O")
|
101
104
|
if head.all?
|
102
|
-
# case all
|
105
|
+
# case all distribution
|
103
106
|
new_vtable =
|
104
|
-
make_auto_variables_by_all(prefix, head, tuples, vtable, index)
|
107
|
+
make_auto_variables_by_all(type, prefix, head, tuples, vtable, index)
|
105
108
|
unless tuples.empty?
|
106
109
|
return find_rec_sub(type, tail, index, tuples, new_vtable)
|
107
110
|
end
|
108
111
|
else
|
109
|
-
# case each
|
112
|
+
# case each distribution
|
110
113
|
return tuples.map {|tuple|
|
111
114
|
args = [prefix, head, tuple, vtable, index]
|
112
115
|
new_vtable = make_auto_variables_by_each(*args)
|
@@ -129,62 +132,22 @@ module Pione
|
|
129
132
|
|
130
133
|
# Make auto-variables by the name modified 'all'.
|
131
134
|
# @api private
|
132
|
-
def make_auto_variables_by_all(prefix, expr, tuples, vtable, index)
|
135
|
+
def make_auto_variables_by_all(type, prefix, expr, tuples, vtable, index)
|
133
136
|
# create new table
|
134
137
|
new_vtable = VariableTable.new(vtable)
|
135
|
-
#
|
136
|
-
|
137
|
-
|
138
|
-
# setup rule-io list
|
139
|
-
list = new_vtable.get(var)
|
140
|
-
list = RuleIOList.new unless list
|
141
|
-
io_list = RuleIOList.new
|
142
|
-
new_vtable.set!(var, list.add(io_list))
|
143
|
-
|
144
|
-
asterisk = []
|
145
|
-
|
146
|
-
# convert each tuples
|
147
|
-
tuples.each do |tuple, i|
|
148
|
-
asterisk << expr.match(tuple.name).to_a[1]
|
149
|
-
|
150
|
-
elt = RuleIOElement.new(PioneString.new(tuple.name))
|
151
|
-
elt.uri = PioneString.new(tuple.location.uri)
|
152
|
-
elt.match = PioneList.new(
|
153
|
-
*expr.match(tuple.name).to_a.map{|m| PioneString.new(m)}
|
154
|
-
)
|
155
|
-
io_list.add!(elt)
|
156
|
-
end
|
157
|
-
|
158
|
-
# set special variable if index equals 1
|
159
|
-
if prefix == 'I' && index == 1
|
160
|
-
new_vtable.set(Variable.new("*"), PioneString.new(asterisk.join(":")))
|
161
|
-
end
|
138
|
+
# set auto variables
|
139
|
+
new_vtable.make_io_auto_variables_by_all(type, prefix, expr, tuples, index)
|
162
140
|
|
163
141
|
return new_vtable
|
164
142
|
end
|
165
143
|
|
166
|
-
# Make auto-variables by the name
|
144
|
+
# Make auto-variables by the name with 'each' distribution.
|
167
145
|
# @api private
|
168
146
|
def make_auto_variables_by_each(prefix, expr, tuple, vtable, index)
|
169
147
|
# create new table
|
170
148
|
new_vtable = VariableTable.new(vtable)
|
171
|
-
#
|
172
|
-
|
173
|
-
# matched data
|
174
|
-
md = expr.match(tuple.name).to_a
|
175
|
-
|
176
|
-
# setup rule-io list
|
177
|
-
list = new_vtable.get(var)
|
178
|
-
list = RuleIOList.new unless list
|
179
|
-
elt = RuleIOElement.new(PioneString.new(tuple.name))
|
180
|
-
elt.uri = PioneString.new(tuple.location.uri.to_s)
|
181
|
-
elt.match = PioneList.new(*md.map{|d| PioneString.new(d)})
|
182
|
-
new_vtable.set!(var, list.add(elt))
|
183
|
-
|
184
|
-
# set special variable if index equals 1
|
185
|
-
if prefix == 'I' && index == 1
|
186
|
-
new_vtable.set(Variable.new("*"), PioneString.new(md[1]))
|
187
|
-
end
|
149
|
+
# set auto variables
|
150
|
+
new_vtable.make_io_auto_variables_by_each(prefix, expr, tuple, index)
|
188
151
|
|
189
152
|
return new_vtable
|
190
153
|
end
|
data/lib/pione/version.rb
CHANGED
data/lib/pione.rb
CHANGED
@@ -89,29 +89,19 @@ require 'pione/relay/relay-socket'
|
|
89
89
|
require 'pione/relay/relay-client-db'
|
90
90
|
require 'pione/relay/relay-account-db'
|
91
91
|
|
92
|
+
# tuple-space
|
93
|
+
require 'pione/tuple-space/tuple-space-server-interface'
|
94
|
+
require 'pione/tuple-space/presence-notifier'
|
95
|
+
require 'pione/tuple-space/tuple-space-server'
|
96
|
+
require 'pione/tuple-space/tuple-space-receiver'
|
97
|
+
require 'pione/tuple-space/tuple-space-provider'
|
98
|
+
require 'pione/tuple-space/data-finder'
|
99
|
+
|
100
|
+
# rule-handler
|
101
|
+
require 'pione/rule-handler.rb'
|
102
|
+
|
92
103
|
# model
|
93
|
-
require 'pione/model
|
94
|
-
require 'pione/model/undefined-value'
|
95
|
-
require 'pione/model/list'
|
96
|
-
require 'pione/model/boolean'
|
97
|
-
require 'pione/model/integer'
|
98
|
-
require 'pione/model/float'
|
99
|
-
require 'pione/model/string'
|
100
|
-
require 'pione/model/feature-expr'
|
101
|
-
require 'pione/model/variable'
|
102
|
-
require 'pione/model/variable-table'
|
103
|
-
require 'pione/model/data-expr'
|
104
|
-
require 'pione/model/parameters'
|
105
|
-
require 'pione/model/package'
|
106
|
-
require 'pione/model/ticket-expr'
|
107
|
-
require 'pione/model/rule-expr'
|
108
|
-
require 'pione/model/binary-operator'
|
109
|
-
require 'pione/model/message'
|
110
|
-
require 'pione/model/call-rule'
|
111
|
-
require 'pione/model/assignment'
|
112
|
-
require 'pione/model/block'
|
113
|
-
require 'pione/model/rule'
|
114
|
-
require 'pione/model/rule-io'
|
104
|
+
require 'pione/model'
|
115
105
|
|
116
106
|
# tuple
|
117
107
|
require 'pione/tuple/basic-tuple'
|
@@ -135,15 +125,6 @@ require 'pione/tuple/rule-tuple'
|
|
135
125
|
require 'pione/tuple/task-worker-resource-tuple'
|
136
126
|
require 'pione/tuple/ticket-tuple'
|
137
127
|
|
138
|
-
# tuple-space
|
139
|
-
require 'pione/tuple-space/tuple-space-server-interface'
|
140
|
-
require 'pione/tuple-space/presence-notifier'
|
141
|
-
require 'pione/tuple-space/tuple-space-server'
|
142
|
-
require 'pione/tuple-space/tuple-space-receiver'
|
143
|
-
require 'pione/tuple-space/tuple-space-provider'
|
144
|
-
require 'pione/tuple-space/data-finder'
|
145
|
-
require 'pione/tuple-space/update-criteria'
|
146
|
-
|
147
128
|
# parser
|
148
129
|
require 'pione/parser/parslet-extension'
|
149
130
|
require 'pione/parser/common-parser'
|
@@ -158,13 +139,6 @@ require 'pione/parser/document-parser'
|
|
158
139
|
# transformer
|
159
140
|
require 'pione/transformer'
|
160
141
|
|
161
|
-
# rule-handler
|
162
|
-
require 'pione/rule-handler/basic-handler'
|
163
|
-
require 'pione/rule-handler/flow-handler'
|
164
|
-
require 'pione/rule-handler/action-handler'
|
165
|
-
require 'pione/rule-handler/root-handler'
|
166
|
-
require 'pione/rule-handler/system-handler'
|
167
|
-
|
168
142
|
# agent
|
169
143
|
require 'pione/agent/basic-agent'
|
170
144
|
require 'pione/agent/tuple-space-client'
|
@@ -70,7 +70,7 @@ describe 'Pione::Agent::TaskWorker' do
|
|
70
70
|
ID.domain_id("main", "Test", [], Parameters.empty),
|
71
71
|
[]
|
72
72
|
)
|
73
|
-
rule = Tuple[:rule].new('&main:Test', :fake_content
|
73
|
+
rule = Tuple[:rule].new('&main:Test', :fake_content)
|
74
74
|
write(rule)
|
75
75
|
task2, result = @worker.__send__(:transit_to_rule_loading, task1)
|
76
76
|
result.should == :fake_content
|
@@ -86,7 +86,7 @@ describe 'Pione::Agent::TaskWorker' do
|
|
86
86
|
ID.domain_id("main", "Test", [], Parameters.empty),
|
87
87
|
[]
|
88
88
|
)
|
89
|
-
rule = Tuple[:rule].new('&main:Test', :fake_content
|
89
|
+
rule = Tuple[:rule].new('&main:Test', :fake_content)
|
90
90
|
write(rule)
|
91
91
|
should.raise(Agent::TaskWorker::UnknownRuleError) do
|
92
92
|
@worker.__send__(:transit_to_rule_loading, task)
|
@@ -109,11 +109,13 @@ describe 'Pione::Agent::TaskWorker' do
|
|
109
109
|
[],
|
110
110
|
[DataExpr.new('out.txt')],
|
111
111
|
Parameters.empty,
|
112
|
-
Feature.empty
|
112
|
+
Feature.empty,
|
113
|
+
TicketExpr.empty,
|
114
|
+
TicketExpr.empty
|
113
115
|
),
|
114
116
|
ActionBlock.new("expr 1 + 2 > out.txt")
|
115
117
|
)
|
116
|
-
|
118
|
+
quiet_mode do
|
117
119
|
task2, handler, result =
|
118
120
|
@worker.__send__(:transit_to_task_executing, task1, rule)
|
119
121
|
task2.should == task1
|
@@ -133,7 +135,7 @@ describe 'Pione::Agent::TaskWorker' do
|
|
133
135
|
write(Tuple[:working].new(task1.domain, "test"))
|
134
136
|
rule = FlowRule.new(
|
135
137
|
RuleExpr.new(Package.new('main'), 'Test'),
|
136
|
-
RuleCondition.new([], [], Parameters.empty, Feature.empty),
|
138
|
+
RuleCondition.new([], [], Parameters.empty, Feature.empty, TicketExpr.empty, TicketExpr.empty),
|
137
139
|
:dummy
|
138
140
|
)
|
139
141
|
handler1 = RuleHandler::FlowHandler.new(
|
@@ -159,7 +161,7 @@ describe 'Pione::Agent::TaskWorker' do
|
|
159
161
|
write(Tuple[:working].new(task.domain, "test"))
|
160
162
|
rule = FlowRule.new(
|
161
163
|
RuleExpr.new(Package.new('main'), 'Test'),
|
162
|
-
RuleCondition.new([], [], Parameters.empty, Feature.empty),
|
164
|
+
RuleCondition.new([], [], Parameters.empty, Feature.empty, TicketExpr.empty, TicketExpr.empty),
|
163
165
|
:dummy
|
164
166
|
)
|
165
167
|
handler = RuleHandler::FlowHandler.new(
|
@@ -177,7 +179,7 @@ describe 'Pione::Agent::TaskWorker' do
|
|
177
179
|
DRb.start_service
|
178
180
|
create_remote_tuple_space_server
|
179
181
|
|
180
|
-
Agent[:logger].start(tuple_space_server,
|
182
|
+
Agent[:logger].start(tuple_space_server, Location["out.txt"])
|
181
183
|
|
182
184
|
# process info
|
183
185
|
write(Tuple[:process_info].new('spec_task-worker', 'testid'))
|
@@ -188,9 +190,9 @@ describe 'Pione::Agent::TaskWorker' do
|
|
188
190
|
@worker3 = Agent[:task_worker].start(tuple_space_server)
|
189
191
|
|
190
192
|
# make a task
|
191
|
-
@
|
192
|
-
|
193
|
-
@data = Tuple[:data].new(domain: 'test', name: "1.a",
|
193
|
+
@location = Location[Temppath.create]
|
194
|
+
@location.create "abc"
|
195
|
+
@data = Tuple[:data].new(domain: 'test', name: "1.a", location: @location)
|
194
196
|
@task1 = Tuple[:task].new(
|
195
197
|
"&main:test",
|
196
198
|
[@data],
|
@@ -212,8 +214,7 @@ describe 'Pione::Agent::TaskWorker' do
|
|
212
214
|
write(
|
213
215
|
Tuple[:rule].new(
|
214
216
|
rule_path: "&main:test",
|
215
|
-
content: doc["&main:test"]
|
216
|
-
status: :known
|
217
|
+
content: doc["&main:test"]
|
217
218
|
)
|
218
219
|
)
|
219
220
|
|
@@ -28,9 +28,9 @@ describe 'Model::Assignment' do
|
|
28
28
|
vtable = VariableTable.new
|
29
29
|
Assignment.new(
|
30
30
|
Variable.new("X"),
|
31
|
-
Message.new("as_string", 1.to_pione)
|
31
|
+
Message.new("as_string", IntegerSequence.new([1.to_pione]))
|
32
32
|
).eval(vtable)
|
33
|
-
Variable.new("X").eval(vtable).should == "1".to_pione
|
33
|
+
Variable.new("X").eval(vtable).should == StringSequence.new(["1".to_pione])
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should update variable table' do
|
@@ -4,26 +4,26 @@ describe 'Model::BinaryOperator' do
|
|
4
4
|
before do
|
5
5
|
@a = Model::BinaryOperator.new(
|
6
6
|
"%",
|
7
|
-
Model::PioneInteger.new(5),
|
8
|
-
Model::PioneInteger.new(2)
|
7
|
+
Model::IntegerSequence.new([Model::PioneInteger.new(5)]),
|
8
|
+
Model::IntegerSequence.new([Model::PioneInteger.new(2)])
|
9
9
|
)
|
10
10
|
@b = Model::BinaryOperator.new(
|
11
11
|
"+",
|
12
|
-
Model::PioneString.new("abc"),
|
13
|
-
Model::PioneString.new("def")
|
12
|
+
Model::StringSequence.new([Model::PioneString.new("abc")]),
|
13
|
+
Model::StringSequence.new([Model::PioneString.new("def")])
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should equal' do
|
18
18
|
@a.should == Model::BinaryOperator.new(
|
19
19
|
"%",
|
20
|
-
Model::PioneInteger.new(5),
|
21
|
-
Model::PioneInteger.new(2)
|
20
|
+
Model::IntegerSequence.new([Model::PioneInteger.new(5)]),
|
21
|
+
Model::IntegerSequence.new([Model::PioneInteger.new(2)])
|
22
22
|
)
|
23
23
|
@b.should == Model::BinaryOperator.new(
|
24
24
|
"+",
|
25
|
-
Model::PioneString.new("abc"),
|
26
|
-
Model::PioneString.new("def")
|
25
|
+
Model::StringSequence.new([Model::PioneString.new("abc")]),
|
26
|
+
Model::StringSequence.new([Model::PioneString.new("def")])
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
@@ -33,7 +33,7 @@ describe 'Model::BinaryOperator' do
|
|
33
33
|
|
34
34
|
it 'should send message' do
|
35
35
|
vtable = VariableTable.new
|
36
|
-
@a.eval(vtable).should == Model::PioneInteger.new(1)
|
37
|
-
@b.eval(vtable).should == Model::PioneString.new("abcdef")
|
36
|
+
@a.eval(vtable).should == Model::IntegerSequence.new([Model::PioneInteger.new(1)])
|
37
|
+
@b.eval(vtable).should == Model::StringSequence.new([Model::PioneString.new("abcdef")])
|
38
38
|
end
|
39
39
|
end
|
data/test/model/spec_block.rb
CHANGED
@@ -14,9 +14,9 @@ describe 'Model::ActionBlock' do
|
|
14
14
|
it 'should expand variables' do
|
15
15
|
block = ActionBlock.new("{$var1} {$var2} {$var3}")
|
16
16
|
vtable = VariableTable.new
|
17
|
-
vtable.set(Variable.new("var1"), "a".
|
18
|
-
vtable.set(Variable.new("var2"), "b".
|
19
|
-
vtable.set(Variable.new("var3"), "c".
|
17
|
+
vtable.set(Variable.new("var1"), PioneString.new("a").to_seq)
|
18
|
+
vtable.set(Variable.new("var2"), PioneString.new("b").to_seq)
|
19
|
+
vtable.set(Variable.new("var3"), PioneString.new("c").to_seq)
|
20
20
|
block.eval(vtable).should == ActionBlock.new("a b c")
|
21
21
|
end
|
22
22
|
end
|
@@ -60,14 +60,14 @@ describe 'Model::FlowBlock' do
|
|
60
60
|
Assignment.new(Variable.new("Y"), Variable.new("Z")),
|
61
61
|
ConditionalBlock.new(
|
62
62
|
Variable.new("A"),
|
63
|
-
{ PioneBoolean.true =>
|
64
|
-
FlowBlock.new(Assignment.new(Variable.new("Z"), 1.to_pione)),
|
63
|
+
{ BooleanSequence.new([PioneBoolean.true]) =>
|
64
|
+
FlowBlock.new(Assignment.new(Variable.new("Z"), IntegerSequence.new([1.to_pione]))),
|
65
65
|
}
|
66
66
|
),
|
67
|
-
Assignment.new(Variable.new("A"), PioneBoolean.true),
|
67
|
+
Assignment.new(Variable.new("A"), BooleanSequence.new([PioneBoolean.true])),
|
68
68
|
ConditionalBlock.new(
|
69
|
-
Message.new("==", Variable.new("Z"), 1.to_pione),
|
70
|
-
{ PioneBoolean.true => FlowBlock.new(z) }
|
69
|
+
Message.new("==", Variable.new("Z"), IntegerSequence.new([1.to_pione])),
|
70
|
+
{ BooleanSequence.new([PioneBoolean.true]) => FlowBlock.new(z) }
|
71
71
|
),
|
72
72
|
x,
|
73
73
|
y
|
data/test/model/spec_boolean.rb
CHANGED
@@ -40,76 +40,5 @@ describe 'Model::PioneBoolean' do
|
|
40
40
|
PioneBoolean.or(PioneBoolean.false, PioneBoolean.false).should.false
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
it 'should true' do
|
45
|
-
@true.call_pione_method("==", PioneBoolean.true).should.true
|
46
|
-
@false.call_pione_method("==", PioneBoolean.false).should.true
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should false' do
|
50
|
-
@true.call_pione_method("==", PioneBoolean.false).should.not.true
|
51
|
-
@false.call_pione_method("==", PioneBoolean.true).should.not.true
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should raise type error' do
|
55
|
-
should.raise(PioneModelTypeError) do
|
56
|
-
@true.call_pione_method("==", PioneInteger.new(1))
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'pione method !=' do
|
62
|
-
it 'should true' do
|
63
|
-
@true.call_pione_method("!=", PioneBoolean.false).should.true
|
64
|
-
@false.call_pione_method("!=", PioneBoolean.true).should.true
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should false' do
|
68
|
-
@true.call_pione_method("!=", PioneBoolean.true).should.not.true
|
69
|
-
@false.call_pione_method("!=", PioneBoolean.false).should.not.true
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should raise type error' do
|
73
|
-
should.raise(PioneModelTypeError) do
|
74
|
-
@true.call_pione_method("!=", PioneInteger.new(1))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'pione method &&' do
|
80
|
-
it 'should get truth' do
|
81
|
-
@true.call_pione_method("&&", @true).should.true
|
82
|
-
@true.call_pione_method("&&", @false).should.false
|
83
|
-
@false.call_pione_method("&&", @true).should.false
|
84
|
-
@false.call_pione_method("&&", @false).should.false
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should raise type error' do
|
88
|
-
should.raise(PioneModelTypeError) do
|
89
|
-
@true.call_pione_method("&&", PioneInteger.new(1))
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe 'pione method ||' do
|
95
|
-
it 'should get truth' do
|
96
|
-
@true.call_pione_method("||", @true).should.true
|
97
|
-
@true.call_pione_method("||", @false).should.true
|
98
|
-
@false.call_pione_method("||", @true).should.true
|
99
|
-
@false.call_pione_method("||", @false).should.false
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should raise type error' do
|
103
|
-
should.raise(PioneModelTypeError) do
|
104
|
-
@true.call_pione_method("||", PioneInteger.new(1))
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe 'pione method as_string' do
|
110
|
-
it 'should get string' do
|
111
|
-
@true.call_pione_method("as_string").should == PioneString.new("true")
|
112
|
-
@false.call_pione_method("as_string").should == PioneString.new("false")
|
113
|
-
end
|
114
|
-
end
|
43
|
+
test_pione_method("boolean")
|
115
44
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# ==
|
2
|
+
- true : 'true == true'
|
3
|
+
- false : 'true == false'
|
4
|
+
- false : 'false == true'
|
5
|
+
- true : 'false == false'
|
6
|
+
- false : 'true | true == true'
|
7
|
+
- false : 'true | true == false'
|
8
|
+
- false : 'true | false == true'
|
9
|
+
- false : 'true | false == false'
|
10
|
+
- false : 'false | true == true'
|
11
|
+
- false : 'false | true == false'
|
12
|
+
- false : 'false | false == true'
|
13
|
+
- false : 'false | false == false'
|
14
|
+
- false : 'true == true | true'
|
15
|
+
- false : 'true == true | false'
|
16
|
+
- false : 'true == false | true'
|
17
|
+
- false : 'true == false | false'
|
18
|
+
- false : 'false == true | true'
|
19
|
+
- false : 'false == true | false'
|
20
|
+
- false : 'false == false | true'
|
21
|
+
- false : 'false == false | false'
|
22
|
+
- true : 'true | true == true | true'
|
23
|
+
- false : 'true | true == true | false'
|
24
|
+
- false : 'true | true == false | true'
|
25
|
+
- false : 'true | true == false | false'
|
26
|
+
- false : 'true | false == true | true'
|
27
|
+
- true : 'true | false == true | false'
|
28
|
+
- false : 'true | false == false | true'
|
29
|
+
- false : 'true | false == false | false'
|
30
|
+
- false : 'false | true == true | true'
|
31
|
+
- false : 'false | true == true | false'
|
32
|
+
- true : 'false | true == false | true'
|
33
|
+
- false : 'false | true == false | false'
|
34
|
+
- false : 'false | false == true | true'
|
35
|
+
- false : 'false | false == true | false'
|
36
|
+
- false : 'false | false == false | true'
|
37
|
+
- true : 'false | false == false | false'
|
38
|
+
|
39
|
+
# as_string, str
|
40
|
+
- '"true"' : 'true.as_string'
|
41
|
+
- '"false"' : 'false.as_string'
|
42
|
+
- '"true"' : 'true.str'
|
43
|
+
- '"false"' : 'false.str'
|
44
|
+
- '"true" | "true"' : '(true | true).str'
|
45
|
+
- '"true" | "false"' : '(true | false).str'
|
46
|
+
- '"false" | "true"' : '(false | true).str'
|
47
|
+
- '"false" | "false"' : '(false | false).str'
|
48
|
+
|
49
|
+
# as_data_expr, d
|
50
|
+
# - "'true'" : 'true.as_data_expr'
|
51
|
+
# - "'false'" : 'false.as_data_expr'
|
52
|
+
# - "'true'" : 'true.d'
|
53
|
+
# - "'false'" : 'false.d'
|
54
|
+
# - "'true' | 'true'" : '(true | true).d'
|
55
|
+
# - "'true' | 'false'" : '(true | false).d'
|
56
|
+
# - "'false' | 'true'" : '(false | true).d'
|
57
|
+
# - "'false' | 'false'" : '(false | false).d'
|
58
|
+
|
59
|
+
# not
|
60
|
+
- false : 'true.not'
|
61
|
+
- true : 'false.not'
|
62
|
+
- true : '(true | true).not == false | false'
|
63
|
+
- true : '(true | false).not == false | true'
|
64
|
+
- true : '(false | true).not == true | false'
|
65
|
+
- true : '(false | false).not == true | true'
|
66
|
+
|
67
|
+
# and
|
68
|
+
- true : 'true and true == true'
|
69
|
+
- true : 'true and false == false'
|
70
|
+
- true : 'false and true == false'
|
71
|
+
- true : 'false and false == false'
|
72
|
+
- true : '(true | true) and true == true | true'
|
73
|
+
- true : '(true | true) and false == false | false'
|
74
|
+
- true : '(true | false) and true == true | false'
|
75
|
+
- true : '(true | false) and false == false | false'
|
76
|
+
- true : '(false | true) and true == false | true'
|
77
|
+
- true : '(false | true) and false == false | false'
|
78
|
+
- true : '(false | false) and true == false | false'
|
79
|
+
- true : '(false | false) and false == false | false'
|
80
|
+
- true : 'true and (true | true) == true | true'
|
81
|
+
- true : 'true and (true | false) == true | false'
|
82
|
+
- true : 'true and (false | true) == false | true'
|
83
|
+
- true : 'true and (false | false) == false | false'
|
84
|
+
- true : 'false and (true | true) == false | false'
|
85
|
+
- true : 'false and (true | false) == false | false'
|
86
|
+
- true : 'false and (false | true) == false | false'
|
87
|
+
- true : 'false and (false | false) == false | false'
|
88
|
+
|
89
|
+
# or
|
90
|
+
- true : 'true or true == true'
|
91
|
+
- true : 'true or false == true'
|
92
|
+
- true : 'false or true == true'
|
93
|
+
- true : 'false or false == false'
|
94
|
+
- true : '(true | true) or true == true | true'
|
95
|
+
- true : '(true | true) or false == true | true'
|
96
|
+
- true : '(true | false) or true == true | true'
|
97
|
+
- true : '(true | false) or false == true | false'
|
98
|
+
- true : '(false | true) or true == true | true'
|
99
|
+
- true : '(false | true) or false == false | true'
|
100
|
+
- true : '(false | false) or true == true | true'
|
101
|
+
- true : '(false | false) or false == false | false'
|
102
|
+
- true : 'true or (true | true) == true | true'
|
103
|
+
- true : 'true or (true | false) == true | true'
|
104
|
+
- true : 'true or (false | true) == true | true'
|
105
|
+
- true : 'true or (false | false) == true | true'
|
106
|
+
- true : 'false or (true | true) == true | true'
|
107
|
+
- true : 'false or (true | false) == true | false'
|
108
|
+
- true : 'false or (false | true) == false | true'
|
109
|
+
- true : 'false or (false | false) == false | false'
|
110
|
+
|
111
|
+
# every?
|
112
|
+
- true : 'true.every?'
|
113
|
+
- false : 'false.every?'
|
114
|
+
- true : '(true | true).every?'
|
115
|
+
- false : '(true | false).every?'
|
116
|
+
- false : '(false | true).every?'
|
117
|
+
- false : '(false | false).every?'
|
118
|
+
|
119
|
+
# any?
|
120
|
+
- true : 'true.any?'
|
121
|
+
- false : 'false.any?'
|
122
|
+
- true : '(true | true).any?'
|
123
|
+
- true : '(true | false).any?'
|
124
|
+
- true : '(false | true).any?'
|
125
|
+
- false : '(false | false).any?'
|
126
|
+
|
127
|
+
# one?
|
128
|
+
- true : 'true.one?'
|
129
|
+
- false : 'false.one?'
|
130
|
+
- false : '(true | true).one?'
|
131
|
+
- true : '(true | false).one?'
|
132
|
+
- true : '(false | true).one?'
|
133
|
+
- false : '(false | false).one?'
|
134
|
+
|