Permalink
Browse files

RubyToken::Token#open_tag? didn't handle ELSE correctly

  • Loading branch information...
1 parent 3fef3c1 commit 7dd6bbbfe356742524439c799bd11fe02ffdfaa2 @notro notro committed Mar 10, 2011
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/proc_source.rb
  2. +10 −0 try/22_proc_try.rb
View
@@ -41,7 +41,7 @@ def to_lambda
class RubyToken::Token
# These EXPR_BEG tokens don't have associated end tags
- FAKIES = [RubyToken::TkWHEN, RubyToken::TkELSIF, RubyToken::TkTHEN]
+ FAKIES = [RubyToken::TkWHEN, RubyToken::TkELSIF, RubyToken::TkELSE, RubyToken::TkTHEN]
def name
@name ||= nil
View
@@ -101,6 +101,16 @@ def self.block_method(&block)
p.source
#=> "{ \n# comment\ntrue # comment\n# comment\n}\n"
+## should handle if, elsif, else statement
+p = Proc.new {
+if false
+elsif true
+else
+end
+}
+p.source
+#=> "{\nif false\nelsif true\nelse\nend\n}\n"
+
## #lines should be correct for one line proc
@line = __LINE__ + 1
p = Proc.new { false }

0 comments on commit 7dd6bbb

Please sign in to comment.