diff options
author | murphy <murphy@rubychan.de> | 2007-01-01 16:26:17 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2007-01-01 16:26:17 +0000 |
commit | da09c7c6bb1267996db7751e775d08742256f3f2 (patch) | |
tree | dd5029385fb87f04cd242857f0c833d0db6cca6a /test/scanners/coderay_suite.rb | |
parent | 74c9a0d2b32e45c0692b4cdad4eddcab1e6a74e3 (diff) | |
download | coderay-da09c7c6bb1267996db7751e775d08742256f3f2.tar.gz |
New Scanner: Scheme (thanks closure!)
Test and example added.
Token changed: operator_fat instead of operator_name (for use with LISP-like
parentheses).
Added file_extension for Scanners.
Improved CodeRay::Suite:
- uses scanners file extension now
- example parameter is now named "only"
- only param overwrite MAX_CODE_SIZE_TO_HIGHLIGHT
Diffstat (limited to 'test/scanners/coderay_suite.rb')
-rw-r--r-- | test/scanners/coderay_suite.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 9ca0128..122d9cd 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -128,20 +128,13 @@ module CodeRay if extension @extension = extension.to_s else - @extension ||= lang.to_s + @extension ||= CodeRay::Scanners[lang].file_extension.to_s end end end # Create only once, for speed Tokenizer = CodeRay::Encoders[:debug].new - Highlighter = CodeRay::Encoders[:html].new( - :tab_width => 2, - :line_numbers => :inline, - :wrap => :page, - :hint => :debug, - :css => :class - ) def test_ALL puts @@ -168,7 +161,7 @@ module CodeRay extension = 'in.' + self.class.extension for example_filename in Dir["*.#{extension}"] name = File.basename(example_filename, ".#{extension}") - next if ENV['example'] and ENV['example'] != name + next if ENV['only'] and ENV['only'] != name print name_and_size = ('%15s'.cyan + ' %4.0fK: '.yellow) % [ name, File.size(example_filename) / 1024.0 ] time_for_file = Benchmark.realtime do @@ -181,7 +174,7 @@ module CodeRay end def example_test example_filename, name, scanner, max - if File.size(example_filename) > MAX_CODE_SIZE_TO_TEST and not ENV['example'] + if File.size(example_filename) > MAX_CODE_SIZE_TO_TEST and not ENV['only'] print 'too big. ' return end @@ -199,7 +192,7 @@ module CodeRay identity_test scanner, tokens - unless ENV['nohl'] or code.size > MAX_CODE_SIZE_TO_HIGHLIGHT + unless ENV['nohl'] or (code.size > MAX_CODE_SIZE_TO_HIGHLIGHT and not ENV['only']) highlight_test tokens, name else print '-- skipped -- '.concealed @@ -286,6 +279,14 @@ module CodeRay print ', '.red end + Highlighter = CodeRay::Encoders[:html].new( + :tab_width => 2, + :line_numbers => :inline, + :wrap => :page, + :hint => :debug, + :css => :class + ) + def highlight_test tokens, name print 'highlighting, '.red highlighted = Highlighter.encode_tokens tokens |