summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-array-ext/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-03-15 05:19:06 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2013-03-15 05:19:06 -0700
commitc5db1397ee4cfe664502eb206ad901945b4ddb20 (patch)
tree7c90620b9ea8210e99beb986f109f766dc2c12c8 /mrbgems/mruby-array-ext/test
parent75dd4a5aeda402e74ade4b3e74d2ca15eecec009 (diff)
parente6ab9237cc72469dfc6dd3279ce31be4495ac011 (diff)
downloadmruby-c5db1397ee4cfe664502eb206ad901945b4ddb20.tar.gz
mruby-c5db1397ee4cfe664502eb206ad901945b4ddb20.zip
Merge pull request #1009 from skandhas/pr-add-mrb-array-ext
add mrbgem: mruby-array-ext
Diffstat (limited to 'mrbgems/mruby-array-ext/test')
-rw-r--r--mrbgems/mruby-array-ext/test/array.rb30
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..36da6bb17
--- /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
+