From 921e6e24f4e87cf75827b6deba18fc7bbea48d5c Mon Sep 17 00:00:00 2001 From: Paolo Bosetti Date: Fri, 10 Jan 2014 11:13:47 +0100 Subject: Added rewrite of Array#[] to mruby-array-ext gem, so that arrays can be sliced with Ranges (as a[1..-2]) --- mrbgems/mruby-array-ext/test/array.rb | 7 +++++++ 1 file changed, 7 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 1c441cec4..8a6f50fe4 100644 --- a/mrbgems/mruby-array-ext/test/array.rb +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -107,3 +107,10 @@ assert("Array#compact!") do a.compact! a == [1, "2", :t, false] end + +assert("Array#[]") do + a = [ "a", "b", "c", "d", "e" ] + a[1.1] == "b" and + a[1,2] == ["b", "c"] and + a[1..-2] == ["b", "c", "d"] +end -- cgit v1.2.3