summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/array_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/optional/capi/array_spec.rb')
-rw-r--r--spec/ruby/optional/capi/array_spec.rb86
1 files changed, 9 insertions, 77 deletions
diff --git a/spec/ruby/optional/capi/array_spec.rb b/spec/ruby/optional/capi/array_spec.rb
index 9c35017e21..2fd898ad94 100644
--- a/spec/ruby/optional/capi/array_spec.rb
+++ b/spec/ruby/optional/capi/array_spec.rb
@@ -1,4 +1,4 @@
-require_relative 'spec_helper'
+require File.expand_path('../spec_helper', __FILE__)
load_extension("array")
@@ -8,7 +8,7 @@ describe :rb_ary_new2, shared: true do
end
it "raises an ArgumentError when the given argument is negative" do
- -> { @s.send(@method, -1) }.should raise_error(ArgumentError)
+ lambda { @s.send(@method, -1) }.should raise_error(ArgumentError)
end
end
@@ -83,8 +83,8 @@ describe "C-API Array function" do
@s.rb_ary_cat([1, 2], 3, 4).should == [1, 2, 3, 4]
end
- it "raises a FrozenError if the array is frozen" do
- -> { @s.rb_ary_cat([].freeze, 1) }.should raise_error(FrozenError)
+ it "raises a RuntimeError if the array is frozen" do
+ lambda { @s.rb_ary_cat([].freeze, 1) }.should raise_error(RuntimeError)
end
end
@@ -130,8 +130,8 @@ describe "C-API Array function" do
@s.rb_ary_rotate([1, 2, 3, 4], -3).should == [2, 3, 4, 1]
end
- it "raises a FrozenError if the array is frozen" do
- -> { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(FrozenError)
+ it "raises a RuntimeError if the array is frozen" do
+ lambda { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(RuntimeError)
end
end
@@ -190,22 +190,6 @@ describe "C-API Array function" do
end
end
- describe "rb_ary_sort" do
- it "returns a new sorted array" do
- a = [2, 1, 3]
- @s.rb_ary_sort(a).should == [1, 2, 3]
- a.should == [2, 1, 3]
- end
- end
-
- describe "rb_ary_sort_bang" do
- it "sorts the given array" do
- a = [2, 1, 3]
- @s.rb_ary_sort_bang(a).should == [1, 2, 3]
- a.should == [1, 2, 3]
- end
- end
-
describe "rb_ary_store" do
it "overwrites the element at the given position" do
a = [1, 2, 3]
@@ -221,7 +205,7 @@ describe "C-API Array function" do
it "raises an IndexError if the negative index is greater than the length" do
a = [1, 2, 3]
- -> { @s.rb_ary_store(a, -10, 5) }.should raise_error(IndexError)
+ lambda { @s.rb_ary_store(a, -10, 5) }.should raise_error(IndexError)
end
it "enlarges the array as needed" do
@@ -230,9 +214,9 @@ describe "C-API Array function" do
a.should == [nil, nil, 7]
end
- it "raises a FrozenError if the array is frozen" do
+ it "raises a RuntimeError if the array is frozen" do
a = [1, 2, 3].freeze
- -> { @s.rb_ary_store(a, 1, 5) }.should raise_error(FrozenError)
+ lambda { @s.rb_ary_store(a, 1, 5) }.should raise_error(RuntimeError)
end
end
@@ -265,14 +249,6 @@ describe "C-API Array function" do
@s.RARRAY_PTR_assign(a, :set)
a.should == [:set, :set, :set]
end
-
- it "allows memcpying between arrays" do
- a = [1, 2, 3]
- b = [0, 0, 0]
- @s.RARRAY_PTR_memcpy(a, b)
- b.should == [1, 2, 3]
- a.should == [1, 2, 3] # check a was not modified
- end
end
describe "RARRAY_LEN" do
@@ -288,16 +264,6 @@ describe "C-API Array function" do
end
end
- describe "RARRAY_ASET" do
- # This macro does NOT do any bounds checking!
- it "writes an element in the array" do
- ary = [1, 2, 3]
- @s.RARRAY_ASET(ary, 0, 0)
- @s.RARRAY_ASET(ary, 2, 42)
- ary.should == [0, 2, 42]
- end
- end
-
describe "rb_assoc_new" do
it "returns an array containing the two elements" do
@s.rb_assoc_new(1, 2).should == [1, 2]
@@ -377,40 +343,6 @@ describe "C-API Array function" do
end
end
- describe "rb_block_call" do
- it "calls an callback function as a block passed to an method" do
- s = [1,2,3,4]
- s2 = @s.rb_block_call(s)
-
- s2.should == s
-
- # Make sure they're different objects
- s2.equal?(s).should be_false
- end
-
- it "calls a function with the other function available as a block" do
- h = {a: 1, b: 2}
-
- @s.rb_block_call_each_pair(h).sort.should == [1,2]
- end
-
- it "calls a function which can yield into the original block" do
- s2 = []
-
- o = Object.new
- def o.each
- yield 1
- yield 2
- yield 3
- yield 4
- end
-
- @s.rb_block_call_then_yield(o) { |x| s2 << x }
-
- s2.should == [1,2,3,4]
- end
- end
-
describe "rb_ary_delete" do
it "removes an element from an array and returns it" do
ary = [1, 2, 3, 4]