Skip to content

Commit 0601dec

Browse files
committed
Require the 'pp' gem by default, per MRI.
1 parent 9fea753 commit 0601dec

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

spec/ruby/core/kernel/pp_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require_relative '../../spec_helper'
2+
3+
describe "Kernel#pp" do
4+
it "lazily loads the 'pp' library and delegates the call to that library" do
5+
# Run in child process to ensure 'pp' hasn't been loaded yet.
6+
output = ruby_exe("pp [1, 2, 3]")
7+
output.should == "[1, 2, 3]\n"
8+
end
9+
end

src/main/ruby/core/kernel.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,11 @@ def printf(*args)
589589
end
590590
module_function :printf
591591

592+
private def pp(*args)
593+
require 'pp'
594+
pp(*args)
595+
end
596+
592597
alias_method :trust, :untaint
593598
alias_method :untrust, :taint
594599
alias_method :untrusted?, :tainted?

0 commit comments

Comments
 (0)