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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4570f5c16ed669363e2f486537279b8fff18f13b
4
- data.tar.gz: 493b757dc0e50e955a57d27531a1b820dd6eac04
3
+ metadata.gz: 5b2ecda77bfc45a49d215cf17020f630ee0f34be
4
+ data.tar.gz: a83ad616cf8cd540ed9823e6a42938b4617312ff
5
5
  SHA512:
6
- metadata.gz: cfc80d5a5f74bb162055f19923658d64348ee5e69530bb6aeb2f1bd5cc7982c7cd549375a1f8a92d505cb66c374cb0963e461903924f96d2c19dfe5556553eab
7
- data.tar.gz: d89389ec377ad6d26addc8c1369bdbc6eae27be4bd87b75190fcf25b07d7ccd35554b053e7ecf8f41e17aa386323cb8509cb43af96048502d93e2dd271593eaa
6
+ metadata.gz: 7ba1c8559c1fb4b906e176403bd4d015bc257535afc719f308cd658574fd5c7858a127d3ea138eac27f343dbffd66ebbb8c24f32a3a6a971e1bf121c16d32ed1
7
+ data.tar.gz: ab033d8eaabe98073c1d783450145232aaa09041947c66fa85b1069fe654a4c753f8372b948934f3b6523ceb0ba34fc7b3e2253ab103be3252be7df86230ea48
@@ -4,8 +4,8 @@
4
4
  #
5
5
  class YPetri::Place::Guard
6
6
  ERRMSG = -> m, of, assert do
7
- "Marking #{m}:#{m.class}" +
8
- if of then " of #{of.name || of rescue of}" else '' end +
7
+ "Marking #{m.insp}" +
8
+ if of then " of #{of.name || of}" else '' end +
9
9
  " #{assert}!"
10
10
  end
11
11
 
@@ -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: name || self, &block )
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
@@ -1,4 +1,4 @@
1
1
  module YPetri
2
- VERSION = "2.2.1"
2
+ VERSION = "2.2.2"
3
3
  DEBUG = false
4
4
  end
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
- before do
12
- @pç = pç = Class.new YPetri::Place
13
- @p = pç.avid default_marking: 3.2,
14
- marking: 1.1,
15
- quantum: 0.1,
16
- name: "P1"
17
- end
18
-
19
- it "should support #name" do
20
- assert_respond_to @p, :name
21
- assert_equal @p.name, :P1
22
- end
23
-
24
- it "should have marking and related methods" do
25
- @p.marking.must_equal 1.1 # Attention, #marking overloaded with guard setup!
26
- @p.quantum.must_equal 0.1
27
- @p.add 1
28
- @p.value.must_equal 2.1 # near-alias of #marking (no guard setup)
29
- @p.subtract 0.5
30
- @p.m.must_equal 1.6 # alias of #value
31
- @p.reset_marking
32
- @p.marking.must_equal 3.2
33
- @p.marking = 42
34
- @p.m.must_equal 42
35
- @p.m = 43
36
- @p.m.must_equal 43
37
- @p.value = 44
38
- @p.m.must_equal 44
39
- end
40
-
41
- it "should have decent #inspect and #to_s methods" do
42
- assert @p.inspect.start_with? "#<Place:"
43
- assert @p.to_s.start_with? "#{@p.name}["
44
- end
45
-
46
- it "should have arc getter methods" do
47
- @p.upstream_arcs.must_equal []
48
- @p.upstream_transitions.must_equal [] # alias of #upstream_arcs
49
- @p.ϝ.must_equal [] # alias of #upstream_arcs
50
- @p.downstream_arcs.must_equal []
51
- @p.downstream_transitions.must_equal [] # alias of #downstream_arcs
52
- @p.arcs.must_equal [] # all arcs
53
- @p.precedents.must_equal []
54
- @p.upstream_places.must_equal [] # alias for #precedents
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; @p.guard.( 11.1 ); :nothing_raised
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
- @p.marking "must be in 0..10" do |m| fail unless ( 0..10 ) === m end
79
- @p.guards.size.must_equal 4
80
- g = @p.federated_guard_closure
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; @p.marking = -1.11; rescue YPetri::GuardError => err
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.1
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-16 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: y_support