[macruby-changes] [4606] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 03:47:40 PDT 2010
Revision: 4606
http://trac.macosforge.org/projects/ruby/changeset/4606
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 03:47:38 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Rescue any exception when evaluating.
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 10:47:30 UTC (rev 4605)
+++ DietRB/trunk/lib/irb/context.rb 2010-10-08 10:47:38 UTC (rev 4606)
@@ -13,6 +13,8 @@
def evaluate(source)
eval(source.to_s, @binding)
+ rescue Exception => e
+
end
def readline
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 10:47:30 UTC (rev 4605)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 10:47:38 UTC (rev 4606)
@@ -26,16 +26,6 @@
lambda { eval("x", @context.binding) }.should.raise NameError
end
- it "evaluates code with the object's binding" do
- @context.evaluate("self").should == main
- end
-
- it "coerces the given source to a string first" do
- o = Object.new
- def o.to_s; "self"; end
- @context.evaluate(o).should == main
- end
-
it "returns a prompt string, displaying line number and code indentation level" do
@context.prompt.should == "irb(main):001:0> "
@context.instance_variable_set(:@line, 23)
@@ -51,6 +41,29 @@
end
end
+describe "IRB::Context, when evaluating source" do
+ before do
+ @context = IRB::Context.new(main)
+ end
+
+ it "evaluates code with the object's binding" do
+ @context.evaluate("self").should == main
+ end
+
+ it "coerces the given source to a string first" do
+ o = Object.new
+ def o.to_s; "self"; end
+ @context.evaluate(o).should == main
+ end
+
+ it "rescues any type of exception" do
+ lambda {
+ @context.evaluate("DoesNotExist")
+ @context.evaluate("raise Exception")
+ }.should.not.raise
+ end
+end
+
class << Readline
attr_reader :received
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/eebd085c/attachment.html>
More information about the macruby-changes
mailing list