ruby-changes:21328
From: ayumin <ko1@a...>
Date: Sun, 2 Oct 2011 12:18:50 +0900 (JST)
Subject: [ruby-changes:21328] ayumin:r33377 (trunk): * test/psych/test_yamldbm.rb: add test case.
ayumin 2011-10-02 12:18:39 +0900 (Sun, 02 Oct 2011) New Revision: 33377 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33377 Log: * test/psych/test_yamldbm.rb: add test case. * test/syck/test_yamldbm.rb: ditto. Modified files: trunk/ChangeLog trunk/test/psych/test_yamldbm.rb trunk/test/syck/test_yamldbm.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 33376) +++ ChangeLog (revision 33377) @@ -1,3 +1,8 @@ +Sun Oct 02 12:14:06 2011 Ayumu AIZAWA <ayumu.aizawa@g...> + + * test/psych/test_yamldbm.rb: add test case. + * test/syck/test_yamldbm.rb: ditto. + Sun Oct 2 11:28:09 2011 Aaron Patterson <aaron@t...> * lib/yaml/store.rb: make initialize method signature match the Index: test/psych/test_yamldbm.rb =================================================================== --- test/psych/test_yamldbm.rb (revision 33376) +++ test/psych/test_yamldbm.rb (revision 33377) @@ -157,5 +157,34 @@ assert_equal({'a'=>'b','e'=>'f'}, @yamldbm.reject {|k,v| v == 'd'}) assert_equal({'a'=>'b','c'=>'d','e'=>'f'}, @yamldbm.reject {false}) end + + def test_values + assert_equal [], @yamldbm.values + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + assert_equal ['b','d'], @yamldbm.values + end + + def test_values_at + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + assert_equal ['b','d'], @yamldbm.values_at('a','c') + end + + def test_selsct + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + @yamldbm['e'] = 'f' + assert_equal(['b','d'], @yamldbm.select('a','c')) + end + + def test_selsct_with_block + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + @yamldbm['e'] = 'f' + assert_equal([['a','b']], @yamldbm.select {|k,v| k == 'a'}) + assert_equal([['c','d']], @yamldbm.select {|k,v| v == 'd'}) + assert_equal([], @yamldbm.select {false}) + end end end Index: test/syck/test_yamldbm.rb =================================================================== --- test/syck/test_yamldbm.rb (revision 33376) +++ test/syck/test_yamldbm.rb (revision 33377) @@ -157,5 +157,34 @@ assert_equal({'a'=>'b','e'=>'f'}, @yamldbm.reject {|k,v| v == 'd'}) assert_equal({'a'=>'b','c'=>'d','e'=>'f'}, @yamldbm.reject {false}) end + + def test_values + assert_equal [], @yamldbm.values + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + assert_equal ['b','d'], @yamldbm.values + end + + def test_values_at + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + assert_equal ['b','d'], @yamldbm.values_at('a','c') + end + + def test_selsct + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + @yamldbm['e'] = 'f' + assert_equal(['b','d'], @yamldbm.select('a','c')) + end + + def test_selsct_with_block + @yamldbm['a'] = 'b' + @yamldbm['c'] = 'd' + @yamldbm['e'] = 'f' + assert_equal([['a','b']], @yamldbm.select {|k,v| k == 'a'}) + assert_equal([['c','d']], @yamldbm.select {|k,v| v == 'd'}) + assert_equal([], @yamldbm.select {false}) + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/