Class: RandHashTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- RandHashTest
- Includes:
- RandTestHelpers
- Defined in:
- lib/rand.rb
Overview
:nodoc:
Instance Method Summary collapse
- #ha ⇒ Object
- #test_pick ⇒ Object
- #test_pick! ⇒ Object
- #test_pick_key ⇒ Object
- #test_pick_key! ⇒ Object
- #test_pick_value ⇒ Object
- #test_pick_value! ⇒ Object
- #test_shuffle ⇒ Object
- #test_shuffle_hash ⇒ Object
- #test_shuffle_hash! ⇒ Object
Methods included from RandTestHelpers
Instance Method Details
#ha ⇒ Object
303 304 305 |
# File 'lib/rand.rb', line 303 def ha Hash[*(1..100).to_a] end |
#test_pick ⇒ Object
307 308 309 |
# File 'lib/rand.rb', line 307 def test_pick assert true, picker(ha, ha.entries, :pick) end |
#test_pick! ⇒ Object
311 312 313 314 |
# File 'lib/rand.rb', line 311 def test_pick! h = ha assert true, picker(h, ha.entries, :pick!) and h.empty? end |
#test_pick_key ⇒ Object
316 317 318 |
# File 'lib/rand.rb', line 316 def test_pick_key assert true, picker(ha, ha.keys, :pick_key) end |
#test_pick_key! ⇒ Object
320 321 322 323 |
# File 'lib/rand.rb', line 320 def test_pick_key! h = ha assert true, picker(h, ha.keys, :pick_key!) and h.empty? end |
#test_pick_value ⇒ Object
325 326 327 |
# File 'lib/rand.rb', line 325 def test_pick_value assert true, picker(ha, ha.values, :pick_value) end |
#test_pick_value! ⇒ Object
329 330 331 332 |
# File 'lib/rand.rb', line 329 def test_pick_value! h = ha assert true, picker(h, ha.values, :pick_value!) and h.empty? end |
#test_shuffle ⇒ Object
347 348 349 350 351 |
# File 'lib/rand.rb', line 347 def test_shuffle h = ha hs = try_shuffling(ha, h, :shuffle) assert true, hs != h and hs.entries.sort == h.entries.sort end |
#test_shuffle_hash ⇒ Object
334 335 336 337 338 |
# File 'lib/rand.rb', line 334 def test_shuffle_hash h = ha hs = try_shuffling(ha, h, :shuffle_hash) assert true, hs != h and (hs.keys + hs.values).sort == (h.keys + h.values).sort end |
#test_shuffle_hash! ⇒ Object
340 341 342 343 344 345 |
# File 'lib/rand.rb', line 340 def test_shuffle_hash! h = ha hs = ha try_shuffling(hs, h, :shuffle_hash!) assert true, hs != h and (hs.keys + hs.values).sort == (h.keys + h.values).sort end |