summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/coderay-lib.tmproj10
-rw-r--r--lib/coderay/scanners/_map.rb2
-rw-r--r--lib/coderay/scanners/debug.rb1
-rw-r--r--lib/coderay/scanners/delphi.rb1
-rw-r--r--lib/coderay/scanners/nitro_xhtml.rb1
-rw-r--r--lib/coderay/scanners/scheme.rb2
-rw-r--r--lib/coderay/scanners/xml.rb1
-rw-r--r--test/scanners/coderay_suite.rb22
-rw-r--r--test/scanners/debug/suite.rb1
-rw-r--r--test/scanners/nitro/suite.rb1
10 files changed, 27 insertions, 15 deletions
diff --git a/etc/coderay-lib.tmproj b/etc/coderay-lib.tmproj
index b787e8c..ecd2d1c 100644
--- a/etc/coderay-lib.tmproj
+++ b/etc/coderay-lib.tmproj
@@ -85,12 +85,6 @@
<string>../diff</string>
<key>lastUsed</key>
<date>2008-08-11T12:12:11Z</date>
- <key>selected</key>
- <true/>
- </dict>
- <dict>
- <key>filename</key>
- <string>../ROADMAP</string>
</dict>
<dict>
<key>filename</key>
@@ -110,7 +104,9 @@
<key>filename</key>
<string>../test/scanners/coderay_suite.rb</string>
<key>lastUsed</key>
- <date>2008-08-04T21:50:01Z</date>
+ <date>2008-09-16T21:34:38Z</date>
+ <key>selected</key>
+ <true/>
</dict>
<dict>
<key>filename</key>
diff --git a/lib/coderay/scanners/_map.rb b/lib/coderay/scanners/_map.rb
index 1c5fc89..e8dfa07 100644
--- a/lib/coderay/scanners/_map.rb
+++ b/lib/coderay/scanners/_map.rb
@@ -5,8 +5,8 @@ module Scanners
:plain => :plaintext,
:pascal => :delphi,
:irb => :ruby,
- :xml => :html,
:xhtml => :nitro_xhtml,
+ :javascript => :java_script,
:nitro => :nitro_xhtml
default :plain
diff --git a/lib/coderay/scanners/debug.rb b/lib/coderay/scanners/debug.rb
index 0dee38f..ec594c1 100644
--- a/lib/coderay/scanners/debug.rb
+++ b/lib/coderay/scanners/debug.rb
@@ -6,6 +6,7 @@ module Scanners
include Streamable
register_for :debug
+ file_extension 'raydebug'
protected
def scan_tokens tokens, options
diff --git a/lib/coderay/scanners/delphi.rb b/lib/coderay/scanners/delphi.rb
index 5ee07a3..0975b26 100644
--- a/lib/coderay/scanners/delphi.rb
+++ b/lib/coderay/scanners/delphi.rb
@@ -4,6 +4,7 @@ module Scanners
class Delphi < Scanner
register_for :delphi
+ file_extension 'pas'
RESERVED_WORDS = [
'and', 'array', 'as', 'at', 'asm', 'at', 'begin', 'case', 'class',
diff --git a/lib/coderay/scanners/nitro_xhtml.rb b/lib/coderay/scanners/nitro_xhtml.rb
index d7968cc..4a8ee96 100644
--- a/lib/coderay/scanners/nitro_xhtml.rb
+++ b/lib/coderay/scanners/nitro_xhtml.rb
@@ -11,6 +11,7 @@ module Scanners
include Streamable
register_for :nitro_xhtml
+ file_extension :xhtml
NITRO_RUBY_BLOCK = /
<\?r
diff --git a/lib/coderay/scanners/scheme.rb b/lib/coderay/scanners/scheme.rb
index 2aee223..c869a30 100644
--- a/lib/coderay/scanners/scheme.rb
+++ b/lib/coderay/scanners/scheme.rb
@@ -6,7 +6,7 @@ module CodeRay
class Scheme < Scanner
register_for :scheme
- file_extension :scm
+ file_extension 'scm'
CORE_FORMS = %w[
lambda let let* letrec syntax-case define-syntax let-syntax
diff --git a/lib/coderay/scanners/xml.rb b/lib/coderay/scanners/xml.rb
index ff923fb..bc6020a 100644
--- a/lib/coderay/scanners/xml.rb
+++ b/lib/coderay/scanners/xml.rb
@@ -11,6 +11,7 @@ module Scanners
class XML < HTML
register_for :xml
+ file_extension 'xml'
end
diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb
index b417b16..4ad057b 100644
--- a/test/scanners/coderay_suite.rb
+++ b/test/scanners/coderay_suite.rb
@@ -157,15 +157,28 @@ module CodeRay
def examples_test scanner, max
self.class.dir do
extension = 'in.' + self.class.extension
- for example_filename in Dir["*.#{extension}"]
+ path = "test/scanners/#{File.basename(Dir.pwd)}/*.#{extension}"
+ print 'Loading examples in '.green + path.cyan + '...'.green
+ examples = Dir["*.#{extension}"]
+ if examples.empty?
+ puts "No examples found!".red
+ else
+ puts '%d'.yellow % examples.size + " example#{'s' if examples.size > 1} found.".green
+ end
+ for example_filename in examples
name = File.basename(example_filename, ".#{extension}")
next if ENV['lang'] && ENV['only'] && ENV['only'] != name
print name_and_size = ('%15s'.cyan + ' %6.1fK: '.yellow) %
[ name, File.size(example_filename) / 1024.0 ]
+
+ tokens = nil
time_for_file = Benchmark.realtime do
- example_test example_filename, name, scanner, max
+ tokens = example_test example_filename, name, scanner, max
end
- print 'finished in '.green + '%0.2fs'.white % time_for_file
+ tokens_per_second = tokens.size / time_for_file
+
+ print 'finished in '.green + '%5.2fs'.white % time_for_file +
+ ' ('.green + '%6.0f tok/s'.white % tokens_per_second + ')'.green
puts '.'.green
end
end
@@ -195,6 +208,7 @@ module CodeRay
else
print '-- skipped -- '.concealed
end
+ tokens
end
def random_test scanner, max
@@ -315,7 +329,7 @@ module CodeRay
highlighted = Highlighter.encode_tokens tokens
rescue
flunk 'highlighting test failed!' if ENV['assert']
- return
+ return false
end
File.open(name + '.actual.html', 'w') { |f| f.write highlighted }
File.copy(name + '.actual.html', name + '.expected.html') if okay
diff --git a/test/scanners/debug/suite.rb b/test/scanners/debug/suite.rb
index 42503ee..10ce930 100644
--- a/test/scanners/debug/suite.rb
+++ b/test/scanners/debug/suite.rb
@@ -1,3 +1,2 @@
class Debug < CodeRay::TestCase
- extension :raydebug
end
diff --git a/test/scanners/nitro/suite.rb b/test/scanners/nitro/suite.rb
index c2f0e33..2836cd3 100644
--- a/test/scanners/nitro/suite.rb
+++ b/test/scanners/nitro/suite.rb
@@ -1,3 +1,2 @@
class Nitro < CodeRay::TestCase
- extension :xhtml
end