[macruby-changes] [4746] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 04:08:57 PDT 2010
Revision: 4746
http://trac.macosforge.org/projects/ruby/changeset/4746
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 04:08:56 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Instead of using globals for storing the last exception, use the local vars: e & exception
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/lib/irb/context.rb
DietRB/trunk/spec/context_spec.rb
Modified: DietRB/trunk/lib/irb/context.rb
===================================================================
--- DietRB/trunk/lib/irb/context.rb 2010-10-08 11:08:47 UTC (rev 4745)
+++ DietRB/trunk/lib/irb/context.rb 2010-10-08 11:08:56 UTC (rev 4746)
@@ -19,7 +19,8 @@
@line = 1
clear_buffer
- @underscore_assigner = __evaluate__("_ = nil; proc { |val| _ = val }")
+ @last_result_assigner = __evaluate__("_ = nil; proc { |val| _ = val }")
+ @exception_assigner = __evaluate__("e = exception = nil; proc { |ex| e = exception = ex }")
end
def __evaluate__(source, file = __FILE__, line = __LINE__)
@@ -84,11 +85,11 @@
end
def store_result(result)
- @underscore_assigner.call(result)
+ @last_result_assigner.call(result)
end
def store_exception(exception)
- $e = $EXCEPTION = exception
+ @exception_assigner.call(exception)
end
end
end
\ No newline at end of file
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 11:08:47 UTC (rev 4745)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 11:08:56 UTC (rev 4746)
@@ -75,11 +75,11 @@
}.should_not.raise_error
end
- it "assigns the last raised exception to the global variable `$EXCEPTION' / `$e'" do
+ it "assigns the last raised exception to the variables `exception' / `e'" do
@context.evaluate("DoesNotExist")
- $EXCEPTION.class.should == NameError
- $EXCEPTION.message.should include('DoesNotExist')
- $e.should == $EXCEPTION
+ @context.__evaluate__("exception").class.should == NameError
+ @context.__evaluate__("exception").message.should include('DoesNotExist')
+ @context.__evaluate__("e").should == @context.__evaluate__("exception")
end
it "prints the exception that occurs" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/533c555a/attachment.html>
More information about the macruby-changes
mailing list