ffi-clang 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +4 -0
  3. data/.travis.yml +20 -9
  4. data/Gemfile +10 -1
  5. data/README.md +1 -1
  6. data/Rakefile +9 -9
  7. data/examples/docs.cpp +25 -0
  8. data/examples/docs.rb +31 -0
  9. data/ffi-clang.gemspec +1 -1
  10. data/lib/ffi/clang.rb +16 -13
  11. data/lib/ffi/clang/clang_version.rb +29 -0
  12. data/lib/ffi/clang/code_completion.rb +1 -1
  13. data/lib/ffi/clang/comment.rb +8 -4
  14. data/lib/ffi/clang/compilation_database.rb +1 -1
  15. data/lib/ffi/clang/cursor.rb +42 -15
  16. data/lib/ffi/clang/diagnostic.rb +6 -2
  17. data/lib/ffi/clang/file.rb +6 -9
  18. data/lib/ffi/clang/index.rb +4 -4
  19. data/lib/ffi/clang/lib.rb +1 -1
  20. data/lib/ffi/clang/lib/{utils.rb → clang_version.rb} +1 -1
  21. data/lib/ffi/clang/lib/code_completion.rb +2 -3
  22. data/lib/ffi/clang/lib/comment.rb +0 -2
  23. data/lib/ffi/clang/lib/compilation_database.rb +6 -9
  24. data/lib/ffi/clang/lib/cursor.rb +10 -18
  25. data/lib/ffi/clang/lib/diagnostic.rb +4 -4
  26. data/lib/ffi/clang/lib/file.rb +4 -6
  27. data/lib/ffi/clang/lib/inclusions.rb +2 -2
  28. data/lib/ffi/clang/lib/index.rb +0 -2
  29. data/lib/ffi/clang/lib/source_location.rb +6 -8
  30. data/lib/ffi/clang/lib/source_range.rb +1 -1
  31. data/lib/ffi/clang/lib/string.rb +0 -2
  32. data/lib/ffi/clang/lib/translation_unit.rb +2 -2
  33. data/lib/ffi/clang/lib/type.rb +8 -17
  34. data/lib/ffi/clang/source_location.rb +2 -2
  35. data/lib/ffi/clang/source_range.rb +16 -3
  36. data/lib/ffi/clang/token.rb +4 -4
  37. data/lib/ffi/clang/translation_unit.rb +5 -5
  38. data/lib/ffi/clang/type.rb +0 -14
  39. data/lib/ffi/clang/version.rb +2 -2
  40. data/spec/{clang → ffi/clang}/code_completion_spec.rb +6 -6
  41. data/spec/{clang → ffi/clang}/comment_spec.rb +22 -39
  42. data/spec/{clang → ffi/clang}/compilation_database_spec.rb +8 -10
  43. data/spec/{clang → ffi/clang}/cursor_spec.rb +89 -97
  44. data/spec/{clang → ffi/clang}/diagnostic_spec.rb +9 -10
  45. data/spec/{clang → ffi/clang}/file_spec.rb +3 -5
  46. data/spec/{fixtures → ffi/clang/fixtures}/a.c +0 -0
  47. data/spec/{fixtures → ffi/clang/fixtures}/canonical.c +0 -0
  48. data/spec/ffi/clang/fixtures/class.cpp +8 -0
  49. data/spec/{fixtures → ffi/clang/fixtures}/compile_commands.json +0 -0
  50. data/spec/{fixtures → ffi/clang/fixtures}/completion.cxx +0 -0
  51. data/spec/{fixtures → ffi/clang/fixtures}/docs.c +0 -0
  52. data/spec/{fixtures → ffi/clang/fixtures}/docs.cc +0 -0
  53. data/spec/{fixtures → ffi/clang/fixtures}/docs.h +0 -0
  54. data/spec/{fixtures → ffi/clang/fixtures}/list.c +0 -0
  55. data/spec/{fixtures → ffi/clang/fixtures}/location1.c +0 -0
  56. data/spec/ffi/clang/fixtures/simple.ast +0 -0
  57. data/spec/{fixtures → ffi/clang/fixtures}/simple.c +0 -0
  58. data/spec/{fixtures → ffi/clang/fixtures}/test.cxx +0 -0
  59. data/spec/{clang → ffi/clang}/index_spec.rb +17 -14
  60. data/spec/{clang → ffi/clang}/source_location_spec.rb +12 -14
  61. data/spec/{clang → ffi/clang}/source_range_spec.rb +12 -14
  62. data/spec/{clang → ffi/clang}/token_spec.rb +6 -8
  63. data/spec/{clang → ffi/clang}/translation_unit_spec.rb +28 -30
  64. data/spec/{clang → ffi/clang}/type_spec.rb +17 -33
  65. data/spec/ffi/clang/version_spec.rb +28 -0
  66. data/spec/spec_helper.rb +11 -37
  67. metadata +61 -55
  68. data/lib/ffi/clang/utils.rb +0 -89
  69. data/spec/clang/utils_spec.rb +0 -60
@@ -18,14 +18,12 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'spec_helper'
22
-
23
21
  describe CodeCompletion do
24
22
  let(:filename) { fixture_path("completion.cxx") }
25
- let(:tu) { Index.new.parse_translation_unit(filename) }
23
+ let(:translation_unit) { Index.new.parse_translation_unit(filename) }
26
24
  let(:line) { 7 }
27
25
  let(:column) { 6 }
28
- let(:results) { tu.code_complete(filename, line, column) }
26
+ let(:results) { translation_unit.code_complete(filename, line, column) }
29
27
 
30
28
  describe "self.default_code_completion_options" do
31
29
  let(:options) { FFI::Clang::CodeCompletion.default_code_completion_options }
@@ -101,8 +99,10 @@ describe CodeCompletion do
101
99
  it "#sort!" do
102
100
  results.sort!
103
101
 
104
- # may be sorted with typed_text kind, first result will start with 'a'
105
- expect(results.results.first.string.chunks.select{|x| x[:kind] == :typed_text}.first[:text]).to be =~ /^a/
102
+ possibilities = results.first.string.chunks.select{|x| x[:kind] == :typed_text}.collect{|chunk| chunk[:text]}
103
+
104
+ # may be sorted with typed_text kind, first result will start with 'a'.. not necessarily
105
+ expect(possibilities).to be == possibilities.sort
106
106
  end
107
107
  end
108
108
 
@@ -19,59 +19,56 @@
19
19
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
20
  # THE SOFTWARE.
21
21
 
22
- require 'spec_helper'
23
-
24
22
  describe Comment do
25
23
  let(:cursor) { Index.new.parse_translation_unit(fixture_path("docs.cc")).cursor }
26
24
  let (:comment) { find_first(cursor, :cursor_function).comment }
27
25
 
28
26
  it "can be obtained from a cursor" do
29
- comment.should be_kind_of(Comment)
30
- comment.should be_kind_of(FullComment)
31
- comment.kind.should equal(:comment_full)
27
+ expect(comment).to be_kind_of(Comment)
28
+ expect(comment).to be_kind_of(FullComment)
29
+ expect(comment.kind).to equal(:comment_full)
32
30
  end
33
31
 
34
32
  it "can parse the brief description" do
35
33
  para = comment.child
36
- para.kind.should equal(:comment_paragraph)
37
- para.should be_kind_of(ParagraphComment)
34
+ expect(para.kind).to equal(:comment_paragraph)
35
+ expect(para).to be_kind_of(ParagraphComment)
38
36
  text = para.child
39
- text.kind.should equal(:comment_text)
40
- text.should be_kind_of(TextComment)
41
- text.text.strip.should eq("Short explanation")
37
+ expect(text.kind).to equal(:comment_text)
38
+ expect(text).to be_kind_of(TextComment)
39
+ expect(text.text.strip).to eq("Short explanation")
42
40
  end
43
41
 
44
42
  it "can parse the longer description" do
45
43
  para = comment.child(1)
46
- para.kind.should equal(:comment_paragraph)
47
- para.num_children.should equal(2)
48
- text = para.child
44
+ expect(para.kind).to equal(:comment_paragraph)
45
+ expect(para.num_children).to equal(2)
49
46
 
50
47
  lines = (0..para.num_children-1).map do |i|
51
48
  para.child(i).text
52
49
  end
53
50
 
54
- lines.should eq([" This is a longer explanation",
51
+ expect(lines).to eq([" This is a longer explanation",
55
52
  " that spans multiple lines"])
56
53
  end
57
54
 
58
55
  it "has working helpers" do
59
- comment.num_children.should equal(8)
56
+ expect(comment.num_children).to equal(8)
60
57
 
61
58
  para = comment.child(1)
62
- para.text.should eq(" This is a longer explanation\n that spans multiple lines")
59
+ expect(para.text).to eq(" This is a longer explanation\n that spans multiple lines")
63
60
  end
64
61
 
65
62
  it "understands params" do
66
63
  [['input', " some input\n "], ['flags', " some flags\n "]].each_with_index do |v, child_idx|
67
64
  param = comment.child(3 + child_idx)
68
- param.should be_kind_of(ParamCommandComment)
65
+ expect(param).to be_kind_of(ParamCommandComment)
69
66
 
70
- param.valid_index?.should == true
71
- param.index.should equal(child_idx)
72
- param.name.should eq(v[0])
73
- param.child.text.should eq v[1]
74
- param.comment.should eq v[1]
67
+ expect(param.valid_index?).to be_truthy
68
+ expect(param.index).to be == child_idx
69
+ expect(param.name).to be == v[0]
70
+ expect(param.child.text).to be == v[1]
71
+ expect(param.comment).to be == v[1]
75
72
  end
76
73
  end
77
74
 
@@ -135,15 +132,10 @@ describe Comment do
135
132
  end
136
133
 
137
134
  describe "#text" do
138
- it "returns HTML tag as string", from_3_4: true do
135
+ it "returns HTML tag as string" do
139
136
  expect(html_start_tag_comments[0].text.strip).to eq('<br/>')
140
137
  expect(html_start_tag_comments[1].text.strip).to eq('<a href="http://example.org/">')
141
138
  end
142
-
143
- it "returuns empty string", upto_3_3: true do
144
- expect(html_start_tag_comments[0].text.strip).to eq('')
145
- expect(html_start_tag_comments[1].text.strip).to eq('')
146
- end
147
139
  end
148
140
 
149
141
  describe "#self_closing?" do
@@ -193,13 +185,9 @@ describe Comment do
193
185
  end
194
186
 
195
187
  describe "#text" do
196
- it "returns HTML tag as string", from_3_4: true do
188
+ it "returns HTML tag as string" do
197
189
  expect(html_end_tag_comment.text.strip).to eq('</a>')
198
190
  end
199
-
200
- it "returuns empty string", upto_3_3: true do
201
- expect(html_end_tag_comment.text.strip).to eq('')
202
- end
203
191
  end
204
192
  end
205
193
 
@@ -214,15 +202,10 @@ describe Comment do
214
202
  end
215
203
 
216
204
  describe "#to_html" do
217
- it "converts a given full parsed comment to an HTML fragment", from_3_4: true do
205
+ it "converts a given full parsed comment to an HTML fragment" do
218
206
  expect(comment.to_html).to be_kind_of(String)
219
207
  expect(comment.to_html).to eq('<p class="para-brief"> this is a function.</p>')
220
208
  end
221
-
222
- it "converts a given full parsed comment to an HTML fragment", upto_3_3: true do
223
- expect(comment.to_html).to be_kind_of(String)
224
- expect(comment.to_html).to eq('<p class="para-brief"> this is a function. </p>')
225
- end
226
209
  end
227
210
 
228
211
  describe "#to_xml" do
@@ -18,8 +18,6 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'spec_helper'
22
-
23
21
  describe CompilationDatabase do
24
22
  let(:dirpath) { fixture_path('') }
25
23
  let(:cdb) { CompilationDatabase.new(dirpath) }
@@ -35,7 +33,7 @@ describe CompilationDatabase do
35
33
 
36
34
  it "calls compilation_database_dispose on GC" do
37
35
  cdb.autorelease = false
38
- expect(Lib).to receive(:compilation_database_dispose).with(cdb).once
36
+ # expect(Lib).to receive(:compilation_database_dispose).with(cdb).once
39
37
  expect{cdb.free}.not_to raise_error
40
38
  end
41
39
 
@@ -53,7 +51,7 @@ describe CompilationDatabase do
53
51
  end
54
52
  end
55
53
 
56
- describe '#all_compile_commands', from_3_3: true do
54
+ describe '#all_compile_commands' do
57
55
  it "returns all compile commands in the database" do
58
56
  expect(cdb.all_compile_commands).to be_kind_of(CompilationDatabase::CompileCommands)
59
57
  expect(cdb.all_compile_commands.size).to eq(3)
@@ -65,7 +63,7 @@ describe CompilationDatabase do
65
63
 
66
64
  it "calls compile_commands_dispose on GC" do
67
65
  commands.autorelease = false
68
- expect(Lib).to receive(:compile_commands_dispose).with(commands).once
66
+ # expect(Lib).to receive(:compile_commands_dispose).with(commands).once
69
67
  expect{commands.free}.not_to raise_error
70
68
  end
71
69
 
@@ -75,7 +73,7 @@ describe CompilationDatabase do
75
73
  expect(commands.size).to eq(1)
76
74
  end
77
75
 
78
- it "returns the number of CompileCommand", from_3_3: true do
76
+ it "returns the number of CompileCommand" do
79
77
  expect(cdb.all_compile_commands.size).to eq(3)
80
78
  end
81
79
  end
@@ -135,7 +133,7 @@ describe CompilationDatabase do
135
133
  end
136
134
  end
137
135
 
138
- describe '#num_mapped_sources', from_3_4: true do
136
+ describe '#num_mapped_sources' do
139
137
  # TODO: a case which has mapped sources
140
138
 
141
139
  it "returns the number of source mappings" do
@@ -144,7 +142,7 @@ describe CompilationDatabase do
144
142
  end
145
143
  end
146
144
 
147
- describe '#mapped_source_path', from_3_4: true do
145
+ describe '#mapped_source_path' do
148
146
  it "returns the I'th mapped source path" do
149
147
  # TODO: a case which returns real source path
150
148
  # expect(cmd.mapped_source_path(0)).to be_kind_of(String)
@@ -155,7 +153,7 @@ describe CompilationDatabase do
155
153
  end
156
154
  end
157
155
 
158
- describe '#mapped_source_content', from_3_4: true do
156
+ describe '#mapped_source_content' do
159
157
  it "returns the I'th mapped source content" do
160
158
  # TODO: a case which returns real source path
161
159
  # expect(cmd.mapped_source_content(0)).to be_kind_of(String)
@@ -166,7 +164,7 @@ describe CompilationDatabase do
166
164
  end
167
165
  end
168
166
 
169
- describe '#mapped_sources', from_3_4: true do
167
+ describe '#mapped_sources' do
170
168
  # TODO: a case which has mapped sources
171
169
 
172
170
  it "returns all mapped sources as Array" do
@@ -2,14 +2,14 @@
2
2
  # Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
3
  # Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
4
4
  # Copyright, 2014, by Masahiro Sano.
5
- #
5
+ #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
8
8
  # in the Software without restriction, including without limitation the rights
9
9
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
10
  # copies of the Software, and to permit persons to whom the Software is
11
11
  # furnished to do so, subject to the following conditions:
12
- #
12
+ #
13
13
  # The above copyright notice and this permission notice shall be included in
14
14
  # all copies or substantial portions of the Software.
15
15
  #
@@ -21,7 +21,20 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
 
24
- require 'spec_helper'
24
+ describe "Function Call Cursors" do
25
+ let(:translation_unit) {Index.new.parse_translation_unit(fixture_path("class.cpp"))}
26
+ let(:cursor) {translation_unit.cursor}
27
+ let(:call) {find_first(cursor, :cursor_call_expr)}
28
+
29
+ it "should parse correctly" do
30
+ expect(translation_unit.diagnostics).to be_empty
31
+ end
32
+
33
+ it "should find a method call" do
34
+ call.should_not be_nil
35
+ end
36
+ end
37
+
25
38
 
26
39
  describe Cursor do
27
40
  let(:cursor) { Index.new.parse_translation_unit(fixture_path("list.c")).cursor }
@@ -30,15 +43,15 @@ describe Cursor do
30
43
  let(:cursor_pp) { Index.new.parse_translation_unit(fixture_path("docs.c"),[],[],{detailed_preprocessing_record: true}).cursor }
31
44
 
32
45
  it "can be obtained from a translation unit" do
33
- cursor.should be_kind_of(Cursor)
34
- cursor.kind.should equal(:cursor_translation_unit)
35
- cursor.null?.should equal(false)
36
- cursor.translation_unit?.should equal(true)
46
+ expect(cursor).to be_kind_of(Cursor)
47
+ expect(cursor.kind).to equal(:cursor_translation_unit)
48
+ expect(cursor.null?).to equal(false)
49
+ expect(cursor.translation_unit?).to equal(true)
37
50
  end
38
51
 
39
52
  it "returns the source location of the cursor" do
40
53
  location = cursor.location
41
- location.should be_kind_of(SourceLocation)
54
+ expect(location).to be_kind_of(SourceLocation)
42
55
  end
43
56
 
44
57
  describe '#extent' do
@@ -52,20 +65,15 @@ describe Cursor do
52
65
  expect(extent.start.line).to equal(1)
53
66
  end
54
67
 
55
- it 'has filename and posion at end point', from_3_4: true do
68
+ it 'has filename and posion at end point' do
56
69
  expect(extent.end.file).to eq(fixture_path("list.c"))
57
70
  expect(extent.end.line).to equal(12)
58
71
  end
59
-
60
- it 'has filename and posion at end point', upto_3_3: true do
61
- expect(extent.end.file).to eq(fixture_path("list.c"))
62
- expect(extent.end.line).to equal(11)
63
- end
64
72
  end
65
73
 
66
74
  it "returns the path of the translation unit for the translation unit cursor" do
67
- cursor.display_name.should eq(fixture_path("list.c"))
68
- cursor.spelling.should eq(fixture_path("list.c"))
75
+ expect(cursor.display_name).to eq(fixture_path("list.c"))
76
+ expect(cursor.spelling).to eq(fixture_path("list.c"))
69
77
  end
70
78
 
71
79
  it "allows us to visit its children" do
@@ -74,29 +82,29 @@ describe Cursor do
74
82
  counter += 1
75
83
  :recurse
76
84
  end
77
- counter.should_not equal(0)
85
+ expect(counter).not_to equal(0)
78
86
  end
79
87
 
80
88
  describe "Null Cursor" do
81
89
  it "can be a null cursor" do
82
- Cursor.null_cursor.should be_kind_of(Cursor)
83
- Cursor.null_cursor.kind.should equal(:cursor_invalid_file)
90
+ expect(Cursor.null_cursor).to be_kind_of(Cursor)
91
+ expect(Cursor.null_cursor.kind).to equal(:cursor_invalid_file)
84
92
  end
85
93
 
86
94
  it "is null?" do
87
- Cursor.null_cursor.null?.should equal(true)
95
+ expect(Cursor.null_cursor.null?).to equal(true)
88
96
  end
89
97
 
90
98
  it "is invalid?" do
91
- Cursor.null_cursor.invalid?.should equal(true)
99
+ expect(Cursor.null_cursor.invalid?).to equal(true)
92
100
  end
93
101
 
94
102
  it "compares as equal to another null cursor instance" do
95
- Cursor.null_cursor.should eq(Cursor.null_cursor)
103
+ expect(Cursor.null_cursor).to eq(Cursor.null_cursor)
96
104
  end
97
105
 
98
106
  it "should not equal a Translation Unit cursor" do
99
- Cursor.null_cursor.should_not eq(cursor)
107
+ expect(Cursor.null_cursor).not_to eq(cursor)
100
108
  end
101
109
  end
102
110
 
@@ -104,23 +112,23 @@ describe Cursor do
104
112
  let (:func) { find_first(cursor, :cursor_function) }
105
113
 
106
114
  it "is not invalid?" do
107
- func.invalid?.should equal(false)
115
+ expect(func.invalid?).to equal(false)
108
116
  end
109
117
 
110
118
  it "can find the first function declaration" do
111
- func.should_not equal(nil)
112
- func.kind.should equal(:cursor_function)
119
+ expect(func).not_to equal(nil)
120
+ expect(func.kind).to equal(:cursor_function)
113
121
  end
114
122
 
115
123
  it "has an extent representing the bounds of the function" do
116
- func.extent.should be_kind_of(SourceRange)
117
- func.extent.start.line.should equal(5)
118
- func.extent.end.line.should equal(5)
124
+ expect(func.extent).to be_kind_of(SourceRange)
125
+ expect(func.extent.start.line).to equal(5)
126
+ expect(func.extent.end.line).to equal(5)
119
127
  end
120
128
 
121
129
  it "returns the name of the function" do
122
- func.spelling.should eq("sum")
123
- func.display_name.should eq("sum(union List *)")
130
+ expect(func.spelling).to eq("sum")
131
+ expect(func.display_name).to eq("sum(union List *)")
124
132
  end
125
133
  end
126
134
 
@@ -128,18 +136,18 @@ describe Cursor do
128
136
  let (:struct) { find_first(cursor, :cursor_struct) }
129
137
 
130
138
  it "can find the first struct" do
131
- struct.should_not equal(nil)
132
- struct.kind.should equal(:cursor_struct)
139
+ expect(struct).not_to equal(nil)
140
+ expect(struct.kind).to equal(:cursor_struct)
133
141
  end
134
142
 
135
143
  it "has an extent representing the bounds of the struct" do
136
- struct.extent.start.line.should equal(1)
137
- struct.extent.end.line.should equal(4)
144
+ expect(struct.extent.start.line).to equal(1)
145
+ expect(struct.extent.end.line).to equal(4)
138
146
  end
139
147
 
140
148
  it "returns the name of the struct" do
141
- struct.spelling.should eq("List")
142
- struct.display_name.should eq("List")
149
+ expect(struct.spelling).to eq("List")
150
+ expect(struct.display_name).to eq("List")
143
151
  end
144
152
 
145
153
  end
@@ -196,39 +204,27 @@ describe Cursor do
196
204
  let(:public_cursor) { find_matching(cursor_cxx) { |child, parent|
197
205
  child.kind == :cursor_field_decl and child.spelling == 'public_member_int' } }
198
206
 
199
- it 'checks access control level is public', from_3_3: true do
207
+ it 'checks access control level is public' do
200
208
  expect(public_cursor.public?).to be true
201
209
  end
202
-
203
- it 'returns false on clang 3.2', upto_3_2: true do
204
- expect(public_cursor.public?).to be false
205
- end
206
210
  end
207
211
 
208
212
  describe '#private?' do
209
213
  let(:private_cursor) { find_matching(cursor_cxx) { |child, parent|
210
214
  child.kind == :cursor_field_decl and child.spelling == 'private_member_int' } }
211
215
 
212
- it 'checks access control level is private', from_3_3: true do
216
+ it 'checks access control level is private' do
213
217
  expect(private_cursor.private?).to be true
214
218
  end
215
-
216
- it 'returns false on clang 3.2', upto_3_2: true do
217
- expect(private_cursor.private?).to be false
218
- end
219
219
  end
220
220
 
221
221
  describe '#protected?' do
222
222
  let(:protected_cursor) { find_matching(cursor_cxx) { |child, parent|
223
223
  child.kind == :cursor_field_decl and child.spelling == 'protected_member_int' } }
224
224
 
225
- it 'checks access control level is protected', from_3_3: true do
225
+ it 'checks access control level is protected' do
226
226
  expect(protected_cursor.protected?).to be true
227
227
  end
228
-
229
- it 'returns false on clang 3.2', upto_3_2: true do
230
- expect(protected_cursor.protected?).to be false
231
- end
232
228
  end
233
229
 
234
230
  describe '#preprocessing?' do
@@ -253,7 +249,7 @@ describe Cursor do
253
249
  child.kind == :cursor_cxx_base_specifier and parent.spelling == 'B' } }
254
250
 
255
251
  it 'checks cursor is virtual base' do
256
- virtual_base_cursor.virtual_base?.should equal true
252
+ expect(virtual_base_cursor.virtual_base?).to equal true
257
253
  end
258
254
  end
259
255
 
@@ -262,17 +258,17 @@ describe Cursor do
262
258
  child.kind == :cursor_cxx_method and child.spelling == 'func_a' } }
263
259
 
264
260
  it 'checks member function is virtual' do
265
- virtual_cursor.virtual?.should equal true
261
+ expect(virtual_cursor.virtual?).to equal true
266
262
  end
267
263
  end
268
264
 
269
- describe '#pure_virtual?', from_3_4: true do
265
+ describe '#pure_virtual?' do
270
266
  let(:pure_virtual_cursor) { find_matching(cursor_cxx) { |child, parent|
271
267
  child.kind == :cursor_cxx_method and
272
268
  child.spelling == 'func_a' and parent.spelling == 'A' } }
273
269
 
274
270
  it 'checks member function is purely virtual' do
275
- pure_virtual_cursor.pure_virtual?.should equal true
271
+ expect(pure_virtual_cursor.pure_virtual?).to equal true
276
272
  end
277
273
  end
278
274
 
@@ -281,7 +277,7 @@ describe Cursor do
281
277
  child.kind == :cursor_cxx_method and child.spelling == 'func_b' } }
282
278
 
283
279
  it 'checks cursor is static member function' do
284
- static_method_cursor.static?.should equal true
280
+ expect(static_method_cursor.static?).to equal true
285
281
  end
286
282
  end
287
283
 
@@ -290,7 +286,7 @@ describe Cursor do
290
286
  child.kind == :cursor_enum_constant_decl and child.spelling == 'EnumC' } }
291
287
 
292
288
  it 'returns enum value' do
293
- enum_value_cursor.enum_value.should equal 100
289
+ expect(enum_value_cursor.enum_value).to equal 100
294
290
  end
295
291
  end
296
292
 
@@ -305,7 +301,7 @@ describe Cursor do
305
301
 
306
302
  describe '#dynamic_call?' do
307
303
  let(:dynamic_call) { find_matching(cursor_cxx) { |child, parent|
308
- child.kind == :cursor_call_expr and child.spelling == 'func_a' and
304
+ child.kind == :cursor_call_expr and child.spelling == 'func_a' and
309
305
  child.semantic_parent.spelling == 'f_dynamic_call' } }
310
306
 
311
307
  it 'checks if the method call is dynamic' do
@@ -313,7 +309,7 @@ describe Cursor do
313
309
  end
314
310
  end
315
311
 
316
- describe '#specialized_template', from_3_3: true do # looks not working on 3.2
312
+ describe '#specialized_template' do # looks not working on 3.2
317
313
  let(:cursor_function) { find_matching(cursor_cxx) { |child, parent|
318
314
  child.kind == :cursor_function and child.spelling == 'func_overloaded' } }
319
315
 
@@ -327,13 +323,13 @@ describe Cursor do
327
323
  let (:structs) { find_all(cursor_canon, :cursor_struct) }
328
324
 
329
325
  it "mathes 3 cursors" do
330
- structs.size.should eq(3)
326
+ expect(structs.size).to eq(3)
331
327
  end
332
328
 
333
329
  it "refers the first cursor as canonical one" do
334
- structs[0].canonical.should eq(structs[0])
335
- structs[1].canonical.should eq(structs[0])
336
- structs[2].canonical.should eq(structs[0])
330
+ expect(structs[0].canonical).to eq(structs[0])
331
+ expect(structs[1].canonical).to eq(structs[0])
332
+ expect(structs[2].canonical).to eq(structs[0])
337
333
  end
338
334
  end
339
335
 
@@ -341,17 +337,17 @@ describe Cursor do
341
337
  let (:structs) { find_all(cursor_canon, :cursor_struct) }
342
338
 
343
339
  it "mathes 3 cursors" do
344
- structs.size.should eq(3)
340
+ expect(structs.size).to eq(3)
345
341
  end
346
342
 
347
343
  it "refers the third cursor as definition one" do
348
- structs[0].definition.should eq(structs[2])
349
- structs[1].definition.should eq(structs[2])
350
- structs[2].definition.should eq(structs[2])
344
+ expect(structs[0].definition).to eq(structs[2])
345
+ expect(structs[1].definition).to eq(structs[2])
346
+ expect(structs[2].definition).to eq(structs[2])
351
347
  end
352
348
  end
353
349
 
354
- describe '#template_kind', from_3_3: true do # looks not working on 3.2
350
+ describe '#template_kind' do # looks not working on 3.2
355
351
  let(:template) { find_matching(cursor_cxx) { |child, parent|
356
352
  child.kind == :cursor_function_template and child.spelling == 'func_overloaded' } }
357
353
 
@@ -365,12 +361,8 @@ describe Cursor do
365
361
  let(:access_specifier_cursor) { find_matching(cursor_cxx) { |child, parent|
366
362
  child.kind == :cursor_cxx_method and child.spelling == 'func_d' } }
367
363
 
368
- it 'returns access specifier symbol', from_3_3: true do
369
- access_specifier_cursor.access_specifier.should equal :private
370
- end
371
-
372
- it 'returns access specifier symbol(invalid, why?)', upto_3_2: true do
373
- access_specifier_cursor.access_specifier.should equal :invalid
364
+ it 'returns access specifier symbol' do
365
+ expect(access_specifier_cursor.access_specifier).to equal :private
374
366
  end
375
367
  end
376
368
 
@@ -379,11 +371,11 @@ describe Cursor do
379
371
  let(:cxx_language_cursor) { find_matching(cursor_cxx) { |c, p| c.kind == :cursor_struct } }
380
372
 
381
373
  it 'returns :c if the cursor language is C' do
382
- c_language_cursor.language.should equal :c
374
+ expect(c_language_cursor.language).to equal :c
383
375
  end
384
376
 
385
377
  it 'returns :c_plus_plus if the cursor language is C++' do
386
- cxx_language_cursor.language.should equal :c_plus_plus
378
+ expect(cxx_language_cursor.language).to equal :c_plus_plus
387
379
  end
388
380
  end
389
381
 
@@ -391,12 +383,12 @@ describe Cursor do
391
383
  let (:struct) { find_first(cursor, :cursor_struct) }
392
384
 
393
385
  it "can find the first struct" do
394
- struct.should_not equal(nil)
386
+ expect(struct).not_to equal(nil)
395
387
  end
396
388
 
397
389
  it "returns the translation unit that a cursor originated from" do
398
- struct.translation_unit.should be_kind_of(TranslationUnit)
399
- struct.translation_unit.spelling.should eq(fixture_path("list.c"))
390
+ expect(struct.translation_unit).to be_kind_of(TranslationUnit)
391
+ expect(struct.translation_unit.spelling).to eq(fixture_path("list.c"))
400
392
  end
401
393
  end
402
394
 
@@ -405,11 +397,11 @@ describe Cursor do
405
397
  let (:func) { find_first(cursor, :cursor_function) }
406
398
 
407
399
  it "returns :external if the cursor is non-static function" do
408
- func.linkage.should equal :external
400
+ expect(func.linkage).to equal :external
409
401
  end
410
402
 
411
403
  it "returns :invalid if the cursor does not have linkage" do
412
- ref.linkage.should equal :invalid
404
+ expect(ref.linkage).to equal :invalid
413
405
  end
414
406
  end
415
407
 
@@ -418,7 +410,7 @@ describe Cursor do
418
410
  child.kind == :cursor_cxx_method and child.spelling == 'func_d' and parent.spelling != 'D' } }
419
411
 
420
412
  it 'returns base class as semantic parent' do
421
- parent.semantic_parent.spelling.should eq('D')
413
+ expect(parent.semantic_parent.spelling).to eq('D')
422
414
  end
423
415
  end
424
416
 
@@ -427,7 +419,7 @@ describe Cursor do
427
419
  child.kind == :cursor_cxx_method and child.spelling == 'func_d' and parent.spelling != 'D' } }
428
420
 
429
421
  it 'returns translation unit as lexical parent' do
430
- parent.lexical_parent.kind.should eq(:cursor_translation_unit)
422
+ expect(parent.lexical_parent.kind).to eq(:cursor_translation_unit)
431
423
  end
432
424
  end
433
425
 
@@ -439,7 +431,7 @@ describe Cursor do
439
431
  let (:struct) { find_all(cursor_canon, :cursor_struct).at(2) }
440
432
 
441
433
  it "checks cursor is a definition" do
442
- struct.definition?.should be true
434
+ expect(struct.definition?).to be true
443
435
  end
444
436
  end
445
437
 
@@ -447,16 +439,16 @@ describe Cursor do
447
439
  let (:func) { find_first(cursor, :cursor_function) }
448
440
 
449
441
  it "returns something in string" do
450
- func.usr.should be_kind_of(String)
442
+ expect(func.usr).to be_kind_of(String)
451
443
  end
452
444
  end
453
445
 
454
- describe '#variadic?', from_3_3: true do
446
+ describe '#variadic?' do
455
447
  let(:func) { find_matching(cursor_cxx) { |child, parent|
456
448
  child.kind == :cursor_function and child.spelling == 'f_variadic' } }
457
449
 
458
450
  it "checks cursor is a variadic function" do
459
- func.variadic?.should be true
451
+ expect(func.variadic?).to be true
460
452
  end
461
453
  end
462
454
 
@@ -467,7 +459,7 @@ describe Cursor do
467
459
  child.kind == :cursor_type_ref and child.spelling == 'struct A' } }
468
460
 
469
461
  it "returns a cursor that this cursor references" do
470
- ref.referenced.should eq(struct)
462
+ expect(ref.referenced).to eq(struct)
471
463
  end
472
464
 
473
465
  end
@@ -476,7 +468,7 @@ describe Cursor do
476
468
  let (:func) { find_first(cursor, :cursor_function) }
477
469
 
478
470
  it "computes hash for the cursor" do
479
- func.hash.should be_kind_of(Fixnum)
471
+ expect(func.hash).to be_kind_of(Fixnum)
480
472
  end
481
473
  end
482
474
 
@@ -484,7 +476,7 @@ describe Cursor do
484
476
  let (:func) { find_first(cursor, :cursor_function) }
485
477
 
486
478
  it "returns :available for the cursor availability" do
487
- func.availability.should equal(:available)
479
+ expect(func.availability).to equal(:available)
488
480
  end
489
481
  end
490
482
 
@@ -492,8 +484,8 @@ describe Cursor do
492
484
  let (:field) { find_first(cursor, :cursor_field_decl) }
493
485
 
494
486
  it "returns type for the cursor" do
495
- field.type.should be_kind_of(Type)
496
- field.type.kind.should equal(:type_int)
487
+ expect(field.type).to be_kind_of(Type)
488
+ expect(field.type.kind).to equal(:type_int)
497
489
  end
498
490
  end
499
491
 
@@ -501,12 +493,12 @@ describe Cursor do
501
493
  let (:typedef) { find_first(cursor_cxx, :cursor_typedef_decl) }
502
494
 
503
495
  it "returns type that the cursor type is underlying" do
504
- typedef.underlying_type.should be_kind_of(Type)
505
- typedef.underlying_type.kind.should equal(:type_pointer)
496
+ expect(typedef.underlying_type).to be_kind_of(Type)
497
+ expect(typedef.underlying_type.kind).to equal(:type_pointer)
506
498
  end
507
499
  end
508
500
 
509
- describe '#bitfield?', from_3_3: true do
501
+ describe '#bitfield?' do
510
502
  let(:bitfield) { find_matching(cursor_cxx) { |child, parent|
511
503
  child.kind == :cursor_field_decl and child.spelling == 'bit_field_a' } }
512
504
  let(:non_bitfield) { find_matching(cursor_cxx) { |child, parent|
@@ -521,7 +513,7 @@ describe Cursor do
521
513
  end
522
514
  end
523
515
 
524
- describe '#bitwidth', from_3_3: true do
516
+ describe '#bitwidth' do
525
517
  let(:bitfield) { find_matching(cursor_cxx) { |child, parent|
526
518
  child.kind == :cursor_field_decl and child.spelling == 'bit_field_a' } }
527
519
  let(:non_bitfield) { find_matching(cursor_cxx) { |child, parent|