summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
authorkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-26 23:11:59 +0000
committerkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-26 23:11:59 +0000
commitab77f00b04999a857382462d40dfaef3262cbe84 (patch)
tree841540c43d1fad56a46403b49e670fc825a5bb03 /test/ripper
parent33c5abbefae97178001f1ba8c95205b99209a313 (diff)
* parse.y (ripper_filename): add Ripper#filename. [ruby-dev:37856] * test/ripper/test_filter.rb: add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_filter.rb41
1 files changed, 35 insertions, 6 deletions
diff --git a/test/ripper/test_filter.rb b/test/ripper/test_filter.rb
index d7e9ba0..b398ebe 100644
--- a/test/ripper/test_filter.rb
+++ b/test/ripper/test_filter.rb
@@ -23,31 +23,60 @@ class TestRipper_Filter < Test::Unit::TestCase
File.expand_path(__FILE__)
end
- def test_filter_filename
+ def test_filter_filename_unset
data = {}
- Filter.new(File.read(filename)).parse(data)
+ filter = Filter.new(File.read(filename))
+ filter.parse(data)
assert_equal('-', data[:filename], "[ruby-dev:37856]")
+ assert_equal('-', filter.filename)
+ end
+ def test_filter_filename
data = {}
- Filter.new(File.read(filename), filename).parse(data)
+ filter = Filter.new(File.read(filename), filename)
+ assert_equal(filename, filter.filename)
+ filter.parse(data)
assert_equal(filename, data[:filename])
+ assert_equal(filename, filter.filename)
end
def test_filter_lineno
data = {}
- Filter.new(File.read(filename)).parse(data)
+ src = File.read(filename)
+ src_lines = src.count("\n")
+ filter = Filter.new(src)
+ assert_equal(nil, filter.lineno)
+ filter.parse(data)
assert_equal(1, data[:lineno])
+ assert_equal(src_lines, filter.lineno)
+ end
+
+ def test_filter_lineno_set
+ data = {}
+ src = File.read(filename)
+ src_lines = src.count("\n")
+ filter = Filter.new(src, '-', 100)
+ assert_equal(nil, filter.lineno)
+ filter.parse(data)
+ assert_equal(100, data[:lineno])
+ assert_equal(src_lines+100-1, filter.lineno)
end
def test_filter_column
data = {}
- Filter.new(File.read(filename)).parse(data)
+ src = File.read(filename)
+ last_columns = src[/(.*)\Z/].size
+ filter = Filter.new(src)
+ assert_equal(nil, filter.column)
+ filter.parse(data)
assert_equal(0, data[:column])
+ assert_equal(last_columns, filter.column)
end
def test_filter_token
data = {}
- Filter.new(File.read(filename)).parse(data)
+ filter = Filter.new(File.read(filename))
+ filter.parse(data)
assert_equal("begin", data[:token])
end
end if ripper_test