File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ require_relative '../../spec_helper'
2
+
3
+ describe "Range#clone" do
4
+ it "duplicates the range" do
5
+ copy = ( 1 ..3 ) . clone
6
+ copy . begin . should == 1
7
+ copy . end . should == 3
8
+ copy . should_not . exclude_end?
9
+
10
+ copy = ( "a" ..."z" ) . clone
11
+ copy . begin . should == "a"
12
+ copy . end . should == "z"
13
+ copy . should . exclude_end?
14
+ end
15
+
16
+ it "maintains the frozen state" do
17
+ ( 1 ..2 ) . clone . frozen? . should == ( 1 ..2 ) . frozen?
18
+ ( 1 ..) . clone . frozen? . should == ( 1 ..) . frozen?
19
+ Range . new ( 1 , 2 ) . clone . frozen? . should == Range . new ( 1 , 2 ) . frozen?
20
+ Class . new ( Range ) . new ( 1 , 2 ) . clone . frozen? . should == Class . new ( Range ) . new ( 1 , 2 ) . frozen?
21
+ end
22
+ end
Original file line number Diff line number Diff line change 65
65
66
66
range_exclude . should_not == range_include
67
67
end
68
+
69
+ ruby_version_is "3.0" do
70
+ it "creates a frozen range if the class is Range.class" do
71
+ Range . new ( 1 , 2 ) . should . frozen?
72
+ end
73
+
74
+ it "does not create a frozen range if the class is not Range.class" do
75
+ Class . new ( Range ) . new ( 1 , 2 ) . should_not . frozen?
76
+ end
77
+ end
68
78
end
69
79
end
You can’t perform that action at this time.
0 commit comments