Module: HashOfTest
- Defined in:
- lib/type_struct/hash_of_test.rb
Instance Method Summary collapse
Instance Method Details
#test_equal(t) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/type_struct/hash_of_test.rb', line 10 def test_equal(t) ssh = HashOf.new(String, String) unless ssh === { "a" => "b", "c" => "d" } t.error("=== equal check failed") end if ssh === { "a" => "b", "c" => :d } t.error("=== equal check failed") end if ssh === { "a" => "b", :c => "d" } t.error("=== equal check failed") end ifh = HashOf.new(Integer, Float) unless ifh === { 1 => 1.0, 2 => Float::NAN } t.error("=== equal check failed") end if ifh === { 1 => 1, 2 => Float::NAN } t.error("=== equal check failed") end if ifh === { 1 => 1.0, "2" => "1" } t.error("=== equal check failed") end end |
#test_initialize(t) ⇒ Object
4 5 6 7 8 |
# File 'lib/type_struct/hash_of_test.rb', line 4 def test_initialize(t) unless HashOf === HashOf.new(String, String) t.error("make hash of") end end |
#test_to_s(t) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/type_struct/hash_of_test.rb', line 34 def test_to_s(t) hash_of = HashOf.new(Symbol, Integer) expect = "TypeStruct::HashOf(Symbol, Integer)" unless expect == hash_of.to_s t.error("to_s string was break #{expect} != #{hash_of}") end end |