From bdacdfaea9bf4b52770c32d60b7d402b48297c58 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 12 Oct 2019 12:39:29 +0900 Subject: Add `Array#intersection` which is new in Ruby2.7. --- mrbgems/mruby-array-ext/test/array.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mrbgems/mruby-array-ext/test/array.rb') diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb index 0cfb1e857..cb76559c7 100644 --- a/mrbgems/mruby-array-ext/test/array.rb +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -111,6 +111,14 @@ assert("Array#&") do assert_equal [1, 2, 3, 1], a end +assert("Array#intersection") do + a = [1, 2, 3, 1, 8, 6, 7, 8] + b = [1, 4, 6, 8] + c = [1, 5, 7, 8] + + assert_equal [1, 8], a.intersection(b,c) +end + assert("Array#flatten") do assert_equal [1, 2, "3", {4=>5}, :'6'], [1, 2, "3", {4=>5}, :'6'].flatten assert_equal [1, 2, 3, 4, 5, 6], [1, 2, [3, 4, 5], 6].flatten -- cgit v1.2.3