File tree Expand file tree Collapse file tree 4 files changed +17
-2
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 116
116
-> { ArraySpecs . empty_frozen_array . reject! { } } . should raise_error ( FrozenError )
117
117
end
118
118
119
+ it "raises a FrozenError on a frozen array only during iteration if called without a block" do
120
+ enum = ArraySpecs . frozen_array . reject!
121
+ -> { enum . each { } } . should raise_error ( FrozenError )
122
+ end
123
+
119
124
it "does not truncate the array is the block raises an exception" do
120
125
a = [ 1 , 2 , 3 ]
121
126
begin
Original file line number Diff line number Diff line change 57
57
-> { @frozen . send ( @method ) { false } } . should raise_error ( FrozenError )
58
58
end
59
59
end
60
+
61
+ it "raises a FrozenError on a frozen array only during iteration if called without a block" do
62
+ enum = @frozen . send ( @method )
63
+ -> { enum . each { } } . should raise_error ( FrozenError )
64
+ end
60
65
end
61
66
62
67
it "does not truncate the array is the block raises an exception" do
Original file line number Diff line number Diff line change 32
32
-> { ArraySpecs . empty_frozen_array . sort_by! { } } . should raise_error ( FrozenError )
33
33
end
34
34
35
+ it "raises a FrozenError on a frozen array only during iteration if called without a block" do
36
+ enum = ArraySpecs . frozen_array . sort_by!
37
+ -> { enum . each { } } . should raise_error ( FrozenError )
38
+ end
39
+
35
40
it "returns the specified value when it would break in the given block" do
36
41
[ 1 , 2 , 3 ] . sort_by! { break :a } . should == :a
37
42
end
Original file line number Diff line number Diff line change @@ -1259,10 +1259,10 @@ def drop(n)
1259
1259
end
1260
1260
1261
1261
def sort_by! ( &block )
1262
- Primitive . check_frozen self
1263
-
1264
1262
return to_enum ( :sort_by! ) { size } unless block_given?
1265
1263
1264
+ Primitive . check_frozen self
1265
+
1266
1266
Primitive . steal_array_storage ( self , sort_by ( &block ) )
1267
1267
end
1268
1268
You can’t perform that action at this time.
0 commit comments