summaryrefslogtreecommitdiff
path: root/test/rdoc/test_rdoc_parser_ruby.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rdoc/test_rdoc_parser_ruby.rb')
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb60
1 files changed, 55 insertions, 5 deletions
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 337cf9ea1a..3e2a85ffba 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -921,7 +921,7 @@ end
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
end
err = stds[1]
- assert_match(/Expected class name or '<<'\. Got/, err)
+ assert_match(/Expected class name or '<<\'\. Got/, err)
end
def test_parse_syntax_error_code
@@ -1960,10 +1960,10 @@ end
def test_parse_method_bracket
util_parser <<-RUBY
class C
- def [] end
- def self.[] end
- def []= end
- def self.[]= end
+ def []; end
+ def self.[]; end
+ def []=; end
+ def self.[]=; end
end
RUBY
@@ -3065,6 +3065,28 @@ RUBY
assert_nil m.params, 'Module parameter not removed'
end
+ def test_parse_statements_nodoc_identifier_alias
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\nalias :old :new # :nodoc:"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
+ def test_parse_statements_nodoc_identifier_alias_method
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\nalias_method :old :new # :nodoc:"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
def test_parse_statements_stopdoc_alias
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
@@ -3205,6 +3227,14 @@ RUBY
assert_nil @parser.parse_symbol_in_arg
end
+ def test_parse_percent_symbol
+ content = '%s[foo bar]'
+ util_parser content
+ tk = @parser.get_tk
+ assert_equal :on_symbol, tk[:kind]
+ assert_equal content, tk[:text]
+ end
+
def test_parse_statements_alias_method
content = <<-CONTENT
class A
@@ -3350,6 +3380,13 @@ end
assert_equal :on_const, parser.get_tk[:kind]
end
+ def test_read_directive_linear_performance
+ pre = ->(i) {util_parser '# ' + '0'*i + '=000:'}
+ assert_linear_performance((1..5).map{|i|10**i}, pre: pre) do |parser|
+ assert_nil parser.read_directive []
+ end
+ end
+
def test_read_documentation_modifiers
c = RDoc::Context.new
@@ -4345,4 +4382,17 @@ end
assert_equal 'Hello', meth.comment.text
end
+ def test_parenthesized_cdecl
+ util_parser <<-RUBY
+module DidYouMean
+ class << (NameErrorCheckers = Object.new)
+ end
+end
+ RUBY
+
+ @parser.scan
+
+ refute_predicate @store.find_class_or_module('DidYouMean'), :nil?
+ refute_predicate @store.find_class_or_module('DidYouMean::NameErrorCheckers'), :nil?
+ end
end