blob: e255d07f759122380209009cdb403ee4f94e5ac0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
require 'test/unit'
require 'coderay'
class CommentFilterTest < Test::Unit::TestCase
def test_filtering_comments
tokens = CodeRay.scan <<-RUBY, :ruby
#!/usr/bin/env ruby
# a minimal Ruby program
puts "Hello world!"
RUBY
assert_equal <<-RUBY_FILTERED, tokens.comment_filter.text
#!/usr/bin/env ruby
puts "Hello world!"
RUBY_FILTERED
end
def test_filtering_docstrings
tokens = CodeRay.scan <<-PYTHON, :python
'''
Assuming this is file mymodule.py then this string, being the
first statement in the file will become the mymodule modules
docstring when the file is imported
'''
class Myclass():
"""
The class's docstring
"""
def mymethod(self):
'''The method's docstring'''
def myfunction():
"""The function's docstring"""
PYTHON
assert_equal <<-PYTHON_FILTERED.chomp, tokens.comment_filter.text
class Myclass():
def mymethod(self):
def myfunction():
PYTHON_FILTERED
end
end
|