diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 23:33:36 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-18 23:33:36 +0000 |
commit | df7dac9174a31e71b58be6184e23bfe6b742a494 (patch) | |
tree | 885edf624f0e8f37014b0d937340ac1c372a0066 /test/rdoc/test_rdoc_parser_c.rb | |
parent | fed428007c015ac3b7f4586f2491517fafffa030 (diff) |
* lib/rdoc: Update to RDoc 4.1.0.preview.1
RDoc 4.1.0 contains a number of enhancements including a new default
style and accessibility support. You can see the changelog here:
https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc
* test/rdoc: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_parser_c.rb')
-rw-r--r-- | test/rdoc/test_rdoc_parser_c.rb | 124 |
1 files changed, 120 insertions, 4 deletions
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb index 8fe1bf46ec..99f2159203 100644 --- a/test/rdoc/test_rdoc_parser_c.rb +++ b/test/rdoc/test_rdoc_parser_c.rb @@ -534,10 +534,6 @@ void Init_curses(){ def test_do_constants_file content = <<-EOF void Init_File(void) { - rb_cFile = rb_define_class("File", rb_cIO); - rb_mFConst = rb_define_module_under(rb_cFile, "Constants"); - rb_include_module(rb_cIO, rb_mFConst); - /* Document-const: LOCK_SH * * Shared lock @@ -1000,6 +996,36 @@ init_gi_repository (void) assert_equal 2, klass.method_list.length end + def test_find_body_cast + content = <<-EOF +/* + * a comment for other_function + */ +VALUE +other_function() { +} + +void +Init_Foo(void) { + VALUE foo = rb_define_class("Foo", rb_cObject); + + rb_define_method(foo, "my_method", (METHOD)other_function, 0); +} + EOF + + klass = util_get_class content, 'foo' + other_function = klass.method_list.first + + assert_equal 'my_method', other_function.name + assert_equal "a comment for other_function", + other_function.comment.text + assert_equal '()', other_function.params + + code = other_function.token_stream.first.text + + assert_equal "VALUE\nother_function() {\n}", code + end + def test_find_body_define content = <<-EOF #define something something_else @@ -1669,6 +1695,96 @@ void Init(void) { assert_equal expected, @store.c_singleton_class_variables end + def test_scan_method_copy + parser = util_parser <<-C +/* + * call-seq: + * pathname.to_s -> string + * pathname.to_path -> string + * + * Return the path as a String. + * + * to_path is implemented so Pathname objects are usable with File.open, etc. + */ +static VALUE +path_to_s(VALUE self) { } + +/* + * call-seq: + * str[index] -> new_str or nil + * str[start, length] -> new_str or nil + * str.slice(index) -> new_str or nil + * str.slice(start, length) -> new_str or nil + */ +static VALUE +path_aref_m(int argc, VALUE *argv, VALUE str) { } + +/* + * call-seq: + * string <=> other_string -> -1, 0, +1 or nil + */ +static VALUE +path_cmp_m(VALUE str1, VALUE str2) { } + +/* + * call-seq: + * str == obj -> true or false + * str === obj -> true or false + */ +VALUE +rb_str_equal(VALUE str1, VALUE str2) { } + +Init_pathname() +{ + rb_cPathname = rb_define_class("Pathname", rb_cObject); + + rb_define_method(rb_cPathname, "to_s", path_to_s, 0); + rb_define_method(rb_cPathname, "to_path", path_to_s, 0); + rb_define_method(rb_cPathname, "[]", path_aref_m, -1); + rb_define_method(rb_cPathname, "slice", path_aref_m, -1); + rb_define_method(rb_cPathname, "<=>", path_cmp_m, 1); + rb_define_method(rb_cPathname, "==", rb_str_equal), 2); + rb_define_method(rb_cPathname, "===", rb_str_equal), 2); +} + C + + parser.scan + + pathname = @store.classes_hash['Pathname'] + + to_path = pathname.method_list.find { |m| m.name == 'to_path' } + assert_equal "pathname.to_path -> string", to_path.call_seq + + to_s = pathname.method_list.find { |m| m.name == 'to_s' } + assert_equal "pathname.to_s -> string", to_s.call_seq + + index_expected = <<-EXPECTED.chomp +str[index] -> new_str or nil +str[start, length] -> new_str or nil + EXPECTED + + index = pathname.method_list.find { |m| m.name == '[]' } + assert_equal index_expected, index.call_seq, '[]' + + slice_expected = <<-EXPECTED.chomp +str.slice(index) -> new_str or nil +str.slice(start, length) -> new_str or nil + EXPECTED + + slice = pathname.method_list.find { |m| m.name == 'slice' } + assert_equal slice_expected, slice.call_seq + + spaceship = pathname.method_list.find { |m| m.name == '<=>' } + assert_equal "string <=> other_string -> -1, 0, +1 or nil", + spaceship.call_seq + + equals2 = pathname.method_list.find { |m| m.name == '==' } + assert_match 'str == obj', equals2.call_seq + + equals3 = pathname.method_list.find { |m| m.name == '===' } + assert_match 'str === obj', equals3.call_seq + end + def test_scan_order_dependent parser = util_parser <<-C void a(void) { |