summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/functional/basic.rb8
-rwxr-xr-xtest/functional/suite.rb3
-rw-r--r--test/functional/word_list.rb64
3 files changed, 70 insertions, 5 deletions
diff --git a/test/functional/basic.rb b/test/functional/basic.rb
index a00e4ae..2da85e6 100755
--- a/test/functional/basic.rb
+++ b/test/functional/basic.rb
@@ -1,8 +1,7 @@
require "test/unit"
-
require "coderay"
-class Basic < Test::Unit::TestCase
+class BasicTest < Test::Unit::TestCase
def test_version
assert_nothing_raised do
CodeRay::VERSION
@@ -36,9 +35,10 @@ class Basic < Test::Unit::TestCase
end
SCANNERS_LIST = %w(
- c delphi html nitro_xhtml plaintext rhtml ruby xml
+ c debug delphi html nitro_xhtml plaintext rhtml ruby xml
)
def test_list_of_scanners
assert_equal(SCANNERS_LIST, CodeRay::Scanners.list.sort)
end
-end \ No newline at end of file
+
+end
diff --git a/test/functional/suite.rb b/test/functional/suite.rb
index 51f9a59..46316d8 100755
--- a/test/functional/suite.rb
+++ b/test/functional/suite.rb
@@ -5,4 +5,5 @@ MYDIR = File.dirname(__FILE__)
LIBDIR = Pathname.new(MYDIR).join('..', '..', 'lib').cleanpath
$LOAD_PATH.unshift MYDIR, LIBDIR
-require 'basic' \ No newline at end of file
+require 'basic'
+require 'word_list' \ No newline at end of file
diff --git a/test/functional/word_list.rb b/test/functional/word_list.rb
new file mode 100644
index 0000000..c710d77
--- /dev/null
+++ b/test/functional/word_list.rb
@@ -0,0 +1,64 @@
+require "test/unit"
+require "coderay"
+
+class WordListTest < Test::Unit::TestCase
+
+ # define word arrays
+ RESERVED_WORDS = %w[
+ asm break case continue default do else
+ ...
+ ]
+
+ PREDEFINED_TYPES = %w[
+ int long short char void
+ ...
+ ]
+
+ PREDEFINED_CONSTANTS = %w[
+ EOF NULL ...
+ ]
+
+ # make a WordList
+ IDENT_KIND = WordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ def test_word_list_example
+ assert_equal :pre_type, IDENT_KIND['void']
+ # assert_equal :pre_constant, IDENT_KIND['...'] # not specified
+ end
+
+ def test_word_list
+ list = WordList.new(:ident).add(['foobar'], :reserved)
+ assert_equal :reserved, list['foobar']
+ assert_equal :ident, list['FooBar']
+ end
+
+ def test_word_list_cached
+ list = WordList.new(:ident, true).add(['foobar'], :reserved)
+ assert_equal :reserved, list['foobar']
+ assert_equal :ident, list['FooBar']
+ end
+
+ def test_case_ignoring_word_list
+ list = CaseIgnoringWordList.new(:ident).add(['foobar'], :reserved)
+ assert_equal :reserved, list['foobar']
+ assert_equal :reserved, list['FooBar']
+
+ list = CaseIgnoringWordList.new(:ident).add(['FooBar'], :reserved)
+ assert_equal :reserved, list['foobar']
+ assert_equal :reserved, list['FooBar']
+ end
+
+ def test_case_ignoring_word_list_cached
+ list = CaseIgnoringWordList.new(:ident, true).add(['foobar'], :reserved)
+ assert_equal :reserved, list['foobar']
+ assert_equal :reserved, list['FooBar']
+
+ list = CaseIgnoringWordList.new(:ident, true).add(['FooBar'], :reserved)
+ assert_equal :reserved, list['foobar']
+ assert_equal :reserved, list['FooBar']
+ end
+
+end \ No newline at end of file