summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-07 03:33:19 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-07 03:33:19 +0000
commitd9591028f28606a6e855088eb15538d1730f3918 (patch)
treeb0f45f8ab5c963a19eaea0bcd7f7a4776c74937f /test/rdoc
parentd7dbd877ff890462fd138434d170094bf8fae638 (diff)
Merge RDoc updates from matzruby 11502, 11503, 11504
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/parsers/test_parse_c.rb117
1 files changed, 115 insertions, 2 deletions
diff --git a/test/rdoc/parsers/test_parse_c.rb b/test/rdoc/parsers/test_parse_c.rb
index c7815a95c0..6157a9e1d4 100644
--- a/test/rdoc/parsers/test_parse_c.rb
+++ b/test/rdoc/parsers/test_parse_c.rb
@@ -1,4 +1,3 @@
-require 'pp'
require 'stringio'
require 'tempfile'
require 'test/unit'
@@ -28,6 +27,66 @@ class TestRdocC_Parser < Test::Unit::TestCase
@tempfile.unlink
end
+ def test_do_classes_boot_class
+ content = <<-EOF
+/* Document-class: Foo
+ * this is the Foo boot class
+ */
+VALUE cFoo = boot_defclass("Foo", 0);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal " this is the Foo boot class\n ", klass.comment
+ end
+
+ def test_do_classes_class
+ content = <<-EOF
+/* Document-class: Foo
+ * this is the Foo class
+ */
+VALUE cFoo = rb_define_class("Foo", rb_cObject);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal " this is the Foo class\n ", klass.comment
+ end
+
+ def test_do_classes_class_under
+ content = <<-EOF
+/* Document-class: Kernel::Foo
+ * this is the Foo class under Kernel
+ */
+VALUE cFoo = rb_define_class_under(rb_mKernel, "Foo", rb_cObject);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal " this is the Foo class under Kernel\n ", klass.comment
+ end
+
+ def test_do_classes_module
+ content = <<-EOF
+/* Document-module: Foo
+ * this is the Foo module
+ */
+VALUE mFoo = rb_define_module("Foo");
+ EOF
+
+ klass = util_get_class content, 'mFoo'
+ assert_equal " this is the Foo module\n ", klass.comment
+ end
+
+ def test_do_classes_module_under
+ content = <<-EOF
+/* Document-module: Kernel::Foo
+ * this is the Foo module under Kernel
+ */
+VALUE mFoo = rb_define_module_under(rb_mKernel, "Foo");
+ EOF
+
+ klass = util_get_class content, 'mFoo'
+ assert_equal " this is the Foo module under Kernel\n ", klass.comment
+ end
+
def test_do_constants
content = <<-EOF
#include <ruby.h>
@@ -83,7 +142,7 @@ void Init_foo(){
parser.do_classes
parser.do_constants
- klass = parser.classes['cFoo']
+ klass = parser.classes['cFoo']
assert klass
constants = klass.constants
@@ -138,6 +197,60 @@ void Init_foo(){
assert constants.empty?, constants.inspect
end
+ def test_find_class_comment_init
+ content = <<-EOF
+/*
+ * a comment for class Foo
+ */
+void
+Init_Foo(void) {
+ VALUE foo = rb_define_class("Foo", rb_cObject);
+}
+ EOF
+
+ klass = util_get_class content, 'foo'
+
+ assert_equal " \n a comment for class Foo\n \n", klass.comment
+ end
+
+ def test_find_class_comment_define_class
+ content = <<-EOF
+/*
+ * a comment for class Foo
+ */
+VALUE foo = rb_define_class("Foo", rb_cObject);
+ EOF
+
+ klass = util_get_class content, 'foo'
+
+ assert_equal " \n a comment for class Foo\n ", klass.comment
+ end
+
+ def test_find_class_comment_define_class
+ content = <<-EOF
+/*
+ * a comment for class Foo on Init
+ */
+void
+Init_Foo(void) {
+ /*
+ * a comment for class Foo on rb_define_class
+ */
+ VALUE foo = rb_define_class("Foo", rb_cObject);
+}
+ EOF
+
+ klass = util_get_class content, 'foo'
+
+ assert_equal " \n a comment for class Foo on Init\n \n", klass.comment
+ end
+
+ def util_get_class(content, name)
+ parser = util_parser content
+ parser.do_classes
+ parser.classes[name]
+ end
+
def util_parser(content)
parser = RDoc::C_Parser.new @top_level, @fn, content, @options, @stats
parser.progress = @progress