pione 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. data/.gitignore +4 -3
  2. data/.simplecov +7 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +3 -0
  5. data/History.txt +13 -0
  6. data/README.md +2 -0
  7. data/Rakefile +16 -6
  8. data/bin/pione-val +5 -0
  9. data/example/AbstractRule/package.yml +1 -0
  10. data/example/HelloWorld/package.yml +2 -0
  11. data/example/HelloWorld/scenario/scenario.yml +2 -0
  12. data/example/LoopByTouch/LoopByTouch.pione +28 -0
  13. data/example/LoopByTouch/package.yml +1 -0
  14. data/example/MakePair/package.yml +2 -0
  15. data/example/MakePair/{data → scenario/input}/1.i +0 -0
  16. data/example/MakePair/{data → scenario/input}/2.i +0 -0
  17. data/example/MakePair/{data → scenario/input}/3.i +0 -0
  18. data/example/MakePair/{data → scenario/input}/4.i +0 -0
  19. data/example/MakePair/{data → scenario/input}/5.i +0 -0
  20. data/example/MakePair/scenario/scenario.yml +1 -0
  21. data/example/ScoreAggregation/ScoreAggregation.pione +122 -0
  22. data/example/ScoreAggregation/bin/apply-template.rb +10 -0
  23. data/example/ScoreAggregation/bin/histgram-graph.sh +18 -0
  24. data/example/ScoreAggregation/bin/mean-summary.rb +10 -0
  25. data/example/ScoreAggregation/bin/personal-bar-graph.sh +18 -0
  26. data/example/ScoreAggregation/bin/personal-pre-statistics.rb +37 -0
  27. data/example/ScoreAggregation/bin/total-mean.rb +10 -0
  28. data/example/ScoreAggregation/bin/total-statistics.rb +43 -0
  29. data/example/ScoreAggregation/generate-data.rb +63 -0
  30. data/example/ScoreAggregation/package.yml +1 -0
  31. data/example/ScoreAggregation/scenario/case1/input/A.score +15 -0
  32. data/example/ScoreAggregation/scenario/case1/input/B.score +15 -0
  33. data/example/ScoreAggregation/scenario/case1/input/C.score +15 -0
  34. data/example/ScoreAggregation/scenario/case1/input/D.score +15 -0
  35. data/example/ScoreAggregation/scenario/case1/input/E.score +15 -0
  36. data/example/ScoreAggregation/scenario/case1/input/F.score +15 -0
  37. data/example/ScoreAggregation/scenario/case1/input/G.score +15 -0
  38. data/example/ScoreAggregation/scenario/case1/input/H.score +15 -0
  39. data/example/ScoreAggregation/scenario/case1/input/I.score +15 -0
  40. data/example/ScoreAggregation/scenario/case1/input/J.score +15 -0
  41. data/example/ScoreAggregation/scenario/case1/input/K.score +15 -0
  42. data/example/ScoreAggregation/scenario/case1/input/L.score +15 -0
  43. data/example/ScoreAggregation/scenario/case1/input/M.score +15 -0
  44. data/example/ScoreAggregation/scenario/case1/input/N.score +15 -0
  45. data/example/ScoreAggregation/scenario/case1/input/O.score +15 -0
  46. data/example/ScoreAggregation/scenario/case1/input/P.score +15 -0
  47. data/example/ScoreAggregation/scenario/case1/input/Q.score +15 -0
  48. data/example/ScoreAggregation/scenario/case1/input/R.score +15 -0
  49. data/example/ScoreAggregation/scenario/case1/input/S.score +15 -0
  50. data/example/ScoreAggregation/scenario/case1/input/T.score +15 -0
  51. data/example/ScoreAggregation/scenario/case1/input/U.score +15 -0
  52. data/example/ScoreAggregation/scenario/case1/input/V.score +15 -0
  53. data/example/ScoreAggregation/scenario/case1/input/W.score +15 -0
  54. data/example/ScoreAggregation/scenario/case1/input/X.score +15 -0
  55. data/example/ScoreAggregation/scenario/case1/input/Y.score +15 -0
  56. data/example/ScoreAggregation/scenario/case1/input/Z.score +15 -0
  57. data/example/ScoreAggregation/scenario/case1/input/stat-template.erb +24 -0
  58. data/example/ScoreAggregation/scenario/case1/scenario.yml +3 -0
  59. data/example/{SequentialProcess/SequentialProcess.pione → SerialProcessing/SerialProcessing.pione} +0 -0
  60. data/example/SerialProcessing/package.yml +1 -0
  61. data/example/WorkflowPatterns/01_Sequence/Sequence.pione +21 -0
  62. data/example/WorkflowPatterns/02_PrallelSplit/ParallelSplit.pione +29 -0
  63. data/example/WorkflowPatterns/03_Synchronization/Synchronization.pione +30 -0
  64. data/example/WorkflowPatterns/04_ExclusiveChoice/ExclusiveChoice.pione +44 -0
  65. data/example/WorkflowPatterns/05_SimpleMerge/SimpleMerge.pione +44 -0
  66. data/example/WorkflowPatterns/06_MultiChoice/MultiChoice.pione +48 -0
  67. data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/StructuredSynchronizingMerge.pione +71 -0
  68. data/example/WorkflowPatterns/08_MultiMerge/MultiMerge.pione +44 -0
  69. data/example/WorkflowPatterns/11_ImplicitTermination/ImplicitTermination.pione +29 -0
  70. data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/MultipleInstancesWithoutSynchronization.pione +29 -0
  71. data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/MultipleInstancesWithDesignTimeKnowledge.pione +28 -0
  72. data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/MultipleInstancesWithRunTimeKnowledge.pione +33 -0
  73. data/example/WorkflowPatterns/33_GeneralizedANDJoin/GeneralizedANDJoin.pione +21 -0
  74. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/LocalSynchronizingMerge.pione +101 -0
  75. data/example/WorkflowPatterns/41_ThreadMerge/ThreadMerge.pione +43 -0
  76. data/example/WorkflowPatterns/42_ThreadSplit/ThreadSplit.pione +16 -0
  77. data/lib/pione.rb +23 -47
  78. data/lib/pione/agent/broker.rb +1 -1
  79. data/lib/pione/agent/input-generator.rb +1 -1
  80. data/lib/pione/agent/logger.rb +62 -49
  81. data/lib/pione/agent/messenger.rb +38 -0
  82. data/lib/pione/agent/rule-provider.rb +3 -3
  83. data/lib/pione/agent/task-worker.rb +14 -2
  84. data/lib/pione/agent/tuple-space-client.rb +1 -1
  85. data/lib/pione/agent/tuple-space-server-client-life-checker.rb +5 -3
  86. data/lib/pione/command.rb +2 -0
  87. data/lib/pione/command/basic-command.rb +1 -1
  88. data/lib/pione/command/pione-client.rb +57 -16
  89. data/lib/pione/command/pione-log.rb +5 -5
  90. data/lib/pione/command/pione-syntax-checker.rb +22 -7
  91. data/lib/pione/command/pione-task-worker.rb +36 -19
  92. data/lib/pione/command/pione-tuple-space-viewer.rb +3 -3
  93. data/lib/pione/command/pione-val.rb +40 -0
  94. data/lib/pione/component.rb +8 -0
  95. data/lib/pione/{system → component}/document.rb +13 -11
  96. data/lib/pione/component/package.rb +269 -0
  97. data/lib/pione/component/rule.rb +206 -0
  98. data/lib/pione/location/basic-location.rb +49 -7
  99. data/lib/pione/location/ftp-location.rb +19 -6
  100. data/lib/pione/location/local-location.rb +15 -6
  101. data/lib/pione/log.rb +4 -1
  102. data/lib/pione/log/{domain-info.rb → domain-log.rb} +23 -11
  103. data/lib/pione/{util/console-message.rb → log/message-log.rb} +16 -15
  104. data/lib/pione/log/process-log.rb +35 -86
  105. data/lib/pione/log/process-record.rb +24 -11
  106. data/lib/pione/log/system-log.rb +107 -0
  107. data/lib/pione/log/xes-log.rb +54 -48
  108. data/lib/pione/model.rb +1 -3
  109. data/lib/pione/model/assignment.rb +1 -0
  110. data/lib/pione/model/basic-model.rb +31 -15
  111. data/lib/pione/model/block.rb +1 -1
  112. data/lib/pione/model/boolean.rb +10 -23
  113. data/lib/pione/model/constraints.rb +12 -0
  114. data/lib/pione/model/data-expr.rb +31 -36
  115. data/lib/pione/model/feature-expr.rb +6 -23
  116. data/lib/pione/model/float.rb +29 -18
  117. data/lib/pione/model/integer.rb +44 -56
  118. data/lib/pione/model/keyed-sequence.rb +11 -4
  119. data/lib/pione/model/message.rb +4 -4
  120. data/lib/pione/model/ordinal-sequence.rb +12 -14
  121. data/lib/pione/model/package-expr.rb +53 -0
  122. data/lib/pione/model/parameters.rb +12 -11
  123. data/lib/pione/model/pione-method.rb +2 -2
  124. data/lib/pione/model/rule-expr.rb +30 -52
  125. data/lib/pione/model/sequence.rb +26 -26
  126. data/lib/pione/model/string.rb +13 -54
  127. data/lib/pione/model/ticket-expr.rb +12 -53
  128. data/lib/pione/model/type.rb +7 -1
  129. data/lib/pione/model/variable-table.rb +5 -4
  130. data/lib/pione/model/variable.rb +0 -5
  131. data/lib/pione/option/common-option.rb +2 -1
  132. data/lib/pione/option/task-worker-owner-option.rb +1 -1
  133. data/lib/pione/patch/drb-patch.rb +1 -1
  134. data/lib/pione/patch/em-ftpd-patch.rb +7 -0
  135. data/lib/pione/patch/rinda-patch.rb +53 -0
  136. data/lib/pione/patch/uri-patch.rb +5 -0
  137. data/lib/pione/relay/relay-socket.rb +2 -2
  138. data/lib/pione/rule-handler/action-handler.rb +71 -64
  139. data/lib/pione/rule-handler/basic-handler.rb +50 -32
  140. data/lib/pione/rule-handler/flow-handler.rb +51 -34
  141. data/lib/pione/rule-handler/update-criteria.rb +43 -20
  142. data/lib/pione/system.rb +13 -0
  143. data/lib/pione/system/domain-info.rb +34 -0
  144. data/lib/pione/system/global.rb +8 -1
  145. data/lib/pione/system/object.rb +1 -1
  146. data/lib/pione/transformer/expr-transformer.rb +3 -3
  147. data/lib/pione/transformer/literal-transformer.rb +3 -3
  148. data/lib/pione/transformer/rule-definition-transformer.rb +11 -9
  149. data/lib/pione/tuple-space/tuple-space-server-interface.rb +19 -1
  150. data/lib/pione/tuple-space/tuple-space-server.rb +9 -2
  151. data/lib/pione/tuple.rb +30 -0
  152. data/lib/pione/tuple/data-null-tuple.rb +14 -0
  153. data/lib/pione/tuple/message-tuple.rb +7 -0
  154. data/lib/pione/tuple/process-log-tuple.rb +13 -0
  155. data/lib/pione/tuple/touch-tuple.rb +14 -0
  156. data/lib/pione/uri-scheme/myftp-scheme.rb +45 -0
  157. data/lib/pione/util.rb +18 -0
  158. data/lib/pione/util/cpu.rb +20 -0
  159. data/lib/pione/util/error-report.rb +9 -1
  160. data/lib/pione/util/evaluatable.rb +47 -0
  161. data/lib/pione/util/ftp-server.rb +468 -0
  162. data/lib/pione/util/id.rb +39 -0
  163. data/lib/pione/util/indentation.rb +19 -0
  164. data/lib/pione/util/ip-address.rb +35 -0
  165. data/lib/pione/util/misc.rb +0 -47
  166. data/lib/pione/util/uuid.rb +28 -0
  167. data/lib/pione/util/variable-holdable.rb +38 -0
  168. data/lib/pione/version.rb +1 -1
  169. data/pione.gemspec +16 -14
  170. data/test/agent/spec_logger.rb +35 -44
  171. data/test/agent/spec_messenger.rb +25 -0
  172. data/test/agent/spec_rule-provider.rb +1 -1
  173. data/test/agent/spec_task-worker.rb +7 -13
  174. data/test/{system → component}/spec_document.rb +20 -20
  175. data/test/component/spec_package.rb +77 -0
  176. data/test/component/spec_package/TestPackage/Test.pione +14 -0
  177. data/test/component/spec_package/TestPackage/bin/count +3 -0
  178. data/test/component/spec_package/TestPackage/package.yml +7 -0
  179. data/test/component/spec_package/TestPackage/scenario/case1/input/1.txt +1 -0
  180. data/test/component/spec_package/TestPackage/scenario/case1/scenario.yml +1 -0
  181. data/test/component/spec_rule.rb +140 -0
  182. data/test/endurance-test/graph.plt +12 -0
  183. data/test/endurance-test/run.sh +65 -0
  184. data/test/location/location-behavior.rb +125 -0
  185. data/test/location/spec_ftp-location.rb +28 -90
  186. data/test/location/spec_local-location.rb +26 -76
  187. data/test/log/raw-process-log/pione-process.log +710 -0
  188. data/test/log/spec_domain-log.rb +57 -0
  189. data/test/log/spec_message-log.rb +44 -0
  190. data/test/log/spec_process-log.rb +88 -0
  191. data/test/log/spec_process-record.rb +148 -0
  192. data/test/log/spec_system-log.rb +142 -0
  193. data/test/log/spec_xes-log.rb +2 -2
  194. data/test/model/spec_assignment.rb +26 -25
  195. data/test/model/spec_block.rb +51 -97
  196. data/test/model/spec_boolean.rb +0 -5
  197. data/test/model/spec_call-rule.rb +6 -6
  198. data/test/model/spec_data-expr.rb +0 -7
  199. data/test/model/spec_data-expr.yml +8 -0
  200. data/test/model/spec_float.rb +1 -1
  201. data/test/model/spec_float.yml +13 -0
  202. data/test/model/spec_integer.rb +1 -1
  203. data/test/model/spec_integer.yml +12 -1
  204. data/test/model/spec_keyed-sequence.yml +5 -0
  205. data/test/model/spec_message.rb +2 -4
  206. data/test/model/spec_package-expr.rb +19 -0
  207. data/test/model/spec_parameters.rb +56 -88
  208. data/test/model/spec_pione-method.rb +15 -14
  209. data/test/model/spec_rule-expr.rb +4 -52
  210. data/test/model/spec_rule-expr.yml +11 -0
  211. data/test/model/spec_sequence.yml +6 -0
  212. data/test/model/spec_string.rb +21 -13
  213. data/test/model/spec_string.yml +10 -2
  214. data/test/model/spec_ticket-expr.rb +25 -3
  215. data/test/model/spec_variable.rb +8 -8
  216. data/test/rule-handler/spec_action-handler.pione +37 -0
  217. data/test/rule-handler/spec_action-handler.rb +41 -97
  218. data/test/rule-handler/spec_flow-handler.rb +24 -30
  219. data/test/rule-handler/spec_update-criteria.pione +16 -0
  220. data/test/rule-handler/spec_update-criteria.rb +7 -4
  221. data/test/rule-handler/spec_update-criteria.yml +191 -0
  222. data/test/system/spec_domain-info.rb +25 -0
  223. data/test/test-util.rb +38 -228
  224. data/test/transformer/spec_block-transformer.rb +1 -1
  225. data/test/transformer/spec_expr-transformer.rb +30 -39
  226. data/test/transformer/spec_flow-element-transformer.rb +17 -17
  227. data/test/transformer/spec_literal-transformer.rb +3 -3
  228. data/test/transformer/spec_rule-definition-transformer.rb +55 -76
  229. data/test/{spec_data-finder.rb → tuple-space/spec_data-finder.rb} +1 -1
  230. data/test/{spec_data-finder.yml → tuple-space/spec_data-finder.yml} +0 -0
  231. data/test/tuple/spec_data-tuple.rb +5 -76
  232. data/test/tuple/spec_finished-tuple.rb +5 -46
  233. data/test/tuple/spec_message-tuple.rb +10 -0
  234. data/test/tuple/spec_task-tuple.rb +4 -110
  235. data/test/tuple/spec_touch-tuple.rb +14 -0
  236. data/test/tuple/tuple-behavior.rb +14 -0
  237. data/test/uri-scheme/spec_local-scheme.rb +1 -1
  238. data/test/uri-scheme/spec_myftp-scheme.rb +73 -0
  239. data/test/uri-scheme/spec_myftp-scheme.yml +85 -0
  240. data/test/util/spec_cpu.rb +8 -0
  241. data/test/util/spec_error-report.rb +42 -0
  242. data/test/util/spec_evaluatable.rb +18 -0
  243. data/test/util/spec_ftp-server.rb +249 -0
  244. data/test/util/spec_id.pione +14 -0
  245. data/test/util/spec_id.rb +77 -0
  246. data/test/util/spec_indentation.rb +77 -0
  247. data/test/util/spec_ip-address.rb +15 -0
  248. data/test/util/spec_uuid.rb +11 -0
  249. data/test/util/spec_variable-holdable.rb +69 -0
  250. metadata +282 -83
  251. data/bin/pione-eval +0 -111
  252. data/demo/demo.rb +0 -311
  253. data/demo/public/base.css +0 -94
  254. data/demo/public/demo.js +0 -107
  255. data/demo/public/index.html +0 -91
  256. data/demo/public/jquery-1.8.3.min.js +0 -2
  257. data/lib/pione/model/binary-operator.rb +0 -90
  258. data/lib/pione/model/list.rb +0 -108
  259. data/lib/pione/model/package.rb +0 -56
  260. data/lib/pione/model/rule-io.rb +0 -178
  261. data/lib/pione/model/rule.rb +0 -295
  262. data/lib/pione/system/identifier.rb +0 -61
  263. data/lib/pione/tuple/log-tuple.rb +0 -14
  264. data/lib/pione/util/terminal.rb +0 -78
  265. data/test/log/data/sample.log +0 -1003
  266. data/test/model/spec_binary-operator.rb +0 -39
  267. data/test/model/spec_package.rb +0 -15
  268. data/test/model/spec_rule.rb +0 -158
  269. data/test/spec_identifier.rb +0 -29
  270. data/test/spec_log.rb +0 -52
@@ -1,10 +1,10 @@
1
1
  require_relative '../test-util'
2
2
 
3
- location = Pione::Location[File.join(File.dirname(__FILE__), "data", "sample.log")]
3
+ raw_process_log = Pione::Location[File.join(File.dirname(__FILE__), "raw-process-log", "pione-process.log")]
4
4
 
5
5
  describe 'Pione::XESLog' do
6
6
  it 'should format XES log' do
7
- result = Log::XESLog.read(location).format
7
+ result = Log::XESLog.read(raw_process_log).format
8
8
  result.should.kind_of String
9
9
  result.size.should > 0
10
10
  end
@@ -1,51 +1,52 @@
1
1
  require_relative '../test-util'
2
2
 
3
- describe 'Model::Assignment' do
3
+ describe 'Pione::Model::Assignment' do
4
+ before do
5
+ @var_x = Variable.new("X")
6
+ @var_y = Variable.new("Y")
7
+ @var_z = Variable.new("Z")
8
+ @a = PioneString.new("a")
9
+ @b = PioneString.new("b")
10
+ end
11
+
4
12
  it 'should be equal' do
5
- x1 = Assignment.new(Variable.new("X"), PioneString.new("a"))
6
- x2 = Assignment.new(Variable.new("X"), PioneString.new("a"))
13
+ x1 = Assignment.new(@var_x, @a)
14
+ x2 = Assignment.new(@var_x, @a)
7
15
  x1.should.be.equal x2
8
16
  end
9
17
 
10
18
  it 'should not be equal' do
11
- x1 = Assignment.new(Variable.new("X"), PioneString.new("a"))
12
- x2 = Assignment.new(Variable.new("X"), PioneString.new("b"))
13
- y1 = Assignment.new(Variable.new("Y"), PioneString.new("a"))
14
- y2 = Assignment.new(Variable.new("Y"), PioneString.new("b"))
19
+ x1 = Assignment.new(@var_x, @a)
20
+ x2 = Assignment.new(@var_x, @b)
21
+ y1 = Assignment.new(@var_y, @a)
22
+ y2 = Assignment.new(@var_y, @b)
15
23
  x1.should.not.be.equal x2
16
24
  x1.should.not.be.equal y1
17
25
  x1.should.not.be.equal y2
18
26
  end
19
27
 
20
28
  it 'should push variable and value into variable table' do
21
- Assignment.new(
22
- Variable.new("X"),
23
- PioneString.new("a")
24
- ).eval(VariableTable.new).should == PioneString.new("a")
29
+ vtable = VariableTable.new
30
+ Assignment.new(@var_x, @a).eval(vtable).should == @a
31
+ vtable.get(@var_x).should == @a
25
32
  end
26
33
 
27
34
  it 'should evaluate the value' do
28
35
  vtable = VariableTable.new
29
36
  Assignment.new(
30
- Variable.new("X"),
37
+ @var_x,
31
38
  Message.new("as_string", IntegerSequence.new([1.to_pione]))
32
39
  ).eval(vtable)
33
- Variable.new("X").eval(vtable).should == StringSequence.new(["1".to_pione])
40
+ @var_x.eval(vtable).should == StringSequence.new([PioneString.new("1")])
34
41
  end
35
42
 
36
43
  it 'should update variable table' do
37
44
  vtable = VariableTable.new
38
- Assignment.new(
39
- Variable.new("X"),
40
- "a".to_pione
41
- ).eval(vtable).should == "a".to_pione
42
- vtable.get(Variable.new("X")).should == "a".to_pione
43
- Assignment.new(
44
- Variable.new("Y"),
45
- Variable.new("Z")
46
- ).eval(vtable).should == Variable.new("Z")
47
- vtable.get(Variable.new("Y")).should == Variable.new("Z")
48
- vtable.set(Variable.new("Z"), "b".to_pione)
49
- vtable.get(Variable.new("Y")).should == "b".to_pione
45
+ Assignment.new(@var_x, @a).eval(vtable).should == @a
46
+ vtable.get(@var_x).should == @a
47
+ Assignment.new(@var_y, @var_z).eval(vtable).should == @var_z
48
+ vtable.get(@var_y).should == @var_z
49
+ vtable.set(@var_z, @b)
50
+ vtable.get(@var_y).should == @b
50
51
  end
51
52
  end
@@ -1,14 +1,12 @@
1
1
  require_relative '../test-util'
2
2
 
3
- describe 'Model::ActionBlock' do
3
+ describe 'Pione::Model::ActionBlock' do
4
4
  it 'should be equal' do
5
- ActionBlock.new("eccho 'a'").should ==
6
- ActionBlock.new("eccho 'a'")
5
+ ActionBlock.new("echo 'a'").should == ActionBlock.new("echo 'a'")
7
6
  end
8
7
 
9
8
  it 'should not be equal' do
10
- ActionBlock.new("eccho 'a'").should.not ==
11
- ActionBlock.new("eccho 'b'")
9
+ ActionBlock.new("echo 'a'").should.not == ActionBlock.new("echo 'b'")
12
10
  end
13
11
 
14
12
  it 'should expand variables' do
@@ -21,134 +19,90 @@ describe 'Model::ActionBlock' do
21
19
  end
22
20
  end
23
21
 
24
- describe 'Model::FlowBlock' do
22
+ describe 'Pione::Model::FlowBlock' do
23
+ before do
24
+ @rule_a = CallRule.new(RuleExpr.new(PackageExpr.new("test"), "a"))
25
+ @rule_b = CallRule.new(RuleExpr.new(PackageExpr.new("test"), "b"))
26
+ @rule_c = CallRule.new(RuleExpr.new(PackageExpr.new("test"), "c"))
27
+ @var_a = Variable.new("A")
28
+ @var_x = Variable.new("X")
29
+ @var_y = Variable.new("Y")
30
+ @var_z = Variable.new("Z")
31
+ end
32
+
25
33
  it 'should be equal' do
26
- FlowBlock.new(
27
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
28
- ).should == FlowBlock.new(
29
- Model::CallRule.new(RuleExpr.new(Package.new("test"), "a"))
30
- )
34
+ FlowBlock.new(@rule_a).should == FlowBlock.new(@rule_a)
31
35
  end
32
36
 
33
37
  it 'should not equal' do
34
- FlowBlock.new(
35
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
36
- ).should.not == FlowBlock.new(
37
- CallRule.new(RuleExpr.new(Package.new("test"), "b"))
38
- )
38
+ FlowBlock.new(@rule_a).should != FlowBlock.new(@rule_b)
39
39
  end
40
40
 
41
41
  it 'should get flow elements' do
42
- FlowBlock.new(
43
- CallRule.new(RuleExpr.new(Package.new("test"), "a")),
44
- CallRule.new(RuleExpr.new(Package.new("test"), "b")),
45
- CallRule.new(RuleExpr.new(Package.new("test"), "c"))
46
- ).elements.should == [
47
- CallRule.new(RuleExpr.new(Package.new("test"), "a")),
48
- CallRule.new(RuleExpr.new(Package.new("test"), "b")),
49
- CallRule.new(RuleExpr.new(Package.new("test"), "c"))
50
- ]
42
+ FlowBlock.new(@rule_a, @rule_b, @rule_c).elements.should == [@rule_a, @rule_b, @rule_c]
51
43
  end
52
44
 
53
45
  it 'should evaluate and get call-rule elements' do
54
- x = CallRule.new(RuleExpr.new(Package.new("test"), "x"))
55
- y = CallRule.new(RuleExpr.new(Package.new("test"), "y"))
56
- z = CallRule.new(RuleExpr.new(Package.new("test"), "z"))
57
- vtable = VariableTable.new
58
46
  block = FlowBlock.new(
59
- Assignment.new(Variable.new("X"), Variable.new("Y")),
60
- Assignment.new(Variable.new("Y"), Variable.new("Z")),
47
+ Assignment.new(@var_x, @var_y),
48
+ Assignment.new(@var_y, @var_z),
61
49
  ConditionalBlock.new(
62
- Variable.new("A"),
50
+ @var_a,
63
51
  { BooleanSequence.new([PioneBoolean.true]) =>
64
- FlowBlock.new(Assignment.new(Variable.new("Z"), IntegerSequence.new([1.to_pione]))),
52
+ FlowBlock.new(Assignment.new(@var_z, IntegerSequence.new([1.to_pione]))),
65
53
  }
66
54
  ),
67
- Assignment.new(Variable.new("A"), BooleanSequence.new([PioneBoolean.true])),
55
+ Assignment.new(@var_a, BooleanSequence.new([PioneBoolean.true])),
68
56
  ConditionalBlock.new(
69
- Message.new("==", Variable.new("Z"), IntegerSequence.new([1.to_pione])),
70
- { BooleanSequence.new([PioneBoolean.true]) => FlowBlock.new(z) }
57
+ Message.new("==", @var_z, IntegerSequence.new([1.to_pione])),
58
+ { BooleanSequence.new([PioneBoolean.true]) => FlowBlock.new(@rule_c) }
71
59
  ),
72
- x,
73
- y
60
+ @rule_a,
61
+ @rule_b
74
62
  )
75
- new_block = block.eval(vtable)
76
- new_block.elements.should.include x
77
- new_block.elements.should.include y
78
- new_block.elements.should.include z
63
+ new_block = block.eval(VariableTable.new)
64
+ new_block.elements.should.include @rule_a
65
+ new_block.elements.should.include @rule_b
66
+ new_block.elements.should.include @rule_c
79
67
  new_block.elements.each{|rule| rule.should.kind_of(CallRule)}
80
68
  end
81
69
  end
82
70
 
83
- describe 'Model::ConditionalBlock' do
71
+ describe 'Pione::Model::ConditionalBlock' do
72
+ before do
73
+ @a = PioneString.new("a")
74
+ @b = PioneString.new("b")
75
+ @c = PioneString.new("c")
76
+ @rule_a = CallRule.new(RuleExpr.new(PackageExpr.new("test"), "a"))
77
+ @rule_b = CallRule.new(RuleExpr.new(PackageExpr.new("test"), "b"))
78
+ @rule_c = CallRule.new(RuleExpr.new(PackageExpr.new("test"), "c"))
79
+ @var_a = Variable.new("A")
80
+ @var_x = Variable.new("X")
81
+ @var_y = Variable.new("Y")
82
+ @var_z = Variable.new("Z")
83
+ end
84
+
84
85
  it 'should be equal' do
85
86
  ConditionalBlock.new(
86
- Variable.new("X"),
87
- { "a".to_pione =>
88
- FlowBlock.new(
89
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
90
- ),
91
- "b".to_pione =>
92
- FlowBlock.new(
93
- CallRule.new(RuleExpr.new(Package.new("test"), "b"))
94
- )
95
- }
87
+ @var_x, {@a => FlowBlock.new(@rule_a), @b => FlowBlock.new(@rule_b)}
96
88
  ).should == ConditionalBlock.new(
97
- Variable.new("X"),
98
- { "a".to_pione =>
99
- FlowBlock.new(
100
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
101
- ),
102
- "b".to_pione =>
103
- FlowBlock.new(
104
- CallRule.new(RuleExpr.new(Package.new("test"), "b"))
105
- )
106
- }
89
+ @var_x, {@a => FlowBlock.new(@rule_a), @b => FlowBlock.new(@rule_b)}
107
90
  )
108
91
  end
109
92
 
110
93
  it 'should not be equal' do
111
94
  ConditionalBlock.new(
112
- Variable.new("X"),
113
- { "a".to_pione =>
114
- FlowBlock.new(
115
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
116
- ),
117
- "b".to_pione =>
118
- FlowBlock.new(
119
- CallRule.new(RuleExpr.new(Package.new("test"), "b"))
120
- )
121
- }
95
+ @var_x, {@a => FlowBlock.new(@rule_a), @b => FlowBlock.new(@rule_b)}
122
96
  ).should != ConditionalBlock.new(
123
- Variable.new("Y"),
124
- { "a".to_pione =>
125
- FlowBlock.new(
126
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
127
- ),
128
- "b".to_pione =>
129
- FlowBlock.new(
130
- CallRule.new(RuleExpr.new(Package.new("test"), "b"))
131
- )
132
- }
97
+ @var_y, {@a => FlowBlock.new(@rule_a), @b => FlowBlock.new(@rule_b)}
133
98
  )
134
99
  end
135
100
 
136
101
  it 'should evaluate' do
137
- vtable = VariableTable.new
138
102
  block = ConditionalBlock.new(
139
- Variable.new("X"),
140
- { "a".to_pione =>
141
- FlowBlock.new(
142
- CallRule.new(RuleExpr.new(Package.new("test"), "a"))
143
- ),
144
- "b".to_pione =>
145
- FlowBlock.new(
146
- CallRule.new(RuleExpr.new(Package.new("test"), "b"))
147
- )
148
- }
103
+ @var_x, {@a => FlowBlock.new(@rule_a), @b => FlowBlock.new(@rule_b)}
149
104
  )
150
- vtable.set(Variable.new("X"), "a".to_pione)
151
- block.eval(vtable).should ==
152
- FlowBlock.new(CallRule.new(RuleExpr.new(Package.new("test"), "a")))
105
+ vtable = VariableTable.new.set(@var_x, @a)
106
+ block.eval(vtable).should == FlowBlock.new(@rule_a)
153
107
  end
154
108
  end
@@ -11,11 +11,6 @@ describe 'Model::PioneBoolean' do
11
11
  PioneBoolean.false.should.false
12
12
  end
13
13
 
14
- it 'should get a ruby object that has same value' do
15
- @true.to_ruby.should == true
16
- @false.to_ruby.should == false
17
- end
18
-
19
14
  it 'should equal' do
20
15
  @true.should == PioneBoolean.true
21
16
  @false.should == PioneBoolean.false
@@ -2,22 +2,22 @@ require_relative '../test-util'
2
2
 
3
3
  describe 'Model::CallRule' do
4
4
  it 'should be equal' do
5
- CallRule.new(RuleExpr.new(Package.new("main"), "a")).should ==
6
- CallRule.new(RuleExpr.new(Package.new("main"), "a"))
5
+ CallRule.new(RuleExpr.new(PackageExpr.new("main"), "a")).should ==
6
+ CallRule.new(RuleExpr.new(PackageExpr.new("main"), "a"))
7
7
  end
8
8
 
9
9
  it 'should be not equal' do
10
- CallRule.new(RuleExpr.new(Package.new("main"), "a")).should.not ==
11
- CallRule.new(RuleExpr.new(Package.new("main"), "b"))
10
+ CallRule.new(RuleExpr.new(PackageExpr.new("main"), "a")).should.not ==
11
+ CallRule.new(RuleExpr.new(PackageExpr.new("main"), "b"))
12
12
  end
13
13
 
14
14
  it 'should eval' do
15
15
  a = CallRule.new(Variable.new("a"))
16
16
  a.eval(VariableTable.new(
17
17
  Variable.new("a") =>
18
- RuleExpr.new(Package.new("main"), "b")
18
+ RuleExpr.new(PackageExpr.new("main"), "b")
19
19
  )).should == CallRule.new(
20
- RuleExpr.new(Package.new("main"), "b")
20
+ RuleExpr.new(PackageExpr.new("main"), "b")
21
21
  )
22
22
  end
23
23
  end
@@ -273,13 +273,6 @@ describe 'Model::DataExpr' do
273
273
  exp.select('test-.a','test-1.a','test-a.a','test-a.b').should == ['test-1.a', 'test-a.a']
274
274
  exp.select.should.empty
275
275
  end
276
-
277
- describe 'pione method except' do
278
- it 'should set a exception' do
279
- DataExpr.new('test.a').to_seq.call_pione_method("except", DataExpr.new('test.b').to_seq).should ==
280
- DataExpr.new('test.a').except(DataExpr.new('test.b')).to_seq
281
- end
282
- end
283
276
  end
284
277
 
285
278
  describe "Model::DataExprNull" do
@@ -9,7 +9,15 @@
9
9
  - "'b'" : "'a'.except('b').exceptions"
10
10
 
11
11
  # accept_nonexistence?
12
+ - "false" : "'a'.accept_nonexistence?"
13
+ - "false" : "('a' or 'a').accept_nonexistence?"
12
14
  - "true" : "('a' or null).accept_nonexistence?"
15
+ - "true" : "(null or 'a').accept_nonexistence?"
16
+ - "true" : "(null or null).accept_nonexistence?"
17
+ - "false | false | false" : "('a' | 'b' | 'c').accept_nonexistence?"
18
+ - "true | false | false" : "('a' or null | 'b' | 'c').accept_nonexistence?"
19
+ - "true | true | false" : "('a' or null | 'b' or null | 'c').accept_nonexistence?"
20
+ - "true | true | true" : "('a' or null | 'b' or null | 'c' or null).accept_nonexistence?"
13
21
 
14
22
  # as_string
15
23
  - '"a b c"' : "('a' | 'b' | 'c').as_string.join(\" \")"
@@ -7,7 +7,7 @@ describe 'Model::PioneFloat' do
7
7
  end
8
8
 
9
9
  it 'should get a ruby object that has same value' do
10
- @one.to_ruby.should == 1.0
10
+ @one.value.should == 1.0
11
11
  end
12
12
 
13
13
  it 'should equal' do
@@ -15,3 +15,16 @@
15
15
  # as_float, f
16
16
  - "0.1" : "0.1.as_float"
17
17
  - "1.0" : "1.0.f"
18
+
19
+ # sin
20
+ - "0.0" : "0.0.sin"
21
+ - "-1.0.sin" : "0.0 - 1.0.sin"
22
+
23
+ # cos
24
+ - "1.0" : "0.0.cos"
25
+ - "1.0.cos" : "-1.0.cos"
26
+
27
+ # abs
28
+ - "1.0" : "1.0.abs"
29
+ - "1.0" : "-1.0.abs"
30
+ - "(1.0 | 1.0)" : "(1.0 | -1.0).abs"
@@ -7,7 +7,7 @@ describe 'Model::PioneInteger' do
7
7
  end
8
8
 
9
9
  it 'should get a ruby object that has same value' do
10
- @one.to_ruby.should == 1
10
+ @one.value.should == 1
11
11
  end
12
12
 
13
13
  it 'should equal' do
@@ -22,7 +22,7 @@
22
22
  - "2 | 3 | 4| 3 | 4 | 5 | 4 | 5 | 6" : '(1 | 2 | 3) + (1 | 2 | 3)'
23
23
 
24
24
  # -
25
- - "-4" : '1 - 2 - 3'
25
+ # - "-4" : '1 - 2 - 3' # BUG!!!
26
26
  - "0 | -1 | -2" : '1 - (1 | 2 | 3)'
27
27
  - "0 | 1 | 2" : '(1 | 2 | 3) - 1'
28
28
  - "0 | -1 | -2 | 1 | 0 | -1 | 2 | 1 | 0" : '(1 | 2 | 3) - (1 | 2 | 3)'
@@ -55,3 +55,14 @@
55
55
  - '3 | 3 | 2 | 3 | 2 | 1' : '3.downto(3 | 2 | 1)'
56
56
  - '3 | 3 | 2 | 3 | 2 | 1 | 2 | 2 | 2 | 1 | 1 | 1 | 1' : '(3 | 2 | 1).downto(3 | 2 | 1)'
57
57
 
58
+ # max
59
+ - '3' : '(1 | 2 | 3).max'
60
+ - '2' : '(1 | 2).max'
61
+ - '1' : '1.max'
62
+
63
+ # min
64
+ - '1' : '(1 | 2 | 3).min'
65
+ - '2' : '(2 | 3).min'
66
+ - '3' : '3.min'
67
+
68
+
@@ -20,3 +20,8 @@
20
20
  # values
21
21
  - '"a" | "b" | "c"' : '((1 : "a") | (2 : "b") | (3 : "c")).values'
22
22
 
23
+ # textize
24
+ - '"a b c"' : '((1 : "a") | (2 : "b") | (3 : "c")).textize'
25
+ - '"1 2 3"' : '(("a" : 1) | ("b" : 2) | ("c" : 3)).textize'
26
+ - '"a b c"' : "((1 : 'a') | (2 : 'b') | (3 : 'c')).textize"
27
+
@@ -32,11 +32,9 @@ describe 'Model::Message' do
32
32
  end
33
33
 
34
34
  it 'should include variables' do
35
+ Message.new("next", Variable.new("N")).should.include_variable
35
36
  Message.new(
36
- "next", Variable.new("N")
37
- ).should.include_variable
38
- Message.new(
39
- "substring", "abcdef", Variable.new("FROM"), Variable.new("TO")
37
+ "substring", PioneString.new("abcdef"), Variable.new("FROM"), Variable.new("TO")
40
38
  ).should.include_variable
41
39
  end
42
40
  end