diff options
| author | skandhas <[email protected]> | 2013-03-15 11:28:01 +0800 |
|---|---|---|
| committer | skandhas <[email protected]> | 2013-03-15 11:28:01 +0800 |
| commit | 6c284ec31f470681e333bac431d3a074fc1d27fd (patch) | |
| tree | 5fcbdcc74899499464eb0506c440c4c239496b4b /mrbgems/mruby-array-ext/test/array.rb | |
| parent | 75dd4a5aeda402e74ade4b3e74d2ca15eecec009 (diff) | |
| download | mruby-6c284ec31f470681e333bac431d3a074fc1d27fd.tar.gz mruby-6c284ec31f470681e333bac431d3a074fc1d27fd.zip | |
add mrbgem: mrb-array-ext
Diffstat (limited to 'mrbgems/mruby-array-ext/test/array.rb')
| -rw-r--r-- | mrbgems/mruby-array-ext/test/array.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb new file mode 100644 index 000000000..905606c9d --- /dev/null +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -0,0 +1,30 @@ +## +# Array(Ext) Test + +assert("Array::try_convert") do + Array.try_convert([1]) == [1] and + Array.try_convert("1").nil? +end + +assert("Array#assoc") do + s1 = [ "colors", "red", "blue", "green" ] + s2 = [ "letters", "a", "b", "c" ] + s3 = "foo" + a = [ s1, s2, s3 ] + + a.assoc("letters") == [ "letters", "a", "b", "c" ] and + a.assoc("foo").nil? +end + +assert("Array#at") do + a = [ "a", "b", "c", "d", "e" ] + a.at(0) == "a" and a.at(-1) == "e" +end + +assert("Array::rassoc") do + a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] + + a.rassoc("two") == [2, "two"] and + a.rassoc("four").nil? +end + |
