summaryrefslogtreecommitdiffstats
path: root/test.rb
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-12-21 20:14:52 -0500
committerCasey Dahlin <cdahlin@redhat.com>2008-12-21 20:14:52 -0500
commit24781fbc3ad4640b360e92561948f412fbb7ef3e (patch)
treefb6964cc9843d41aa79e96502c967135402edbad /test.rb
parent8962d343063795e1d9eb6b2c5d53e90c405c59c5 (diff)
downloadupstate-24781fbc3ad4640b360e92561948f412fbb7ef3e.tar.gz
upstate-24781fbc3ad4640b360e92561948f412fbb7ef3e.tar.xz
upstate-24781fbc3ad4640b360e92561948f412fbb7ef3e.zip
Beginnings of python rewrite
Diffstat (limited to 'test.rb')
-rw-r--r--test.rb129
1 files changed, 0 insertions, 129 deletions
diff --git a/test.rb b/test.rb
deleted file mode 100644
index 87cb5bf..0000000
--- a/test.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-require 'state'
-require 'set'
-require 'test/unit'
-
-
-def put_states
- foo = State.send(:class_variable_get, :@@states).map{ |x| x.to_s_color }
- puts foo.sort.join(", ")
-end
-
-class TC_State < Test::Unit::TestCase
- include UpState
-
- Foo = State.new_type("foo", [Event.new("gimmefoo", {:bob => /^...$/})], [], [:bob])
- Bar = State.new_type("bar", [], [Dependency.new(Foo)])
- Baz = State.new_type("baz", [], [Dependency.new(Foo, {:bob => "abc"}, {:bob => :tom}), Dependency.new(Bar)])
- Bam = State.new_type("bam", [Event::Epsilon], [Dependency.new(Baz)])
- Bang = State.new_type("bang", [], [Dependency.new(Bam)])
-
- def assert_have_states(*s)
- assert_equal(s.sort, State.get_all.map{ |x| x.to_s }.sort)
- end
-
- def assert_only_states(*s)
- assert_have_states *s
- assert_equal(State.get_all.size, s.size)
- end
-
- def setup
- assert_only_states "FooState{} (down)"
- end
-
- def teardown
- State.release(:user)
- State.release(:system)
- end
-
- def test_ignored_event
- State.process_event(Event.new("gimmefoo", {:bob => "1234"}))
- assert_only_states "FooState{} (down)"
- end
-
- def test_responded_event
- State.process_event(Event.new("gimmefoo", {:bob => "123"}))
- assert_only_states('FooState{} (down)', 'FooState{:bob=>"123"} (up)', "BarState{} (down)")
- end
-
- def test_hold_with_dependent
- test_responded_event
- Bar.get_all.first.hold(:user)
- assert_only_states('FooState{} (down)', 'FooState{:bob=>"123"} (up)', "BarState{} (up)")
- end
-
- def test_hold_non_existant_state
- Bar.hold(:user)
- assert_only_states "FooState{} (down)"
- end
-
- def test_pattern_matched_param_dep
- State.process_event(Event.new("gimmefoo", {:bob => "abc"}))
- Bar.hold(:user)
- assert_only_states(
- 'BazState{:tom=>"abc"} (down)',
- 'FooState{} (down)',
- 'FooState{:bob=>"abc"} (up)',
- "BarState{} (up)"
- )
- end
-
- def test_duplicitous_state_by_deps
- test_pattern_matched_param_dep
- State.process_event(Event.new("gimmefoo", {:bob => "123"}))
- assert_only_states(
- 'BazState{:tom=>"abc"} (down)',
- 'FooState{} (down)',
- 'FooState{:bob=>"abc"} (up)',
- 'FooState{:bob=>"123"} (up)',
- "BarState{} (up)",
- "BarState{} (down)"
- )
- end
-
- def test_identity_uniqueness
- test_pattern_matched_param_dep
- State.process_event(Event.new("gimmefoo", {:bob => "abc"}))
- assert_only_states(
- 'BazState{:tom=>"abc"} (down)',
- 'FooState{} (down)',
- 'FooState{:bob=>"abc"} (up)',
- "BarState{} (up)"
- )
- end
-
- def test_epsilon
- test_pattern_matched_param_dep
- Baz.hold(:user)
- assert_only_states(
- 'BazState{:tom=>"abc"} (up)',
- 'FooState{} (down)',
- 'FooState{:bob=>"abc"} (up)',
- "BarState{} (up)",
- "BamState{} (up)",
- "BangState{} (down)"
- )
- end
-
- def test_release_noop
- test_epsilon
- Bar.release(:user)
- assert_only_states(
- 'BazState{:tom=>"abc"} (up)',
- 'FooState{} (down)',
- 'FooState{:bob=>"abc"} (up)',
- "BarState{} (up)",
- "BamState{} (up)",
- "BangState{} (down)"
- )
- end
-
- def test_drop_cleanup
- test_release_noop
- Bar.get_all.each{ |x| x.drop }
- assert_only_states(
- 'FooState{} (down)',
- 'FooState{:bob=>"abc"} (up)',
- "BarState{} (down)"
- )
- end
-end