From 558956eaff25fd832ccd3dc5747365bf32cd3825 Mon Sep 17 00:00:00 2001 From: murphy Date: Sun, 11 Jan 2009 04:31:20 +0000 Subject: Fixed a bug in Ruby scanner that broke tests with JRuby. --- lib/coderay/scanners/ruby.rb | 3 ++- test/scanners/coderay_suite.rb | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb index 1bbfe07..90c640a 100644 --- a/lib/coderay/scanners/ruby.rb +++ b/lib/coderay/scanners/ruby.rb @@ -191,6 +191,7 @@ module Scanners depth -= 1 if depth == 0 # closing brace of inline block reached state, depth, heredocs = inline_block_stack.pop + heredocs = nil if heredocs && heredocs.empty? tokens << [match, :inline_delimiter] kind = :inline match = :close @@ -346,7 +347,7 @@ module Scanners value_expected = value_expected == :set last_token_dot = last_token_dot == :set end - + if $DEBUG and not kind raise_inspect 'Error token %p in line %d' % [[match, kind], line], tokens, state diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 03c91f6..bdcbdce 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -251,7 +251,9 @@ module CodeRay begin scanner.tokenize rescue - flunk "Incremental test failed at #{size} #{RUBY_VERSION < '1.9' ? 'bytes' : 'chars'}!" if ENV['assert'] + assert_nothing_raised "Incremental test failed at #{size} #{RUBY_VERSION < '1.9' ? 'bytes' : 'chars'}!" do + raise + end if ENV['assert'] okay = false break end @@ -271,7 +273,9 @@ module CodeRay begin scanner.tokenize rescue - flunk 'shuffle test failed!' if ENV['assert'] + assert_nothing_raised 'shuffle test failed!' do + raise + end if ENV['assert'] okay = false break end @@ -383,7 +387,7 @@ module CodeRay def check_env_lang for key in %w(only new) - if ENV[key] && ENV[key][/^(\w+)\.([\w_]+)$/] + if ENV[key] && ENV[key][/^(\w+)\.([-\w_]+)$/] ENV['lang'] = $1 ENV[key] = $2 end -- cgit v1.2.1