[macruby-changes] [4648] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 03:53:51 PDT 2010
Revision: 4648
http://trac.macosforge.org/projects/ruby/changeset/4648
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 03:53:50 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Support one liners, such as ?\226?\128?\152p :ok if true?\226?\128?\153.
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/lib/irb/source.rb
DietRB/trunk/spec/source_spec.rb
Modified: DietRB/trunk/lib/irb/source.rb
===================================================================
--- DietRB/trunk/lib/irb/source.rb 2010-10-08 10:53:41 UTC (rev 4647)
+++ DietRB/trunk/lib/irb/source.rb 2010-10-08 10:53:50 UTC (rev 4648)
@@ -54,11 +54,11 @@
@reflection ||= Reflector.new(source)
end
- class Reflector < Ripper
+ class Reflector < Ripper::SexpBuilder
def initialize(source)
super
@level = 0
- parse
+ @code_block = !parse.nil?
end
# Returns the code block indentation level.
@@ -85,7 +85,7 @@
#
# def foo; p :ok; end
def code_block?
- @level == 0
+ @code_block
end
# Returns whether or not the source contains a syntax error. However, it
Modified: DietRB/trunk/spec/source_spec.rb
===================================================================
--- DietRB/trunk/spec/source_spec.rb 2010-10-08 10:53:41 UTC (rev 4647)
+++ DietRB/trunk/spec/source_spec.rb 2010-10-08 10:53:50 UTC (rev 4648)
@@ -120,6 +120,9 @@
reflect("def foo").should.not.be.code_block
reflect("def foo; p :ok").should.not.be.code_block
reflect("def foo; p :ok; end").should.be.code_block
+
+ reflect("if true").should.not.be.code_block
+ reflect("p :ok if true").should.be.code_block
end
it "returns whether or not the source contains a syntax error, except a code block not ending" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/31093d93/attachment.html>
More information about the macruby-changes
mailing list