mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Use Helpers::BaseHelpers.<foo>? MOAR
This commit is contained in:
parent
a01d1de27d
commit
30e1e0941e
8 changed files with 9 additions and 19 deletions
|
@ -215,12 +215,12 @@ class Pry
|
||||||
config.exception_whitelist = DEFAULT_EXCEPTION_WHITELIST
|
config.exception_whitelist = DEFAULT_EXCEPTION_WHITELIST
|
||||||
config.hooks = DEFAULT_HOOKS
|
config.hooks = DEFAULT_HOOKS
|
||||||
config.input_stack = []
|
config.input_stack = []
|
||||||
config.color = Pry::Helpers::BaseHelpers.use_ansi_codes?
|
config.color = Helpers::BaseHelpers.use_ansi_codes?
|
||||||
config.pager = true
|
config.pager = true
|
||||||
config.system = DEFAULT_SYSTEM
|
config.system = DEFAULT_SYSTEM
|
||||||
config.editor = default_editor_for_platform
|
config.editor = default_editor_for_platform
|
||||||
config.should_load_rc = true
|
config.should_load_rc = true
|
||||||
config.should_trap_interrupts = defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
config.should_trap_interrupts = Helpers::BaseHelpers.jruby?
|
||||||
config.disable_auto_reload = false
|
config.disable_auto_reload = false
|
||||||
config.command_prefix = ""
|
config.command_prefix = ""
|
||||||
config.auto_indent = true
|
config.auto_indent = true
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Pry
|
||||||
def singleton_instance
|
def singleton_instance
|
||||||
raise ArgumentError, "tried to get instance of non singleton class" unless singleton_class?
|
raise ArgumentError, "tried to get instance of non singleton class" unless singleton_class?
|
||||||
|
|
||||||
if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
if Helpers::BaseHelpers.jruby?
|
||||||
wrapped.to_java.attached
|
wrapped.to_java.attached
|
||||||
else
|
else
|
||||||
@singleton_instance ||= ObjectSpace.each_object(wrapped).detect{ |x| (class << x; self; end) == wrapped }
|
@singleton_instance ||= ObjectSpace.each_object(wrapped).detect{ |x| (class << x; self; end) == wrapped }
|
||||||
|
|
|
@ -49,16 +49,6 @@ class MockPryException
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# are we on Jruby platform?
|
|
||||||
def jruby?
|
|
||||||
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
|
||||||
end
|
|
||||||
|
|
||||||
# are we on rbx platform?
|
|
||||||
def rbx?
|
|
||||||
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
|
|
||||||
end
|
|
||||||
|
|
||||||
Pry.reset_defaults
|
Pry.reset_defaults
|
||||||
|
|
||||||
# this is to test exception code (cat --ex)
|
# this is to test exception code (cat --ex)
|
||||||
|
@ -183,7 +173,7 @@ end
|
||||||
|
|
||||||
# to help with tracking down bugs that cause an infinite loop in the test suite
|
# to help with tracking down bugs that cause an infinite loop in the test suite
|
||||||
if ENV["SET_TRACE_FUNC"]
|
if ENV["SET_TRACE_FUNC"]
|
||||||
require 'set_trace' if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/ # gem install 'rbx-tracer'
|
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
|
||||||
set_trace_func proc { |event, file, line, id, binding, classname|
|
set_trace_func proc { |event, file, line, id, binding, classname|
|
||||||
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe Pry::InputCompleter do
|
||||||
end
|
end
|
||||||
|
|
||||||
# another jruby hack :((
|
# another jruby hack :((
|
||||||
if !jruby?
|
if !Pry::Helpers::BaseHelpers.jruby?
|
||||||
it "should not crash if there's a Module that has a symbolic name." do
|
it "should not crash if there's a Module that has a symbolic name." do
|
||||||
completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
|
completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
|
||||||
lambda{ completer.call "a.to_s." }.should.not.raise Exception
|
lambda{ completer.call "a.to_s." }.should.not.raise Exception
|
||||||
|
|
|
@ -92,7 +92,7 @@ describe "ls" do
|
||||||
describe "when no arguments given" do
|
describe "when no arguments given" do
|
||||||
describe "when at the top-level" do
|
describe "when at the top-level" do
|
||||||
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
|
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
|
||||||
unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
|
unless Pry::Helpers::BaseHelpers.rbx?
|
||||||
it "should show local variables" do
|
it "should show local variables" do
|
||||||
mock_pry("ls").should =~ /_pry_/
|
mock_pry("ls").should =~ /_pry_/
|
||||||
mock_pry("arbitrar = 1", "ls").should =~ /arbitrar/
|
mock_pry("arbitrar = 1", "ls").should =~ /arbitrar/
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
# this doesnt work so well on rbx due to differences in backtrace
|
# this doesnt work so well on rbx due to differences in backtrace
|
||||||
# so we currently skip rbx until we figure out a workaround
|
# so we currently skip rbx until we figure out a workaround
|
||||||
describe "with --ex" do
|
describe "with --ex" do
|
||||||
if !rbx?
|
if !Pry::Helpers::BaseHelpers.rbx?
|
||||||
it 'cat --ex should correctly display code that generated exception even if raised in repl' do
|
it 'cat --ex should correctly display code that generated exception even if raised in repl' do
|
||||||
mock_pry("this raises error", "cat --ex").should =~ /\d+:(\s*) this raises error/
|
mock_pry("this raises error", "cat --ex").should =~ /\d+:(\s*) this raises error/
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,7 +98,7 @@ describe Pry::Method do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
|
# Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
|
||||||
unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
|
unless Pry::Helpers::BaseHelpers.rbx?
|
||||||
it 'should find the super method correctly' do
|
it 'should find the super method correctly' do
|
||||||
a = Class.new{ def gag; binding; end; def self.line; __LINE__; end }
|
a = Class.new{ def gag; binding; end; def self.line; __LINE__; end }
|
||||||
b = Class.new(a){ def gag; super; end }
|
b = Class.new(a){ def gag; super; end }
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe Pry do
|
||||||
["1 1"],
|
["1 1"],
|
||||||
["puts :"],
|
["puts :"],
|
||||||
# in this case the syntax error is "expecting ')'".
|
# in this case the syntax error is "expecting ')'".
|
||||||
((defined? RUBY_ENGINE && RUBY_ENGINE == "rbx") ? nil : ["def", "method(1"])
|
(Pry::Helpers::BaseHelpers.rbx? ? nil : ["def", "method(1"])
|
||||||
].compact.each do |foo|
|
].compact.each do |foo|
|
||||||
it "should raise an error on invalid syntax like #{foo.inspect}" do
|
it "should raise an error on invalid syntax like #{foo.inspect}" do
|
||||||
output = StringIO.new
|
output = StringIO.new
|
||||||
|
|
Loading…
Reference in a new issue