diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/basic.rb | 6 | ||||
-rw-r--r-- | test/functional/for_redcloth.rb | 20 | ||||
-rwxr-xr-x | test/functional/load_plugin_scanner.rb | 4 | ||||
-rwxr-xr-x | test/functional/suite.rb | 14 | ||||
-rw-r--r-- | test/functional/word_list.rb | 4 | ||||
-rw-r--r-- | test/lib/README | 3 | ||||
-rw-r--r-- | test/scanners/coderay_suite.rb | 9 | ||||
-rw-r--r-- | test/scanners/debug/class.expected.raydebug | 1 | ||||
-rw-r--r-- | test/scanners/php/namespaces.expected.raydebug | 9 | ||||
-rw-r--r-- | test/scanners/php/namespaces.in.php | 9 |
10 files changed, 50 insertions, 29 deletions
diff --git a/test/functional/basic.rb b/test/functional/basic.rb index 9f68763..150089e 100755 --- a/test/functional/basic.rb +++ b/test/functional/basic.rb @@ -1,5 +1,5 @@ -require "test/unit" -require "coderay" +require 'test/unit' +require 'coderay' class BasicTest < Test::Unit::TestCase @@ -103,7 +103,7 @@ more code # and another comment, in-line. def test_rubygems_not_loaded assert_equal nil, defined? Gem - end unless RUBY_VERSION >= '1.9' + end if ENV['check_rubygems'] && RUBY_VERSION < '1.9' def test_list_of_encoders assert_kind_of(Array, CodeRay::Encoders.list) diff --git a/test/functional/for_redcloth.rb b/test/functional/for_redcloth.rb index e955e30..a1c3100 100644 --- a/test/functional/for_redcloth.rb +++ b/test/functional/for_redcloth.rb @@ -1,23 +1,18 @@ -require "test/unit" - -require 'pathname' -MYDIR = File.dirname(__FILE__) -LIBDIR = Pathname.new(MYDIR).join('..', '..', 'lib').cleanpath.to_s -$LOAD_PATH.unshift LIBDIR -require "coderay" +require 'test/unit' +$: << 'lib' +require 'coderay' begin - require 'rubygems' + require 'rubygems' unless defined? Gem gem 'RedCloth', '>= 4.0.3' rescue nil require 'redcloth' rescue LoadError - $stderr.puts 'RedCloth not found - skipping for_redcloth tests.' + warn 'RedCloth not found - skipping for_redcloth tests.' end class BasicTest < Test::Unit::TestCase def test_for_redcloth - require 'rubygems' require 'coderay/for_redcloth' assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">puts <span style=\"background-color:#fff0f0;color:#D20\"><span style=\"color:#710\">"</span><span style=\"\">Hello, World!</span><span style=\"color:#710\">"</span></span></span></p>", RedCloth.new('@[ruby]puts "Hello, World!"@').to_html @@ -30,7 +25,6 @@ class BasicTest < Test::Unit::TestCase end def test_for_redcloth_no_lang - require 'rubygems' require 'coderay/for_redcloth' assert_equal "<p><code>puts \"Hello, World!\"</code></p>", RedCloth.new('@puts "Hello, World!"@').to_html @@ -41,7 +35,6 @@ class BasicTest < Test::Unit::TestCase end def test_for_redcloth_style - require 'rubygems' require 'coderay/for_redcloth' assert_equal <<-BLOCKCODE.chomp, <pre style=\"color: red;\"><code style=\"color: red;\">puts \"Hello, World!\"</code></pre> @@ -50,7 +43,6 @@ class BasicTest < Test::Unit::TestCase end def test_for_redcloth_escapes - require 'rubygems' require 'coderay/for_redcloth' assert_equal '<p><span lang="ruby" class="CodeRay">></span></p>', RedCloth.new('@[ruby]>@').to_html @@ -63,7 +55,6 @@ class BasicTest < Test::Unit::TestCase end def test_for_redcloth_escapes2 - require 'rubygems' require 'coderay/for_redcloth' assert_equal "<p><span lang=\"c\" class=\"CodeRay\"><span style=\"color:#579\">#include</span> <span style=\"color:#B44;font-weight:bold\"><test.h></span></span></p>", RedCloth.new('@[c]#include <test.h>@').to_html @@ -71,7 +62,6 @@ class BasicTest < Test::Unit::TestCase # See http://jgarber.lighthouseapp.com/projects/13054/tickets/124-code-markup-does-not-allow-brackets. def test_for_redcloth_false_positive - require 'rubygems' require 'coderay/for_redcloth' assert_equal '<p><code>[project]_dff.skjd</code></p>', RedCloth.new('@[project]_dff.skjd@').to_html diff --git a/test/functional/load_plugin_scanner.rb b/test/functional/load_plugin_scanner.rb index d778e08..25bbc93 100755 --- a/test/functional/load_plugin_scanner.rb +++ b/test/functional/load_plugin_scanner.rb @@ -1,5 +1,5 @@ -require "test/unit" -require "coderay" +require 'test/unit' +require 'coderay' class PluginScannerTest < Test::Unit::TestCase diff --git a/test/functional/suite.rb b/test/functional/suite.rb index ae9c7f0..039ab47 100755 --- a/test/functional/suite.rb +++ b/test/functional/suite.rb @@ -1,10 +1,12 @@ require 'test/unit' -require 'pathname' MYDIR = File.dirname(__FILE__) -LIBDIR = Pathname.new(MYDIR).join('..', '..', 'lib').cleanpath.to_s -$LOAD_PATH.unshift MYDIR, LIBDIR -require 'basic' -require 'load_plugin_scanner' -require 'word_list' +$: << 'lib' +require 'coderay' +puts "Running basic CodeRay #{CodeRay::VERSION} tests..." + +suite = %w(basic load_plugin_scanner word_list) +for test_case in suite + load File.join(MYDIR, test_case + '.rb') +end diff --git a/test/functional/word_list.rb b/test/functional/word_list.rb index 04f4a02..84d6e9e 100644 --- a/test/functional/word_list.rb +++ b/test/functional/word_list.rb @@ -1,5 +1,5 @@ -require "test/unit" -require "coderay" +require 'test/unit' +require 'coderay' class WordListTest < Test::Unit::TestCase diff --git a/test/lib/README b/test/lib/README index dd18540..7d7a0a0 100644 --- a/test/lib/README +++ b/test/lib/README @@ -1,2 +1,3 @@ Contents: -- test/unit: We need the old Test::Unit for the scanner test suite to work with Ruby 1.9.
\ No newline at end of file +- test/unit: We need the old Test::Unit for the scanner test suite to work with Ruby 1.9. +- term/ansicolor: Used for colorful output of the scanner tests.
\ No newline at end of file diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 60f71be..3a98c6b 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -11,6 +11,8 @@ $:.unshift File.join($mydir, '..', 'lib') require 'term/ansicolor' unless ENV['nocolor'] +require 'test/unit' + if defined? Term::ANSIColor class String include Term::ANSIColor @@ -413,6 +415,13 @@ module CodeRay return false end File.open(actual_html, 'w') { |f| f.write highlighted } + if okay + debug = $DEBUG + $DEBUG = false + FileUtils.copy(actual_html, name + '.expected.html') + $DEBUG = debug + end + true end expected_html = name + '.expected.html' diff --git a/test/scanners/debug/class.expected.raydebug b/test/scanners/debug/class.expected.raydebug index 501c99f..a53cdd6 100644 --- a/test/scanners/debug/class.expected.raydebug +++ b/test/scanners/debug/class.expected.raydebug @@ -12,3 +12,4 @@ < !! Folder )inline<delimiter(#{)constant(File)operator(.)ident(split)operator(()pre_constant(__FILE__)operator(\))operator(.)ident(first) operator(+) string<delimiter(')content(/)delimiter(')> operator(+) ident(name)delimiter(})>content( not found --- > !! Folder )inline<inline_delimiter(#{)constant(File)operator(.)ident(split)operator(()pre_constant(__FILE__)operator(\))operator(.)ident(first) operator(+) string<delimiter(')content(/)delimiter(')> operator(+) ident(name)inline_delimiter(})>content( not found +)
\ No newline at end of file diff --git a/test/scanners/php/namespaces.expected.raydebug b/test/scanners/php/namespaces.expected.raydebug new file mode 100644 index 0000000..47074a9 --- /dev/null +++ b/test/scanners/php/namespaces.expected.raydebug @@ -0,0 +1,9 @@ +inline_delimiter(<?php) +reserved(namespace) ident(foo)operator(;) +reserved(use) ident(blah)operator(\\)ident(blah) reserved(as) ident(foo)operator(;) + +local_variable($a) operator(=) reserved(new) ident(my)operator(\\)ident(name)operator(()operator(\))operator(;) comment(// instantiates "foo\\my\\name" class) +ident(foo)operator(\\)ident(bar)operator(::)ident(name)operator(()operator(\))operator(;) comment(// calls static method "name" in class "blah\\blah\\bar") +ident(my)operator(\\)ident(bar)operator(()operator(\))operator(;) comment(// calls function "foo\\my\\bar") +local_variable($a) operator(=) ident(my)operator(\\)constant(BAR)operator(;) comment(// sets $a to the value of constant "foo\\my\\BAR") +inline_delimiter(?>) diff --git a/test/scanners/php/namespaces.in.php b/test/scanners/php/namespaces.in.php new file mode 100644 index 0000000..ad6a1a1 --- /dev/null +++ b/test/scanners/php/namespaces.in.php @@ -0,0 +1,9 @@ +<?php +namespace foo; +use blah\blah as foo; + +$a = new my\name(); // instantiates "foo\my\name" class +foo\bar::name(); // calls static method "name" in class "blah\blah\bar" +my\bar(); // calls function "foo\my\bar" +$a = my\BAR; // sets $a to the value of constant "foo\my\BAR" +?> |