- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-1.3.0
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/test/hash.rb
r321 r331 38 38 Hash['d_key'] 39 39 end 40 end 41 42 assert('Hash.[] for sub class') do 43 sub_hash_class = Class.new(Hash) 44 sub_hash = sub_hash_class[] 45 assert_equal(sub_hash_class, sub_hash.class) 46 end 47 48 assert('Hash.try_convert') do 49 assert_nil Hash.try_convert(nil) 50 assert_nil Hash.try_convert("{1=>2}") 51 assert_equal({1=>2}, Hash.try_convert({1=>2})) 40 52 end 41 53 … … 138 150 end 139 151 152 assert("Hash#invert with sub class") do 153 sub_hash_class = Class.new(Hash) 154 sub_hash = sub_hash_class.new 155 assert_equal(sub_hash_class, sub_hash.invert.class) 156 end 157 140 158 assert("Hash#keep_if") do 141 159 h = { 1 => 2, 3 => 4, 5 => 6 } … … 231 249 assert_false(h2 > h2) 232 250 end 251 252 assert("Hash#dig") do 253 h = {a:{b:{c:1}}} 254 assert_equal(1, h.dig(:a, :b, :c)) 255 assert_nil(h.dig(:d)) 256 end
Note:
See TracChangeset
for help on using the changeset viewer.