diff options
author | murphy <murphy@rubychan.de> | 2009-04-20 21:14:35 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-04-20 21:14:35 +0000 |
commit | d9d447e4d8c09943dc7832cdc921be7f2039471e (patch) | |
tree | f55b3838e28f678dba431738144f0e63baaf2804 | |
parent | 04e1ddf7e29af75c9b90da3153c77de6166d0ec7 (diff) | |
download | coderay-d9d447e4d8c09943dc7832cdc921be7f2039471e.tar.gz |
Fixed some test suite problems.
* coderay_suite: UTF-8 output is compared as binary.
* functional tests: cleaned up.
* test/unit: prevent Ruby 1.9 warning about circular require.
-rwxr-xr-x | test/functional/basic.rb | 31 | ||||
-rwxr-xr-x | test/functional/suite.rb | 2 | ||||
-rw-r--r-- | test/lib/test/unit/autorunner.rb | 1 | ||||
-rw-r--r-- | test/scanners/coderay_suite.rb | 9 |
4 files changed, 23 insertions, 20 deletions
diff --git a/test/functional/basic.rb b/test/functional/basic.rb index d2bc9f1..394d525 100755 --- a/test/functional/basic.rb +++ b/test/functional/basic.rb @@ -2,9 +2,10 @@ require "test/unit" require "coderay" class BasicTest < Test::Unit::TestCase + def test_version assert_nothing_raised do - CodeRay::VERSION + assert_match(/\A\d\.\d\.\d\z/, CodeRay::VERSION) end end @@ -38,7 +39,7 @@ class BasicTest < Test::Unit::TestCase require 'rubygems' gem 'RedCloth', '>= 4.0.3' rescue nil require 'redcloth' - + def test_for_redcloth require 'rubygems' require 'coderay/for_redcloth' @@ -51,7 +52,7 @@ class BasicTest < Test::Unit::TestCase BLOCKCODE RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html end - + def test_for_redcloth_no_lang require 'rubygems' require 'coderay/for_redcloth' @@ -62,7 +63,7 @@ class BasicTest < Test::Unit::TestCase BLOCKCODE RedCloth.new('bc. puts "Hello, World!"').to_html end - + def test_for_redcloth_style require 'rubygems' require 'coderay/for_redcloth' @@ -71,7 +72,7 @@ class BasicTest < Test::Unit::TestCase BLOCKCODE RedCloth.new('bc{color: red}. puts "Hello, World!"').to_html end - + def test_for_redcloth_escapes require 'rubygems' require 'coderay/for_redcloth' @@ -88,18 +89,14 @@ class BasicTest < Test::Unit::TestCase $stderr.puts 'RedCloth not found.' end - ENCODERS_LIST = %w( - count debug div html null page span statistic text tokens xml yaml - ) - def _test_list_of_encoders - assert_equal(ENCODERS_LIST, CodeRay::Encoders.list.sort) + def test_list_of_encoders + assert_kind_of(Array, CodeRay::Encoders.list) + assert CodeRay::Encoders.list.include?('count') end - - SCANNERS_LIST = %w( - c debug delphi html nitro_xhtml plaintext rhtml ruby xml - ) - def _test_list_of_scanners - assert_equal(SCANNERS_LIST, CodeRay::Scanners.list.sort) + + def test_list_of_scanners + assert_kind_of(Array, CodeRay::Scanners.list) + assert CodeRay::Scanners.list.include?('plaintext') end - + end diff --git a/test/functional/suite.rb b/test/functional/suite.rb index e187677..6c6d625 100755 --- a/test/functional/suite.rb +++ b/test/functional/suite.rb @@ -6,4 +6,4 @@ LIBDIR = Pathname.new(MYDIR).join('..', '..', 'lib').cleanpath.to_s $LOAD_PATH.unshift MYDIR, LIBDIR require 'basic' -require 'word_list'
\ No newline at end of file +require 'word_list' diff --git a/test/lib/test/unit/autorunner.rb b/test/lib/test/unit/autorunner.rb index 86c9b12..0dfc01c 100644 --- a/test/lib/test/unit/autorunner.rb +++ b/test/lib/test/unit/autorunner.rb @@ -1,4 +1,3 @@ -require 'test/unit' require 'test/unit/ui/testrunnerutilities' require 'optparse' diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 6e6249b..5edf6be 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -297,9 +297,16 @@ module CodeRay if File.exist?(expected_filename) && !(ENV['lang'] && ENV['new'] && name == ENV['new']) expected = File.open(expected_filename, 'rb') { |f| break f.read } + if result.respond_to?(:bytesize) && result.bytesize != result.size + # for char, i in result.chars.with_index + # raise "result has non-ASCII-8BIT character in line #{result[0,i].count(?\n) + 1}" if char.bytesize != 1 + # end + # UTF-8 encoded result; comparison needs to be done on binary level + result.force_encoding(:binary) + end ok = expected == result - actual_filename = expected_filename.sub('.expected.', '.actual.') unless ok + actual_filename = expected_filename.sub('.expected.', '.actual.') File.open(actual_filename, 'wb') { |f| f.write result } diff = expected_filename.sub(/\.expected\..*/, '.debug.diff') system "diff --unified=0 --text #{expected_filename} #{actual_filename} > #{diff}" |