Module: Linda::Test::Tuple
- Defined in:
- lib/linda/test/tuple.rb
Instance Method Summary collapse
- #test_array_tuple ⇒ Object
- #test_hash_tuple ⇒ Object
- #test_match_array ⇒ Object
- #test_match_array_tuple ⇒ Object
- #test_match_hash ⇒ Object
- #test_match_hash_tuple ⇒ Object
Instance Method Details
#test_array_tuple ⇒ Object
5 6 7 8 9 10 |
# File 'lib/linda/test/tuple.rb', line 5 def test_array_tuple tuple = target_tuple.new([1,2,:a]) assert_equal tuple.data, [1,2,:a] assert_equal tuple.type, Array assert_equal JSON.parse(tuple.to_json), [1,2,"a"] end |
#test_hash_tuple ⇒ Object
12 13 14 15 16 17 |
# File 'lib/linda/test/tuple.rb', line 12 def test_hash_tuple tuple = target_tuple.new(:a => 1, :b => 2) assert_equal tuple.data, {:a => 1, :b => 2} assert_equal tuple.type, Hash assert_equal JSON.parse(tuple.to_json), {"a" => 1, "b" => 2} end |
#test_match_array ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/linda/test/tuple.rb', line 34 def test_match_array tuple = target_tuple.new [1,2,3] assert tuple.match? [1,2,3] assert tuple.match? [1,2,3,4] assert !tuple.match?([1,2]) assert !tuple.match?([1,"a",3]) assert !tuple.match?(:a => 1, :b => 2) tuple = target_tuple.new ["a","b","c"] assert tuple.match? ["a","b","c"] assert tuple.match? ["a","b","c","d","efg",123,"h"] assert !tuple.match?(["a","b"]) assert !tuple.match?(["a","b",789]) assert !tuple.match?(:foo => 1, :bar => 2) end |
#test_match_array_tuple ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/linda/test/tuple.rb', line 19 def test_match_array_tuple tuple = target_tuple.new [1,2,3] assert tuple.match? target_tuple.new [1,2,3] assert tuple.match? target_tuple.new [1,2,3,4] assert !tuple.match?(target_tuple.new [1,2]) assert !tuple.match?(target_tuple.new [1,"a",3]) assert !tuple.match?(target_tuple.new :a => 1, :b => 2) tuple = target_tuple.new ["a","b","c"] assert tuple.match? target_tuple.new ["a","b","c"] assert tuple.match? target_tuple.new ["a","b","c","d","efg",123,"h"] assert !tuple.match?(target_tuple.new ["a","b"]) assert !tuple.match?(target_tuple.new ["a","b",789]) assert !tuple.match?(target_tuple.new :foo => 1, :bar => 2) end |
#test_match_hash ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/linda/test/tuple.rb', line 59 def test_match_hash tuple = target_tuple.new :a => 1, :b => 2 assert tuple.match? :a => 1, :b => 2 assert tuple.match? :a => 1, :b => 2, :c => 3 assert tuple.match? :a => 1, :b => 2, :c => {:foo => "bar"} assert !tuple.match?(:a => 0, :b => 2) assert !tuple.match?(:b => 2, :c => 3) assert !tuple.match?([1,2,3]) end |
#test_match_hash_tuple ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/linda/test/tuple.rb', line 49 def test_match_hash_tuple tuple = target_tuple.new :a => 1, :b => 2 assert tuple.match? target_tuple.new :a => 1, :b => 2 assert tuple.match? target_tuple.new :a => 1, :b => 2, :c => 3 assert tuple.match? target_tuple.new :a => 1, :b => 2, :c => {:foo => "bar"} assert !tuple.match?(target_tuple.new :a => 0, :b => 2) assert !tuple.match?(target_tuple.new :b => 2, :c => 3) assert !tuple.match?(target_tuple.new [1,2,3]) end |