diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-27 14:25:00 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-27 14:25:00 +0000 |
commit | ce68c2bdf62a38521d63425c8826acfef39118d5 (patch) | |
tree | fb6b2270b710d2a8390a1cb0d0bb76b9cbc1c6ad /spec/ruby/core | |
parent | 365164dda13de1f6da3d7d2d398d78675e7330be (diff) | |
download | ruby-ce68c2bdf62a38521d63425c8826acfef39118d5.tar.gz |
Update to ruby/spec@09fa86c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/kernel/eval_spec.rb | 1 | ||||
-rw-r--r-- | spec/ruby/core/kernel/fixtures/singleton_methods.rb | 13 | ||||
-rw-r--r-- | spec/ruby/core/kernel/singleton_methods_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/core/module/refine_spec.rb | 24 | ||||
-rw-r--r-- | spec/ruby/core/signal/trap_spec.rb | 19 |
5 files changed, 70 insertions, 1 deletions
diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb index fbae8ff3c7..46158628a3 100644 --- a/spec/ruby/core/kernel/eval_spec.rb +++ b/spec/ruby/core/kernel/eval_spec.rb @@ -214,6 +214,7 @@ describe "Kernel#eval" do ruby_exe(code).chomp.should == "a,b,c,e,LocalJumpError,f" end + # See language/magic_comment_spec.rb for more magic comments specs describe "with a magic encoding comment" do it "uses the magic comment encoding for the encoding of literal strings" do code = "# encoding: UTF-8\n'é'.encoding".b diff --git a/spec/ruby/core/kernel/fixtures/singleton_methods.rb b/spec/ruby/core/kernel/fixtures/singleton_methods.rb new file mode 100644 index 0000000000..32ea0adf89 --- /dev/null +++ b/spec/ruby/core/kernel/fixtures/singleton_methods.rb @@ -0,0 +1,13 @@ +module SingletonMethodsSpecs + module Prepended + def mspec_test_kernel_singleton_methods + end + public :mspec_test_kernel_singleton_methods + end + + ::Module.prepend Prepended + + module SelfExtending + extend self + end +end diff --git a/spec/ruby/core/kernel/singleton_methods_spec.rb b/spec/ruby/core/kernel/singleton_methods_spec.rb index 74fd4a9608..eb4cede110 100644 --- a/spec/ruby/core/kernel/singleton_methods_spec.rb +++ b/spec/ruby/core/kernel/singleton_methods_spec.rb @@ -36,6 +36,19 @@ describe :kernel_singleton_methods_modules, shared: true do it "does not return any included methods for a class including a module" do ReflectSpecs::D.singleton_methods(*@object).should include(:ds_pro, :ds_pub) end + + it "for a module does not return methods in a module prepended to Module itself" do + require_relative 'fixtures/singleton_methods' + mod = SingletonMethodsSpecs::SelfExtending + mod.method(:mspec_test_kernel_singleton_methods).owner.should == SingletonMethodsSpecs::Prepended + + ancestors = mod.singleton_class.ancestors + ancestors[0...2].should == [ mod.singleton_class, mod ] + ancestors.should include(SingletonMethodsSpecs::Prepended) + + # Do not search prepended modules of `Module`, as that's a non-singleton class + mod.singleton_methods.should == [] + end end describe :kernel_singleton_methods_supers, shared: true do @@ -145,7 +158,6 @@ describe "Kernel#singleton_methods" do it_behaves_like :kernel_singleton_methods_supers, nil, true it_behaves_like :kernel_singleton_methods_modules, nil, true it_behaves_like :kernel_singleton_methods_private_supers, nil, true - end describe "when passed false" do diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index e36b17cf15..287aa601a9 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -594,6 +594,30 @@ describe "Module#refine" do end end + it 'and alias aliases a method within a refinement module, but not outside it' do + Module.new do + using Module.new { + refine Array do + alias :orig_count :count + end + } + [1,2].orig_count.should == 2 + end + lambda { [1,2].orig_count }.should raise_error(NoMethodError) + end + + it 'and alias_method aliases a method within a refinement module, but not outside it' do + Module.new do + using Module.new { + refine Array do + alias_method :orig_count, :count + end + } + [1,2].orig_count.should == 2 + end + lambda { [1,2].orig_count }.should raise_error(NoMethodError) + end + # Refinements are inherited by module inclusion. # That is, using activates all refinements in the ancestors of the specified module. # Refinements in a descendant have priority over refinements in an ancestor. diff --git a/spec/ruby/core/signal/trap_spec.rb b/spec/ruby/core/signal/trap_spec.rb index 867094d6dd..c11c900add 100644 --- a/spec/ruby/core/signal/trap_spec.rb +++ b/spec/ruby/core/signal/trap_spec.rb @@ -158,9 +158,28 @@ platform_is_not :windows do $?.exitstatus.should == 0 end + it "returns 'DEFAULT' for the initial SIGINT handler" do + ruby_exe('print trap(:INT) { abort }').should == 'DEFAULT' + end + it "returns SYSTEM_DEFAULT if passed DEFAULT and no handler was ever set" do Signal.trap("PROF", "DEFAULT").should == "SYSTEM_DEFAULT" end + + it "accepts 'SYSTEM_DEFAULT' and uses the OS handler for SIGPIPE" do + code = <<-RUBY + p Signal.trap('PIPE', 'SYSTEM_DEFAULT') + r, w = IO.pipe + r.close + loop { w.write("a"*1024) } + RUBY + out = ruby_exe(code) + status = $? + out.should == "nil\n" + status.signaled?.should == true + status.termsig.should be_kind_of(Integer) + Signal.signame(status.termsig).should == "PIPE" + end end end |