diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-09-29 18:01:32 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-09-29 18:01:32 +0200 |
commit | a17bc04d159ec9839cc8cfb02dc0cdd2802110f4 (patch) | |
tree | a10d4121aeb1517c198ab5b1577bca93912dc1f9 /spec/ruby/core/kernel | |
parent | f9a9f3c7c6cf3fe534d4934dd3b502d721151b81 (diff) | |
download | ruby-a17bc04d159ec9839cc8cfb02dc0cdd2802110f4.tar.gz |
Update to ruby/spec@e69a14c
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r-- | spec/ruby/core/kernel/warn_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/ruby/core/kernel/warn_spec.rb b/spec/ruby/core/kernel/warn_spec.rb index d05a37958d..2a404a2a35 100644 --- a/spec/ruby/core/kernel/warn_spec.rb +++ b/spec/ruby/core/kernel/warn_spec.rb @@ -101,6 +101,16 @@ describe "Kernel#warn" do -> { w.f4("foo", 3) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f3_call_lineno}: warning: foo|) end + it "converts first arg using to_s" do + w = KernelSpecs::WarnInNestedCall.new + + -> { w.f4(false, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: false|) + -> { w.f4(nil, 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: |) + obj = mock("obj") + obj.should_receive(:to_s).and_return("to_s called") + -> { w.f4(obj, 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: to_s called|) + end + it "does not prepend caller information if line number is too big" do w = KernelSpecs::WarnInNestedCall.new -> { w.f4("foo", 100) }.should output(nil, "warning: foo\n") @@ -136,5 +146,11 @@ describe "Kernel#warn" do -> { warn "", uplevel: Object.new }.should raise_error(TypeError) end end + + it "treats empty hash as no keyword argument" do + h = {} + -> { warn(**h) }.should_not complain(verbose: true) + -> { warn('foo', **h) }.should complain("foo\n") + end end end |