aboutsummaryrefslogtreecommitdiffstats
path: root/test/rdoc/test_rdoc_parser_c.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rdoc/test_rdoc_parser_c.rb')
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index fdc303e3e5..09d7c4b16d 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -176,6 +176,50 @@ void Init_Blah(void) {
assert_equal 'This is a writer', writer.comment.text
end
+ def test_do_attr_rb_attr_2
+ content = <<-EOF
+void Init_Blah(void) {
+ cBlah = rb_define_class("Blah", rb_cObject);
+
+ /*
+ * This is an accessor
+ */
+ rb_attr(cBlah, rb_intern_const("accessor"), 1, 1, Qfalse);
+
+ /*
+ * This is a reader
+ */
+ rb_attr(cBlah, rb_intern_const("reader"), 1, 0, Qfalse);
+
+ /*
+ * This is a writer
+ */
+ rb_attr(cBlah, rb_intern_const("writer"), 0, 1, Qfalse);
+}
+ EOF
+
+ klass = util_get_class content, 'cBlah'
+
+ attrs = klass.attributes
+ assert_equal 3, attrs.length, attrs.inspect
+
+ accessor = attrs.shift
+ assert_equal 'accessor', accessor.name
+ assert_equal 'RW', accessor.rw
+ assert_equal 'This is an accessor', accessor.comment.text
+ assert_equal @top_level, accessor.file
+
+ reader = attrs.shift
+ assert_equal 'reader', reader.name
+ assert_equal 'R', reader.rw
+ assert_equal 'This is a reader', reader.comment.text
+
+ writer = attrs.shift
+ assert_equal 'writer', writer.name
+ assert_equal 'W', writer.rw
+ assert_equal 'This is a writer', writer.comment.text
+ end
+
def test_do_attr_rb_define_attr
content = <<-EOF
void Init_Blah(void) {