Class: TestRecursiveOpenStruct
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestRecursiveOpenStruct
- Defined in:
- lib/Recursive_Open_Struct.rb
Instance Method Summary collapse
- #setAndAssertValue(val) ⇒ Object
- #setup ⇒ Object
- #testAttrs ⇒ Object
- #testDeep ⇒ Object
- #testKlammer ⇒ Object
- #testRaiseTypeError ⇒ Object
- #testRecursive ⇒ Object
- #testSet0 ⇒ Object
- #testSetClass ⇒ Object
- #testSetFalse ⇒ Object
- #testSetNil ⇒ Object
- #testSetStr ⇒ Object
- #testSetTrue ⇒ Object
- #testSimple ⇒ Object
- #testStrange ⇒ Object
Instance Method Details
#setAndAssertValue(val) ⇒ Object
148 149 150 151 152 153 154 155 |
# File 'lib/Recursive_Open_Struct.rb', line 148 def setAndAssertValue(val) @s.test = val assert_equal(val, @s.test) @s.close assert_equal(val, @s.test) @s.test = "asdf" assert_equal("asdf", @s.test) end |
#setup ⇒ Object
144 145 146 |
# File 'lib/Recursive_Open_Struct.rb', line 144 def setup @s = Recursive_Open_Struct.new end |
#testAttrs ⇒ Object
194 195 196 197 198 199 |
# File 'lib/Recursive_Open_Struct.rb', line 194 def testAttrs assert_equal([], @s.attrs) @s.b = "x" @s.a = "a" assert_equal(["a", "b"], @s.attrs) end |
#testDeep ⇒ Object
224 225 226 227 228 229 230 231 |
# File 'lib/Recursive_Open_Struct.rb', line 224 def testDeep @s.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z = false @s.close assert_raise(NoMethodError) do @s.blub = "hellow" end assert_equal(false, @s.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z) end |
#testKlammer ⇒ Object
215 216 217 218 219 220 221 222 |
# File 'lib/Recursive_Open_Struct.rb', line 215 def testKlammer @s.a = "asdf" assert_equal("asdf", @s["a"]) @s.b_x = "hog" assert_equal("hog", @s["b_x"]) @s.c.b.a = 1234 assert_equal(1234, @s["c"]["b"]["a"]) end |
#testRaiseTypeError ⇒ Object
187 188 189 190 191 192 |
# File 'lib/Recursive_Open_Struct.rb', line 187 def testRaiseTypeError @s.a.b = 1 assert_raise(TypeError) do @s.a = 3 end end |
#testRecursive ⇒ Object
201 202 203 204 205 |
# File 'lib/Recursive_Open_Struct.rb', line 201 def testRecursive @s.a.b = 1 @s.a.c = 2 assert_equal(["a"], @s.attrs) end |
#testSet0 ⇒ Object
183 184 185 |
# File 'lib/Recursive_Open_Struct.rb', line 183 def testSet0 setAndAssertValue(0) end |
#testSetClass ⇒ Object
175 176 177 |
# File 'lib/Recursive_Open_Struct.rb', line 175 def testSetClass setAndAssertValue(String) end |
#testSetFalse ⇒ Object
167 168 169 |
# File 'lib/Recursive_Open_Struct.rb', line 167 def testSetFalse setAndAssertValue(false) end |
#testSetNil ⇒ Object
157 158 159 |
# File 'lib/Recursive_Open_Struct.rb', line 157 def testSetNil setAndAssertValue(nil) end |
#testSetStr ⇒ Object
171 172 173 |
# File 'lib/Recursive_Open_Struct.rb', line 171 def testSetStr setAndAssertValue("topfen") end |
#testSetTrue ⇒ Object
179 180 181 |
# File 'lib/Recursive_Open_Struct.rb', line 179 def testSetTrue setAndAssertValue(true) end |
#testSimple ⇒ Object
161 162 163 164 165 |
# File 'lib/Recursive_Open_Struct.rb', line 161 def testSimple @s.test = "xx" @s.close assert_equal("xx", @s.test) end |
#testStrange ⇒ Object
207 208 209 210 211 212 213 |
# File 'lib/Recursive_Open_Struct.rb', line 207 def testStrange @s.a assert_equal(["a"], @s.attrs) assert_equal(Recursive_Open_Struct, @s.a.class) @s.a.x = "asfd" assert_equal("asfd", @s.a.x) end |