mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
.dup watched expressions
This commit is contained in:
parent
263ab5bc06
commit
a8156cbdc8
2 changed files with 17 additions and 0 deletions
|
@ -11,6 +11,10 @@ class Pry
|
||||||
def eval!
|
def eval!
|
||||||
@previous_value = value
|
@previous_value = value
|
||||||
@value = target_eval(target, source)
|
@value = target_eval(target, source)
|
||||||
|
begin
|
||||||
|
@value = @value.dup
|
||||||
|
rescue Pry::RescuableException
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -51,6 +51,19 @@ describe "watch expression" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "prints when an expression is mutated" do
|
||||||
|
ReplTester.start do
|
||||||
|
input 'a = "one"'
|
||||||
|
output '=> "one"'
|
||||||
|
|
||||||
|
input 'watch a'
|
||||||
|
output %(Watching a\nwatch: a => "one")
|
||||||
|
|
||||||
|
input "a.sub! 'o', 'p'"
|
||||||
|
output %(watch: a => "pne"\n=> "pne")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't print when an expresison remains the same" do
|
it "doesn't print when an expresison remains the same" do
|
||||||
ReplTester.start do
|
ReplTester.start do
|
||||||
input 'a = 1'
|
input 'a = 1'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue