diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/c/suite.rb | 10 | ||||
-rw-r--r-- | test/html/suite.rb | 10 | ||||
-rw-r--r-- | test/rhtml/suite.rb | 10 | ||||
-rw-r--r-- | test/ruby/suite.rb | 10 | ||||
-rw-r--r-- | test/suite.rb | 162 | ||||
-rw-r--r-- | test/xhtml/suite.rb | 10 | ||||
-rw-r--r-- | test/xml/suite.rb | 10 |
7 files changed, 111 insertions, 111 deletions
diff --git a/test/c/suite.rb b/test/c/suite.rb index 969703e..8b32792 100644 --- a/test/c/suite.rb +++ b/test/c/suite.rb @@ -1,9 +1,9 @@ class CTest < CodeRaySuite
-
- @file = __FILE__
- LANG = :c
- EXTENSION = 'c'
-
+
+ @file = __FILE__
+ LANG = :c
+ EXTENSION = 'c'
+
end
$suite << CTest.suite if $suite
diff --git a/test/html/suite.rb b/test/html/suite.rb index bff8c83..f4cd6f4 100644 --- a/test/html/suite.rb +++ b/test/html/suite.rb @@ -1,9 +1,9 @@ class HTMLTest < CodeRaySuite
-
- @file = __FILE__
- LANG = :html
- EXTENSION = 'html'
-
+
+ @file = __FILE__
+ LANG = :html
+ EXTENSION = 'html'
+
end
$suite << HTMLTest.suite if $suite
diff --git a/test/rhtml/suite.rb b/test/rhtml/suite.rb index 95eb0e6..c9cd989 100644 --- a/test/rhtml/suite.rb +++ b/test/rhtml/suite.rb @@ -1,9 +1,9 @@ class RHTMLTest < CodeRaySuite
-
- @file = __FILE__
- LANG = :rhtml
- EXTENSION = 'rhtml'
-
+
+ @file = __FILE__
+ LANG = :rhtml
+ EXTENSION = 'rhtml'
+
end
$suite << RHTMLTest.suite if $suite
diff --git a/test/ruby/suite.rb b/test/ruby/suite.rb index b69cf6a..751b364 100644 --- a/test/ruby/suite.rb +++ b/test/ruby/suite.rb @@ -1,9 +1,9 @@ class RubyTest < CodeRaySuite
-
- @file = __FILE__
- LANG = :ruby
- EXTENSION = 'rb'
-
+
+ @file = __FILE__
+ LANG = :ruby
+ EXTENSION = 'rb'
+
end
$suite << RubyTest.suite if $suite
diff --git a/test/suite.rb b/test/suite.rb index aa94ecb..b7afa79 100644 --- a/test/suite.rb +++ b/test/suite.rb @@ -11,72 +11,72 @@ require 'test/unit' include Test::Unit
class CodeRaySuite < TestCase
-
- def self.dir &block
- @dir ||= File.dirname(@file)
- if block
- Dir.chdir @dir, &block
- end
- @dir
- end
-
- def dir &block
- self.class.dir(&block)
- end
-
- def extension
- 'in.' + self.class::EXTENSION
- end
-
- def lang
- self.class::LANG
- end
-
- def test_ALL
- puts
- puts " >> Running #{self.class.name} <<"
- puts
- scanner = CodeRay::Scanners[lang].new
- tokenizer = CodeRay::Encoders[:debug].new
- highlighter = CodeRay::Encoders[:html].new(
- :tab_width => 2,
- :line_numbers => :table,
- :wrap => :page,
- :hint => :debug,
- :css => :class
- )
-
- dir do
- for input in Dir["*.#{extension}"]
- puts "testing #{input}..."
- name = File.basename(input, ".#{extension}")
- output = name + '.out.' + tokenizer.file_extension
- code = File.open(input, 'rb') { |f| break f.read }
-
- scanner.string = code
- tokens = scanner.tokens
- result = tokenizer.encode_tokens tokens
- highlighted = highlighter.encode_tokens tokens
-
- File.open(name + '.html', 'w') do |f| f.write highlighted end
-
- if File.exist? output
- expected = File.read output
- ok = expected == result
- computed = output.sub('.out.', '.computed.')
- unless ok
- File.open(computed, 'w') { |f| f.write result }
- print `gvimdiff #{output} #{computed}` if ENV['diff']
- end
- assert(ok, "Scan error: #{computed} != #{output}") unless ENV['diff']
- else
- File.open(output, 'w') do |f| f.write result end
- puts "New test: #{output}"
- end
-
- end
- end
- end
+
+ def self.dir &block
+ @dir ||= File.dirname(@file)
+ if block
+ Dir.chdir @dir, &block
+ end
+ @dir
+ end
+
+ def dir &block
+ self.class.dir(&block)
+ end
+
+ def extension
+ 'in.' + self.class::EXTENSION
+ end
+
+ def lang
+ self.class::LANG
+ end
+
+ def test_ALL
+ puts
+ puts " >> Running #{self.class.name} <<"
+ puts
+ scanner = CodeRay::Scanners[lang].new
+ tokenizer = CodeRay::Encoders[:debug].new
+ highlighter = CodeRay::Encoders[:html].new(
+ :tab_width => 2,
+ :line_numbers => :table,
+ :wrap => :page,
+ :hint => :debug,
+ :css => :class
+ )
+
+ dir do
+ for input in Dir["*.#{extension}"]
+ puts "testing #{input}..."
+ name = File.basename(input, ".#{extension}")
+ output = name + '.out.' + tokenizer.file_extension
+ code = File.open(input, 'rb') { |f| break f.read }
+
+ scanner.string = code
+ tokens = scanner.tokens
+ result = tokenizer.encode_tokens tokens
+ highlighted = highlighter.encode_tokens tokens
+
+ File.open(name + '.html', 'w') do |f| f.write highlighted end
+
+ if File.exist? output
+ expected = File.read output
+ ok = expected == result
+ computed = output.sub('.out.', '.computed.')
+ unless ok
+ File.open(computed, 'w') { |f| f.write result }
+ print `gvimdiff #{output} #{computed}` if ENV['diff']
+ end
+ assert(ok, "Scan error: #{computed} != #{output}") unless ENV['diff']
+ else
+ File.open(output, 'w') do |f| f.write result end
+ puts "New test: #{output}"
+ end
+
+ end
+ end
+ end
end
@@ -84,29 +84,29 @@ require 'test/unit/testsuite' $suite = TestSuite.new
def load_suite name
- begin
- suite = File.join($mydir, name, 'suite.rb')
- require suite
- rescue LoadError
- $stderr.puts <<-ERR
+ begin
+ suite = File.join($mydir, name, 'suite.rb')
+ require suite
+ rescue LoadError
+ $stderr.puts <<-ERR
!! Suite #{suite} not found
-
- ERR
- false
- end
+
+ ERR
+ false
+ end
end
if subsuite = ARGV.find { |a| break $1 if a[/^([^-].*)/] } || ENV['scannerlang']
- load_suite(subsuite) or exit
+ load_suite(subsuite) or exit
else
- Dir[File.join($mydir, '*', '')].each { |suite| load_suite File.basename(suite) }
+ Dir[File.join($mydir, '*', '')].each { |suite| load_suite File.basename(suite) }
end
if ARGV.include? '-f'
- require 'test/unit/ui/fox/testrunner'
- UI::Fox::TestRunner.run $suite
+ require 'test/unit/ui/fox/testrunner'
+ UI::Fox::TestRunner.run $suite
else
- require 'test/unit/ui/console/testrunner'
- UI::Console::TestRunner.run $suite
+ require 'test/unit/ui/console/testrunner'
+ UI::Console::TestRunner.run $suite
end
diff --git a/test/xhtml/suite.rb b/test/xhtml/suite.rb index 0614874..63c13e3 100644 --- a/test/xhtml/suite.rb +++ b/test/xhtml/suite.rb @@ -1,9 +1,9 @@ class NitroHTMLTest < CodeRaySuite
-
- @file = __FILE__
- LANG = :xhtml
- EXTENSION = 'xhtml'
-
+
+ @file = __FILE__
+ LANG = :xhtml
+ EXTENSION = 'xhtml'
+
end
$suite << NitroHTMLTest.suite if $suite
diff --git a/test/xml/suite.rb b/test/xml/suite.rb index 9113107..8d2b9f0 100644 --- a/test/xml/suite.rb +++ b/test/xml/suite.rb @@ -1,9 +1,9 @@ class XMLTest < CodeRaySuite
-
- @file = __FILE__
- LANG = :xml
- EXTENSION = 'xml'
-
+
+ @file = __FILE__
+ LANG = :xml
+ EXTENSION = 'xml'
+
end
$suite << XMLTest.suite if $suite
|