summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
authorkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-02 04:29:31 +0000
committerkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-02 04:29:31 +0000
commit06ac7185468b67921030a8dde04a81725b10f44b (patch)
tree4d88e8e3e8e3be31439294063ee4667799d707e7 /test/ripper
parent6c743b0e5ab15529af20c89f59582b4483e30066 (diff)
* test/ripper/test_filter.rb: add tests. see [ruby-dev:37856]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_filter.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/ripper/test_filter.rb b/test/ripper/test_filter.rb
new file mode 100644
index 0000000..4e9ee88
--- /dev/null
+++ b/test/ripper/test_filter.rb
@@ -0,0 +1,54 @@
+begin
+
+require 'ripper'
+require 'test/unit'
+
+class TestRipper_Filter < Test::Unit::TestCase
+
+ class Filter < Ripper::Filter
+ def on_default(event, token, data)
+ if data.empty?
+ data[:filename] = filename rescue nil
+ data[:lineno] = lineno
+ data[:column] = column
+ data[:token] = token
+ end
+ data
+ end
+ end
+
+ def filename
+ File.expand_path(__FILE__)
+ end
+
+ def test_filter_filename
+ data = {}
+ Filter.new(File.read(filename)).parse(data)
+ assert_equal('-', data[:filename], "[ruby-dev:37856]")
+
+ data = {}
+ Filter.new(File.read(filename), filename).parse(data)
+ assert_equal(filename, data[:filename])
+ end
+
+ def test_filter_lineno
+ data = {}
+ Filter.new(File.read(filename)).parse(data)
+ assert_equal(1, data[:lineno])
+ end
+
+ def test_filter_column
+ data = {}
+ Filter.new(File.read(filename)).parse(data)
+ assert_equal(0, data[:column])
+ end
+
+ def test_filter_token
+ data = {}
+ Filter.new(File.read(filename)).parse(data)
+ assert_equal("begin", data[:token])
+ end
+end
+
+rescue LoadError
+end