aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/kernel
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-09-30 12:21:48 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-09-30 12:21:48 +0200
commit201d50164016bc519041af302f47d92f314abac5 (patch)
tree688544ac063d8a3825d96474055f5c11ad471972 /spec/ruby/core/kernel
parentce986b41caa1f23b6d07914b8eca62fdff24e034 (diff)
downloadruby-201d50164016bc519041af302f47d92f314abac5.tar.gz
Update to ruby/spec@9277d27
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r--spec/ruby/core/kernel/freeze_spec.rb8
-rw-r--r--spec/ruby/core/kernel/instance_variables_spec.rb4
-rw-r--r--spec/ruby/core/kernel/shared/require.rb15
3 files changed, 26 insertions, 1 deletions
diff --git a/spec/ruby/core/kernel/freeze_spec.rb b/spec/ruby/core/kernel/freeze_spec.rb
index e4a01b5df5..fa32d321cf 100644
--- a/spec/ruby/core/kernel/freeze_spec.rb
+++ b/spec/ruby/core/kernel/freeze_spec.rb
@@ -80,4 +80,12 @@ describe "Kernel#freeze" do
o.freeze
-> {o.instance_variable_set(:@foo, 1)}.should raise_error(RuntimeError)
end
+
+ it "freezes an object's singleton class" do
+ o = Object.new
+ c = o.singleton_class
+ c.frozen?.should == false
+ o.freeze
+ c.frozen?.should == true
+ end
end
diff --git a/spec/ruby/core/kernel/instance_variables_spec.rb b/spec/ruby/core/kernel/instance_variables_spec.rb
index b6d6e27772..831f0662a2 100644
--- a/spec/ruby/core/kernel/instance_variables_spec.rb
+++ b/spec/ruby/core/kernel/instance_variables_spec.rb
@@ -4,7 +4,9 @@ require_relative 'fixtures/classes'
describe "Kernel#instance_variables" do
describe "immediate values" do
it "returns an empty array if no instance variables are defined" do
- 0.instance_variables.should == []
+ [0, 0.5, true, false, nil].each do |value|
+ value.instance_variables.should == []
+ end
end
it "returns the correct array if an instance variable is added" do
diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb
index 0e7f8ba665..6c6895e317 100644
--- a/spec/ruby/core/kernel/shared/require.rb
+++ b/spec/ruby/core/kernel/shared/require.rb
@@ -344,6 +344,21 @@ describe :kernel_require, shared: true do
loaded_feature = $LOADED_FEATURES.last
ScratchPad.recorded.should == [loaded_feature]
end
+
+ it "requires only once when a new matching file added to path" do
+ @object.require('load_fixture').should be_true
+ ScratchPad.recorded.should == [:loaded]
+
+ symlink_to_code_dir_two = tmp("codesymlinktwo")
+ File.symlink("#{CODE_LOADING_DIR}/b", symlink_to_code_dir_two)
+ begin
+ $LOAD_PATH.unshift(symlink_to_code_dir_two)
+
+ @object.require('load_fixture').should be_false
+ ensure
+ rm_r symlink_to_code_dir_two
+ end
+ end
end
describe "with symlinks in the required feature and $LOAD_PATH" do