1
0
Fork 0
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:
Conrad Irwin 2014-02-04 10:55:06 -08:00
parent 263ab5bc06
commit a8156cbdc8
2 changed files with 17 additions and 0 deletions

View file

@ -11,6 +11,10 @@ class Pry
def eval!
@previous_value = value
@value = target_eval(target, source)
begin
@value = @value.dup
rescue Pry::RescuableException
end
end
def to_s

View file

@ -51,6 +51,19 @@ describe "watch expression" do
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
ReplTester.start do
input 'a = 1'