Sha256: c945d4b1a88446d9f05c9934e56cdd9289805b9aacd4c556a50a8f1eab3d431d
Contents?: true
Size: 890 Bytes
Versions: 33
Compression:
Stored size: 890 Bytes
Contents
require 'test_helper' require 'tins' module Tins class SubhashTest < Test::Unit::TestCase require 'tins/xt/subhash' def test_subhash h = { 'foo1' => 1, 'foo2' => 2, 'bar666' => 666 } assert_equal [ [ 'bar666', 666 ] ], h.subhash(/\Abar/).to_a assert h.subhash(/\Abaz/).empty? assert_equal [ [ 'foo1', 1 ], [ 'foo2', 2 ] ], h.subhash(/\Afoo\d/).sort assert_equal [ [ 'foo2', 2 ] ], h.subhash('foo2').to_a end def test_subhash_bang h = { 'foo1' => 1, 'foo2' => 2, 'bar666' => 666 } h.subhash!('foo2') assert_equal [ [ 'foo2', 2 ] ], h.to_a end def test_subhash_with_block h = { 'foo1' => 1, 'foo2' => 2, 'bar666' => 666 } assert h.subhash(/\Abaz/) { :foo }.empty? assert_equal [ [ 'foo1', 1 ], [ 'foo2', 2 ] ], h.subhash(/\Afoo(\d)/) { |_,_,m| Integer(m[1]) }.to_a.sort end end end
Version data entries
33 entries across 33 versions & 2 rubygems