diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-09 11:59:28 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-09 11:59:28 +0900 |
| commit | a9488618ced0001f4f76480f3668ac00c996d446 (patch) | |
| tree | 9aec19f51070b88dc30542beee972d86be8d2046 /mrbgems/mruby-hash-ext/test/hash.rb | |
| parent | 0b23d10a965fba7a58404a43c6369e2361388881 (diff) | |
| parent | dc4c042df5466287764bf46377ca9baa6690f198 (diff) | |
| download | mruby-a9488618ced0001f4f76480f3668ac00c996d446.tar.gz mruby-a9488618ced0001f4f76480f3668ac00c996d446.zip | |
Merge pull request #2213 from suzukaze/add-hash.key
Add Hash#key
Diffstat (limited to 'mrbgems/mruby-hash-ext/test/hash.rb')
| -rw-r--r-- | mrbgems/mruby-hash-ext/test/hash.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb index 1334522ff..b9992fa96 100644 --- a/mrbgems/mruby-hash-ext/test/hash.rb +++ b/mrbgems/mruby-hash-ext/test/hash.rb @@ -102,3 +102,12 @@ assert("Hash#keep_if") do h = { 1 => 2, 3 => 4, 5 => 6 } assert_equal({ 1 => 2, 3=> 4, 5 =>6} , h.keep_if { true }) end + +assert("Hash#key") do + h = { "a" => 100, "b" => 200, "c" => 300, "d" => 300, nil => 'nil', 'nil' => nil } + assert_equal "b", h.key(200) + assert_equal "c", h.key(300) + assert_nil h.key(999) + assert_nil h.key('nil') + assert_equal 'nil', h.key(nil) +end |
