diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/examples.rb | 8 | ||||
-rw-r--r-- | test/unit/debug.rb | 3 | ||||
-rw-r--r-- | test/unit/lines_of_code.rb | 13 |
3 files changed, 10 insertions, 14 deletions
diff --git a/test/functional/examples.rb b/test/functional/examples.rb index 44bc47f..d565fcc 100755 --- a/test/functional/examples.rb +++ b/test/functional/examples.rb @@ -48,6 +48,8 @@ end # keep scanned tokens for later use tokens = CodeRay.scan('{ "just": "an", "example": 42 }', :json) + assert_kind_of CodeRay::TokensProxy, tokens + assert_equal ["{", :operator, " ", :space, :begin_group, :key, "\"", :delimiter, "just", :content, "\"", :delimiter, :end_group, :key, ":", :operator, " ", :space, @@ -56,8 +58,8 @@ end " ", :space, :begin_group, :key, "\"", :delimiter, "example", :content, "\"", :delimiter, :end_group, :key, ":", :operator, " ", :space, "42", :integer, - " ", :space, "}", :operator], tokens - + " ", :space, "}", :operator], tokens.tokens + # produce a token statistic assert_equal <<-STATISTIC, tokens.statistic @@ -84,7 +86,7 @@ Token Types (7): STATISTIC # count the tokens - assert_equal 26, tokens.count # => 26 + assert_equal 26, tokens.count # produce a HTML div, but with CSS classes div = tokens.div(:css => :class) diff --git a/test/unit/debug.rb b/test/unit/debug.rb index 8bafcf5..f2b80bd 100644 --- a/test/unit/debug.rb +++ b/test/unit/debug.rb @@ -70,7 +70,8 @@ method([])] def test_filtering_text_tokens assert_equal TEST_OUTPUT, CodeRay::Scanners::Debug.new.tokenize(TEST_INPUT) - assert_equal TEST_OUTPUT, CodeRay.scan(TEST_INPUT, :debug) + assert_kind_of CodeRay::TokensProxy, CodeRay.scan(TEST_INPUT, :debug) + assert_equal TEST_OUTPUT, CodeRay.scan(TEST_INPUT, :debug).tokens end end diff --git a/test/unit/lines_of_code.rb b/test/unit/lines_of_code.rb index 4231d5a..e2c0caf 100644 --- a/test/unit/lines_of_code.rb +++ b/test/unit/lines_of_code.rb @@ -2,6 +2,8 @@ require 'test/unit' require 'coderay' $VERBOSE = true +require File.expand_path('../../lib/assert_warning', __FILE__) + class LinesOfCodeTest < Test::Unit::TestCase def test_creation @@ -39,17 +41,8 @@ puts "Hello world!" tokens.concat ["\n", :space] tokens.concat ["Hello\n", :comment] - stderr, fake_stderr = $stderr, Object.new - begin - $err = '' - def fake_stderr.write x - $err << x - end - $stderr = fake_stderr + assert_warning 'Tokens have no associated scanner, counting all nonempty lines.' do assert_equal 1, tokens.lines_of_code - assert_equal "Tokens have no associated scanner, counting all nonempty lines.\n", $err - ensure - $stderr = stderr end tokens.scanner = ScannerMockup.new |