test/01get.rb in xkeys-0.0.2 vs test/01get.rb in xkeys-1.0.1

- old
+ new

@@ -22,38 +22,45 @@ assert_equal({ :c => 'bc' }, h[:b], 'h[:b]') assert_equal('bc', h[:b, :c], 'h[:b, :c]') assert_equal(false, h[:b, :d, :else=>false], 'h[:b, :d, :else=>false]') assert_equal(nil, h[:b, :d], 'h[:b, :d]') - assert_raises(KeyError, 'h[:b, :d, {}]') { h[:b, :d, {}] } + assert_raises(KeyError, 'h[:b, :d, {:raise=>true}]') do + h[:b, :d, {:raise=>true}] + end + assert_raises(RuntimeError, 'h[:b, :d, {:raise=>RuntimeError}]') do + h[:b, :d, {:raise=>RuntimeError}] + end + assert_raises(RuntimeError, 'h[:b, :d, {:raise=>[RuntimeError]}]') do + h[:b, :d, {:raise=>[RuntimeError]}] + end end def test_array_get a = [ '0', [ '1.0' ], [ '2.0', [ '2.1.0', '2.1.1' ]]].extend XKeys::Get assert_respond_to(a, :xfetch) assert_respond_to(a, :[]) assert_equal('0', a.xfetch(0), 'a.xfetch 0') assert_equal('1.0', a.xfetch(1, 0), 'a.xfetch 1, 0') - assert_equal('1.0', a.xfetch(nil, 1, 0), 'a.xfetch nil, 1, 0') assert_equal('1.0', a.xfetch(1, 0, {}), 'a.xfetch 1, 0, {}') assert_equal('2.1.1', a.xfetch(2, 1, 1), 'a.xfetch 2, 1, 1') assert_equal(false, a.xfetch(1, 1, :else => false), 'a.xfetch 1, 1, :else => false') assert_raises(IndexError, 'a.xfetch 1, 1') { a.xfetch 1, 1 } assert_equal('0', a[0], 'a[0]') assert_equal([['1.0']], a[1, 1], 'a[1, 1]') - assert_equal('1.0', a[nil, 1, 0], 'a[nil, 1, 0]') assert_equal('1.0', a[1, 0, {}], 'a[1, 0, {}]') - assert_equal('1.0', a[nil, 1, 0, {}], 'a[nil, 1, 0, {}]') assert_equal('2.1.1', a[2, 1, 1], 'a[2, 1, 1]') assert_equal(false, a[1, 1, :else=>false], 'a[1, 1, :else=>false]') - assert_equal(nil, a[nil, 1, 1], 'a[nil, 1, 1]') - assert_raises(IndexError, 'a[1, 1, {}]') { a[1, 1, {}] } + assert_equal(nil, a[1, 1, {}], 'a[1, 1, {}]') + assert_raises(IndexError, 'a[1, 1, {:raise=>true}]') do + a[1, 1, {:raise=>true}] + end end end # END