summaryrefslogtreecommitdiff
path: root/test/unit/tokens.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-06-29 06:32:30 +0000
committermurphy <murphy@rubychan.de>2010-06-29 06:32:30 +0000
commit93dfad17309f46d00d1043592efdb282d13963fe (patch)
tree60cbfc2fbc3497f95f5d02de1e9ec8c7b10515ff /test/unit/tokens.rb
parent87764c224cc8c808688e83d7c1f93c8dbbbd9b4f (diff)
downloadcoderay-93dfad17309f46d00d1043592efdb282d13963fe.tar.gz
Added lots of unit tests.
Theses actually come from the library files; now they are included. Also, rake test and test:all don't test the scanners now; you have to start them using rake test:scanners.
Diffstat (limited to 'test/unit/tokens.rb')
-rw-r--r--test/unit/tokens.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit/tokens.rb b/test/unit/tokens.rb
new file mode 100644
index 0000000..ae6d25a
--- /dev/null
+++ b/test/unit/tokens.rb
@@ -0,0 +1,38 @@
+require 'test/unit'
+require 'coderay/tokens'
+
+class TokensTest < Test::Unit::TestCase
+
+ def test_creation
+ assert CodeRay::Tokens < Array
+ tokens = nil
+ assert_nothing_raised do
+ tokens = CodeRay::Tokens.new
+ end
+ assert_kind_of Array, tokens
+ end
+
+ def test_adding_tokens
+ tokens = CodeRay::Tokens.new
+ assert_nothing_raised do
+ tokens.text_token 'string', :type
+ tokens.text_token '()', :operator
+ end
+ assert_equal tokens.size, 4
+ assert_equal tokens.count, 2
+ end
+
+ def test_dump_undump
+ tokens = CodeRay::Tokens.new
+ assert_nothing_raised do
+ tokens.text_token 'string', :type
+ tokens.text_token '()', :operator
+ end
+ tokens2 = nil
+ assert_nothing_raised do
+ tokens2 = tokens.dump.undump
+ end
+ assert_equal tokens, tokens2
+ end
+
+end \ No newline at end of file