1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
kazu 2009-06-02 04:29:31 +00:00
parent 6c743b0e5a
commit 06ac718546
2 changed files with 58 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Tue Jun 2 13:27:21 2009 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* test/ripper/test_filter.rb: add tests. see [ruby-dev:37856]
Mon Jun 1 11:21:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* cont.c (cont_capture, fiber_store): reraise transferred error.

View file

@ -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