summaryrefslogtreecommitdiff
path: root/spec/ruby/core/range/frozen_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2022-01-28 14:42:38 +0100
committerBenoit Daloze <eregontp@gmail.com>2022-01-28 14:42:38 +0100
commite0c5488ff9308b1a16718c64bc9096caca88ed83 (patch)
treeb0ede98f96c4477c470bef45547abff525215b21 /spec/ruby/core/range/frozen_spec.rb
parentbb5f71088774b14c96fe11718e5e1b7ffb20fff2 (diff)
Update to ruby/spec@902ab83
Diffstat (limited to 'spec/ruby/core/range/frozen_spec.rb')
-rw-r--r--spec/ruby/core/range/frozen_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/ruby/core/range/frozen_spec.rb b/spec/ruby/core/range/frozen_spec.rb
new file mode 100644
index 0000000000..9a3e6eb373
--- /dev/null
+++ b/spec/ruby/core/range/frozen_spec.rb
@@ -0,0 +1,27 @@
+require_relative '../../spec_helper'
+
+# There is no Range#frozen? method but this feels like the best place for these specs
+describe "Range#frozen?" do
+ ruby_version_is "3.0" do
+ it "is true for literal ranges" do
+ (1..2).should.frozen?
+ (1..).should.frozen?
+ eval("(..1)").should.frozen?
+ end
+
+ it "is true for Range.new" do
+ Range.new(1, 2).should.frozen?
+ Range.new(1, nil).should.frozen?
+ Range.new(nil, 1).should.frozen?
+ end
+
+ it "is false for instances of a subclass of Range" do
+ sub_range = Class.new(Range).new(1, 2)
+ sub_range.should_not.frozen?
+ end
+
+ it "is false for Range.allocate" do
+ Range.allocate.should_not.frozen?
+ end
+ end
+end