[macruby-changes] [4608] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 03:47:58 PDT 2010
Revision: 4608
http://trac.macosforge.org/projects/ruby/changeset/4608
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 03:47:57 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Increase the line number after processing a line.
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:48 UTC (rev 4607)
+++ DietRB/trunk/lib/irb/context.rb 2010-10-08 10:47:57 UTC (rev 4608)
@@ -13,7 +13,7 @@
def evaluate(source)
result = eval("_ = (#{source})", @binding)
- puts "=> #{result.inspect}"
+ puts format_result(result)
result
rescue Exception => e
puts format_exception(e)
@@ -35,6 +35,7 @@
evaluate(@source)
clear_buffer
end
+ @line += 1
end
PROMPT = "irb(%s):%03d:%d> "
@@ -43,6 +44,10 @@
PROMPT % [@object.inspect, @line, @source.level]
end
+ def format_result(result)
+ "=> #{result.inspect}"
+ end
+
def format_exception(e)
"#{e.class.name}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
end
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 10:47:48 UTC (rev 4607)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 10:47:57 UTC (rev 4608)
@@ -126,6 +126,14 @@
@context.source.to_s.should == "def foo\np :ok"
end
+ it "increases the current line number" do
+ @context.line.should == 1
+ @context.process_line("def foo")
+ @context.line.should == 2
+ @context.process_line("p :ok")
+ @context.line.should == 3
+ end
+
it "evaluates the buffered source once it's a valid code block" do
def @context.evaluate(source); @evaled = source; end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/951bb7fd/attachment-0001.html>
More information about the macruby-changes
mailing list