2014-03-14 00:31:24 -04:00
|
|
|
require_relative 'helper'
|
2012-12-15 17:09:16 -05:00
|
|
|
|
2012-12-24 01:06:06 -05:00
|
|
|
describe "The whole thing" do
|
2012-12-15 17:09:16 -05:00
|
|
|
it "should let you run commands in the middle of multiline expressions" do
|
2012-12-24 01:06:06 -05:00
|
|
|
ReplTester.start do
|
|
|
|
input 'def a'
|
|
|
|
input '!'
|
|
|
|
output /^Input buffer cleared/
|
|
|
|
|
|
|
|
input '5'
|
|
|
|
output '=> 5'
|
|
|
|
end
|
2012-12-15 17:09:16 -05:00
|
|
|
end
|
2012-12-23 03:03:29 -05:00
|
|
|
|
2013-03-26 09:23:13 -04:00
|
|
|
it "should rescue exceptions" do
|
|
|
|
ReplTester.start do
|
|
|
|
input 'raise "lorum"'
|
|
|
|
output /^RuntimeError: lorum/
|
|
|
|
|
2013-11-23 21:11:29 -05:00
|
|
|
if defined?(java)
|
|
|
|
input 'raise java.lang.Exception.new("foo")'
|
|
|
|
output /Exception: foo/
|
2013-03-26 09:23:13 -04:00
|
|
|
|
2013-11-23 21:11:29 -05:00
|
|
|
input 'raise java.io.IOException.new("bar")'
|
|
|
|
output /IOException: bar/
|
|
|
|
end
|
2013-03-26 09:23:13 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-23 15:25:48 -05:00
|
|
|
describe "eval_string and binding_stack" do
|
2012-12-23 22:58:18 -05:00
|
|
|
it "shouldn't break if we start a nested REPL" do
|
2012-12-23 15:25:48 -05:00
|
|
|
ReplTester.start do
|
|
|
|
input 'Pry::REPL.new(_pry_, :target => 10).start'
|
|
|
|
output ''
|
|
|
|
prompt /10.*> $/
|
2012-12-23 03:03:29 -05:00
|
|
|
|
2012-12-23 15:25:48 -05:00
|
|
|
input 'self'
|
|
|
|
output '=> 10'
|
2012-12-23 03:03:29 -05:00
|
|
|
|
2012-12-23 15:25:48 -05:00
|
|
|
input nil # Ctrl-D
|
|
|
|
output ''
|
2012-12-23 03:03:29 -05:00
|
|
|
|
2012-12-23 15:25:48 -05:00
|
|
|
input 'self'
|
|
|
|
output '=> main'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-23 22:58:18 -05:00
|
|
|
it "shouldn't break if we start a nested instance" do
|
|
|
|
ReplTester.start do
|
2014-01-29 08:56:54 -05:00
|
|
|
input 'Pry.start(10, _pry_.config)'
|
2012-12-23 22:58:18 -05:00
|
|
|
output ''
|
|
|
|
prompt /10.*> $/
|
|
|
|
|
|
|
|
input 'self'
|
|
|
|
output '=> 10'
|
|
|
|
|
|
|
|
input nil # Ctrl-D
|
|
|
|
output '=> nil' # return value of Pry session
|
|
|
|
|
|
|
|
input 'self'
|
|
|
|
output '=> main'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-23 15:25:48 -05:00
|
|
|
it "shouldn't break if we pop bindings in Ruby" do
|
|
|
|
ReplTester.start do
|
|
|
|
input 'cd 10'
|
|
|
|
output ''
|
|
|
|
prompt /10.*> $/
|
|
|
|
|
|
|
|
input '_pry_.binding_stack.pop'
|
|
|
|
output /^=> #<Binding/
|
|
|
|
prompt /main.*> $/
|
|
|
|
|
|
|
|
input '_pry_.binding_stack.pop'
|
|
|
|
output /^=> #<Binding/
|
|
|
|
assert_exited
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-23 18:21:58 -05:00
|
|
|
it "should immediately evaluate eval_string after cmd if complete" do
|
|
|
|
set = Pry::CommandSet.new do
|
|
|
|
import Pry::Commands
|
|
|
|
|
|
|
|
command 'hello!' do
|
|
|
|
eval_string.replace('"hello"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ReplTester.start(:commands => set) do
|
|
|
|
input 'def x'
|
|
|
|
output ''
|
2012-12-23 22:58:18 -05:00
|
|
|
prompt /\* $/
|
2012-12-23 18:21:58 -05:00
|
|
|
|
|
|
|
input 'hello!'
|
|
|
|
output '=> "hello"'
|
|
|
|
prompt /> $/
|
2012-12-23 15:25:48 -05:00
|
|
|
end
|
2012-12-23 03:03:29 -05:00
|
|
|
end
|
|
|
|
end
|
2013-03-26 09:23:13 -04:00
|
|
|
|
2012-12-15 17:09:16 -05:00
|
|
|
end
|