summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/test.rb')
-rw-r--r--sample/test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 69a168f2c40..98c913667a3 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -277,11 +277,20 @@ ok($x[0] == -1 && $x[1] == 10)
$x[-1, 1] = 20
ok($x[-1] == 20 && $x.pop == 20)
+# array and/or
+ok(([1,2,3]&[2,4,6]) == [2])
+ok(([1,2,3]|[2,4,6]) == [1,2,3,4,6])
+
# compact
$x = [nil, 1, nil, nil, 5, nil, nil]
$x.compact!
ok($x == [1, 5])
+# uniq
+$x = [1, 1, 4, 2, 5, 4, 5, 1, 2]
+$x.uniq!
+ok($x == [1, 4, 2, 5])
+
# empty?
ok(!$x.empty?)
$x = []