y_petri 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/y_petri/place/guard.rb +2 -2
- data/lib/y_petri/place/guarded.rb +1 -1
- data/lib/y_petri/version.rb +1 -1
- data/test/place_test.rb +49 -65
- data/test/y_petri_test.rb +0 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b2ecda77bfc45a49d215cf17020f630ee0f34be
|
4
|
+
data.tar.gz: a83ad616cf8cd540ed9823e6a42938b4617312ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba1c8559c1fb4b906e176403bd4d015bc257535afc719f308cd658574fd5c7858a127d3ea138eac27f343dbffd66ebbb8c24f32a3a6a971e1bf121c16d32ed1
|
7
|
+
data.tar.gz: ab033d8eaabe98073c1d783450145232aaa09041947c66fa85b1069fe654a4c753f8372b948934f3b6523ceb0ba34fc7b3e2253ab103be3252be7df86230ea48
|
data/lib/y_petri/place/guard.rb
CHANGED
@@ -37,7 +37,7 @@ module YPetri::Place::Guarded
|
|
37
37
|
#
|
38
38
|
def guard *args, &block
|
39
39
|
if block then
|
40
|
-
@guards << YPetri::Place::Guard.new( *args, place:
|
40
|
+
@guards << YPetri::Place::Guard.new( *args, place: self, &block )
|
41
41
|
elsif args.size == 1 then
|
42
42
|
federated_guard_closure.( args[0] )
|
43
43
|
elsif args.empty? then
|
data/lib/y_petri/version.rb
CHANGED
data/test/place_test.rb
CHANGED
@@ -8,78 +8,62 @@ require_relative '../lib/y_petri' # tested component itself
|
|
8
8
|
# require 'sy'
|
9
9
|
|
10
10
|
describe YPetri::Place do
|
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
|
-
@p.dependents.must_equal []
|
56
|
-
@p.downstream_places.must_equal [] # alias for #dependents
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should have convenience methods to fire surrounding transitions" do
|
60
|
-
assert_respond_to @p, :fire_upstream
|
61
|
-
assert_respond_to @p, :fire_upstream!
|
62
|
-
assert_respond_to @p, :fire_downstream
|
63
|
-
assert_respond_to @p, :fire_downstream!
|
64
|
-
assert_respond_to @p, :fire_upstream_recursively
|
65
|
-
assert_respond_to @p, :fire_downstream_recursively
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should have guard mechanics" do
|
69
|
-
@p.guards.size.must_equal 3 # working automatic guard construction
|
70
|
-
g1, g2 = @p.guards
|
11
|
+
it "should work" do
|
12
|
+
pç = Class.new YPetri::Place
|
13
|
+
p = pç.new default_marking: 3.2,
|
14
|
+
marking: 1.1,
|
15
|
+
quantum: 0.1,
|
16
|
+
name: "P1"
|
17
|
+
p.namespace.must_equal YPetri::Place
|
18
|
+
p.name.must_equal :P1
|
19
|
+
p.inspect[0..7].must_equal "#<Place:"
|
20
|
+
p.to_s[0..2].must_equal 'P1['
|
21
|
+
p.marking.must_equal 1.1 # Attention, #marking overloaded with guard setup!
|
22
|
+
p.quantum.must_equal 0.1
|
23
|
+
p.add 1
|
24
|
+
p.value.must_equal 2.1 # near-alias of #marking (no guard setup)
|
25
|
+
p.subtract 0.5
|
26
|
+
p.m.must_equal 1.6 # alias of #value
|
27
|
+
p.reset_marking
|
28
|
+
p.marking.must_equal 3.2
|
29
|
+
p.marking = 42
|
30
|
+
p.m.must_equal 42
|
31
|
+
p.m = 43
|
32
|
+
p.m.must_equal 43
|
33
|
+
p.value = 44
|
34
|
+
p.m.must_equal 44
|
35
|
+
p.upstream_arcs.must_equal []
|
36
|
+
p.upstream_transitions.must_equal [] # alias of #upstream_arcs
|
37
|
+
p.ϝ.must_equal [] # alias of #upstream_arcs
|
38
|
+
p.downstream_arcs.must_equal []
|
39
|
+
p.downstream_transitions.must_equal [] # alias of #downstream_arcs
|
40
|
+
p.arcs.must_equal [] # all arcs
|
41
|
+
p.precedents.must_equal []
|
42
|
+
p.upstream_places.must_equal [] # alias for #precedents
|
43
|
+
p.dependents.must_equal []
|
44
|
+
p.downstream_places.must_equal [] # alias for #dependents
|
45
|
+
# fire methods
|
46
|
+
assert_respond_to p, :fire_upstream
|
47
|
+
assert_respond_to p, :fire_upstream!
|
48
|
+
assert_respond_to p, :fire_downstream
|
49
|
+
assert_respond_to p, :fire_downstream!
|
50
|
+
assert_respond_to p, :fire_upstream_recursively
|
51
|
+
assert_respond_to p, :fire_downstream_recursively
|
52
|
+
# guard mechanics
|
53
|
+
p.guards.size.must_equal 3 # working automatic guard construction
|
54
|
+
g1, g2 = p.guards
|
71
55
|
[g1.assertion, g2.assertion].tap { |u, v|
|
72
56
|
assert u.include?( "number" ) || u.include?( "Numeric" )
|
73
57
|
assert v.include?( "complex" ) || v.include?( "Complex" )
|
74
58
|
}
|
75
|
-
begin; g1.validate 11.1; g2.validate 11.1;
|
59
|
+
begin; g1.validate 11.1; g2.validate 11.1; p.guard.( 11.1 ); :nothing_raised
|
76
60
|
rescue; :error end.must_equal :nothing_raised
|
77
61
|
-> { g2.validate Complex( 1, 1 ) }.must_raise YPetri::GuardError
|
78
|
-
|
79
|
-
|
80
|
-
g =
|
62
|
+
p.marking "must be in 0..10" do |m| fail unless ( 0..10 ) === m end
|
63
|
+
p.guards.size.must_equal 4
|
64
|
+
g = p.federated_guard_closure
|
81
65
|
-> { g.( 11.1 ) }.must_raise YPetri::GuardError
|
82
|
-
begin;
|
66
|
+
begin; p.marking = -1.11; rescue YPetri::GuardError => err
|
83
67
|
err.message.must_equal 'Marking -1.11:Float of P1 should not be negative!'
|
84
68
|
end
|
85
69
|
end
|
data/test/y_petri_test.rb
CHANGED
@@ -7,15 +7,6 @@ require_relative '../lib/y_petri' # tested component itself
|
|
7
7
|
# require 'y_petri'
|
8
8
|
# require 'sy'
|
9
9
|
|
10
|
-
# Unit tests for the YPetri module.
|
11
|
-
#
|
12
|
-
describe YPetri do
|
13
|
-
it "should have basic classes" do
|
14
|
-
[ :Place, :Transition, :Net, :Simulation, :World, :Agent ]
|
15
|
-
.each { |ß| YPetri.const_get( ß ).must_be_kind_of Module }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
10
|
# Run all other unit tests.
|
20
11
|
#
|
21
12
|
require_relative 'place_test'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: y_petri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: y_support
|