Module: UnionTest
- Defined in:
- lib/type_struct/union_test.rb
Constant Summary collapse
- U =
Union.new(TrueClass, FalseClass)
Instance Method Summary collapse
- #test_class_or(t) ⇒ Object
- #test_class_or_is_undefined(t) ⇒ Object
- #test_equal(t) ⇒ Object
- #test_or(t) ⇒ Object
- #test_union(t) ⇒ Object
Instance Method Details
#test_class_or(t) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/type_struct/union_test.rb', line 46 def test_class_or(t) u = TrueClass | FalseClass unless u === true t.error("error") end end |
#test_class_or_is_undefined(t) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/type_struct/union_test.rb', line 37 def test_class_or_is_undefined(t) TrueClass | FalseClass rescue NoMethodError else t.error("refinents miss") end |
#test_equal(t) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/type_struct/union_test.rb', line 25 def test_equal(t) unless U === true t.error("union error") end unless U === false t.error("union error") end if U === nil t.error("union error") end end |
#test_or(t) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/type_struct/union_test.rb', line 11 def test_or(t) if U === nil t.error("nil") end n = U | NilClass if U === nil t.error("nil") end unless n === nil t.error("nil") end end |
#test_union(t) ⇒ Object
5 6 7 8 9 |
# File 'lib/type_struct/union_test.rb', line 5 def test_union(t) unless Union === U t.error("union error") end end |