Skip to content

Commit c6696ad

Browse files
committed
Ruby: Add test case that would make old module resolution library diverge
1 parent 2187994 commit c6696ad

File tree

8 files changed

+203
-2
lines changed

8 files changed

+203
-2
lines changed

ruby/ql/test/library-tests/modules/ancestors.expected

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ calls.rb:
1313
# 97| Object
1414
#-----| include -> Kernel
1515
#-----| super -> BasicObject
16+
#-----| prepend -> A
1617

1718
# 106| Array
1819
#-----| super -> Object
@@ -64,6 +65,8 @@ calls.rb:
6465

6566
# 150| A
6667
#-----| super -> S
68+
#-----| super -> B
69+
#-----| prepend -> A::B
6770

6871
# 155| B
6972
#-----| super -> S
@@ -139,6 +142,14 @@ modules.rb:
139142

140143
# 71| Test::Foo2::Foo2
141144

145+
modules_rec.rb:
146+
# 1| B::A
147+
#-----| super -> Object
148+
149+
# 4| A::B
150+
#-----| super -> Object
151+
152+
modules.rb:
142153
# 108| MM::MM
143154

144155
# 49| Foo::Bar::ClassInAnotherDefinitionOfFooBar

ruby/ql/test/library-tests/modules/callgraph.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ getTarget
7575
| modules.rb:90:24:90:36 | call to prepend | calls.rb:93:5:93:20 | prepend |
7676
| modules.rb:96:3:96:14 | call to include | calls.rb:92:5:92:20 | include |
7777
| modules.rb:102:3:102:16 | call to prepend | calls.rb:93:5:93:20 | prepend |
78+
| modules_rec.rb:8:3:8:11 | call to prepend | calls.rb:93:5:93:20 | prepend |
79+
| modules_rec.rb:11:1:11:9 | call to prepend | calls.rb:93:5:93:20 | prepend |
7880
| private.rb:2:3:3:5 | call to private | calls.rb:94:5:94:20 | private |
7981
| private.rb:10:3:10:19 | call to private | calls.rb:94:5:94:20 | private |
8082
| private.rb:12:3:12:9 | call to private | calls.rb:94:5:94:20 | private |

ruby/ql/test/library-tests/modules/methods.expected

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ lookupMethod
5757
| calls.rb:29:1:44:3 | C | optional_arg | calls.rb:62:1:65:3 | optional_arg |
5858
| calls.rb:29:1:44:3 | C | private_on_main | calls.rb:164:1:165:3 | private_on_main |
5959
| calls.rb:29:1:44:3 | C | puts | calls.rb:87:5:87:17 | puts |
60+
| calls.rb:29:1:44:3 | C | to_s | calls.rb:151:5:152:7 | to_s |
6061
| calls.rb:51:1:55:3 | D | baz | calls.rb:52:5:54:7 | baz |
6162
| calls.rb:51:1:55:3 | D | call_block | calls.rb:67:1:69:3 | call_block |
6263
| calls.rb:51:1:55:3 | D | foo | calls.rb:1:1:3:3 | foo |
@@ -68,10 +69,12 @@ lookupMethod
6869
| calls.rb:51:1:55:3 | D | optional_arg | calls.rb:62:1:65:3 | optional_arg |
6970
| calls.rb:51:1:55:3 | D | private_on_main | calls.rb:164:1:165:3 | private_on_main |
7071
| calls.rb:51:1:55:3 | D | puts | calls.rb:87:5:87:17 | puts |
72+
| calls.rb:51:1:55:3 | D | to_s | calls.rb:151:5:152:7 | to_s |
7173
| calls.rb:77:1:80:3 | Integer | abs | calls.rb:79:5:79:16 | abs |
7274
| calls.rb:77:1:80:3 | Integer | bit_length | calls.rb:78:5:78:23 | bit_length |
7375
| calls.rb:77:1:80:3 | Integer | new | calls.rb:99:5:99:16 | new |
7476
| calls.rb:77:1:80:3 | Integer | puts | calls.rb:87:5:87:17 | puts |
77+
| calls.rb:77:1:80:3 | Integer | to_s | calls.rb:151:5:152:7 | to_s |
7578
| calls.rb:82:1:84:3 | String | call_block | calls.rb:67:1:69:3 | call_block |
7679
| calls.rb:82:1:84:3 | String | capitalize | calls.rb:83:5:83:23 | capitalize |
7780
| calls.rb:82:1:84:3 | String | foo | calls.rb:1:1:3:3 | foo |
@@ -82,6 +85,7 @@ lookupMethod
8285
| calls.rb:82:1:84:3 | String | optional_arg | calls.rb:62:1:65:3 | optional_arg |
8386
| calls.rb:82:1:84:3 | String | private_on_main | calls.rb:164:1:165:3 | private_on_main |
8487
| calls.rb:82:1:84:3 | String | puts | calls.rb:87:5:87:17 | puts |
88+
| calls.rb:82:1:84:3 | String | to_s | calls.rb:151:5:152:7 | to_s |
8589
| calls.rb:86:1:88:3 | Kernel | puts | calls.rb:87:5:87:17 | puts |
8690
| calls.rb:90:1:95:3 | Module | call_block | calls.rb:67:1:69:3 | call_block |
8791
| calls.rb:90:1:95:3 | Module | foo | calls.rb:1:1:3:3 | foo |
@@ -96,6 +100,7 @@ lookupMethod
96100
| calls.rb:90:1:95:3 | Module | private | calls.rb:94:5:94:20 | private |
97101
| calls.rb:90:1:95:3 | Module | private_on_main | calls.rb:164:1:165:3 | private_on_main |
98102
| calls.rb:90:1:95:3 | Module | puts | calls.rb:87:5:87:17 | puts |
103+
| calls.rb:90:1:95:3 | Module | to_s | calls.rb:151:5:152:7 | to_s |
99104
| calls.rb:97:1:100:3 | Object | call_block | calls.rb:67:1:69:3 | call_block |
100105
| calls.rb:97:1:100:3 | Object | foo | calls.rb:1:1:3:3 | foo |
101106
| calls.rb:97:1:100:3 | Object | foo | calls.rb:71:1:75:3 | foo |
@@ -106,6 +111,7 @@ lookupMethod
106111
| calls.rb:97:1:100:3 | Object | private_on_main | calls.rb:164:1:165:3 | private_on_main |
107112
| calls.rb:97:1:100:3 | Object | private_on_main | private.rb:31:1:32:3 | private_on_main |
108113
| calls.rb:97:1:100:3 | Object | puts | calls.rb:87:5:87:17 | puts |
114+
| calls.rb:97:1:100:3 | Object | to_s | calls.rb:151:5:152:7 | to_s |
109115
| calls.rb:102:1:104:3 | Hash | [] | calls.rb:103:5:103:15 | [] |
110116
| calls.rb:102:1:104:3 | Hash | call_block | calls.rb:67:1:69:3 | call_block |
111117
| calls.rb:102:1:104:3 | Hash | foo | calls.rb:1:1:3:3 | foo |
@@ -116,6 +122,7 @@ lookupMethod
116122
| calls.rb:102:1:104:3 | Hash | optional_arg | calls.rb:62:1:65:3 | optional_arg |
117123
| calls.rb:102:1:104:3 | Hash | private_on_main | calls.rb:164:1:165:3 | private_on_main |
118124
| calls.rb:102:1:104:3 | Hash | puts | calls.rb:87:5:87:17 | puts |
125+
| calls.rb:102:1:104:3 | Hash | to_s | calls.rb:151:5:152:7 | to_s |
119126
| calls.rb:106:1:117:3 | Array | [] | calls.rb:107:3:107:13 | [] |
120127
| calls.rb:106:1:117:3 | Array | call_block | calls.rb:67:1:69:3 | call_block |
121128
| calls.rb:106:1:117:3 | Array | foo | calls.rb:1:1:3:3 | foo |
@@ -128,6 +135,7 @@ lookupMethod
128135
| calls.rb:106:1:117:3 | Array | optional_arg | calls.rb:62:1:65:3 | optional_arg |
129136
| calls.rb:106:1:117:3 | Array | private_on_main | calls.rb:164:1:165:3 | private_on_main |
130137
| calls.rb:106:1:117:3 | Array | puts | calls.rb:87:5:87:17 | puts |
138+
| calls.rb:106:1:117:3 | Array | to_s | calls.rb:151:5:152:7 | to_s |
131139
| calls.rb:144:1:148:3 | S | call_block | calls.rb:67:1:69:3 | call_block |
132140
| calls.rb:144:1:148:3 | S | foo | calls.rb:1:1:3:3 | foo |
133141
| calls.rb:144:1:148:3 | S | foo | calls.rb:71:1:75:3 | foo |
@@ -138,6 +146,7 @@ lookupMethod
138146
| calls.rb:144:1:148:3 | S | private_on_main | calls.rb:164:1:165:3 | private_on_main |
139147
| calls.rb:144:1:148:3 | S | puts | calls.rb:87:5:87:17 | puts |
140148
| calls.rb:144:1:148:3 | S | s_method | calls.rb:145:5:147:7 | s_method |
149+
| calls.rb:144:1:148:3 | S | to_s | calls.rb:151:5:152:7 | to_s |
141150
| calls.rb:150:1:153:3 | A | call_block | calls.rb:67:1:69:3 | call_block |
142151
| calls.rb:150:1:153:3 | A | foo | calls.rb:1:1:3:3 | foo |
143152
| calls.rb:150:1:153:3 | A | foo | calls.rb:71:1:75:3 | foo |
@@ -166,63 +175,89 @@ lookupMethod
166175
| file://:0:0:0:0 | Class | prepend | calls.rb:93:5:93:20 | prepend |
167176
| file://:0:0:0:0 | Class | private | calls.rb:94:5:94:20 | private |
168177
| file://:0:0:0:0 | Class | puts | calls.rb:87:5:87:17 | puts |
178+
| file://:0:0:0:0 | Class | to_s | calls.rb:151:5:152:7 | to_s |
169179
| file://:0:0:0:0 | Complex | new | calls.rb:99:5:99:16 | new |
170180
| file://:0:0:0:0 | Complex | puts | calls.rb:87:5:87:17 | puts |
181+
| file://:0:0:0:0 | Complex | to_s | calls.rb:151:5:152:7 | to_s |
171182
| file://:0:0:0:0 | FalseClass | new | calls.rb:99:5:99:16 | new |
172183
| file://:0:0:0:0 | FalseClass | puts | calls.rb:87:5:87:17 | puts |
184+
| file://:0:0:0:0 | FalseClass | to_s | calls.rb:151:5:152:7 | to_s |
173185
| file://:0:0:0:0 | Float | new | calls.rb:99:5:99:16 | new |
174186
| file://:0:0:0:0 | Float | puts | calls.rb:87:5:87:17 | puts |
187+
| file://:0:0:0:0 | Float | to_s | calls.rb:151:5:152:7 | to_s |
175188
| file://:0:0:0:0 | NilClass | new | calls.rb:99:5:99:16 | new |
176189
| file://:0:0:0:0 | NilClass | puts | calls.rb:87:5:87:17 | puts |
190+
| file://:0:0:0:0 | NilClass | to_s | calls.rb:151:5:152:7 | to_s |
177191
| file://:0:0:0:0 | Numeric | new | calls.rb:99:5:99:16 | new |
178192
| file://:0:0:0:0 | Numeric | puts | calls.rb:87:5:87:17 | puts |
193+
| file://:0:0:0:0 | Numeric | to_s | calls.rb:151:5:152:7 | to_s |
179194
| file://:0:0:0:0 | Rational | new | calls.rb:99:5:99:16 | new |
180195
| file://:0:0:0:0 | Rational | puts | calls.rb:87:5:87:17 | puts |
196+
| file://:0:0:0:0 | Rational | to_s | calls.rb:151:5:152:7 | to_s |
181197
| file://:0:0:0:0 | TrueClass | new | calls.rb:99:5:99:16 | new |
182198
| file://:0:0:0:0 | TrueClass | puts | calls.rb:87:5:87:17 | puts |
199+
| file://:0:0:0:0 | TrueClass | to_s | calls.rb:151:5:152:7 | to_s |
183200
| hello.rb:1:1:8:3 | EnglishWords | hello | hello.rb:2:5:4:7 | hello |
184201
| hello.rb:1:1:8:3 | EnglishWords | world | hello.rb:5:5:7:7 | world |
185202
| hello.rb:11:1:16:3 | Greeting | hello | hello.rb:2:5:4:7 | hello |
186203
| hello.rb:11:1:16:3 | Greeting | message | hello.rb:13:5:15:7 | message |
187204
| hello.rb:11:1:16:3 | Greeting | new | calls.rb:99:5:99:16 | new |
188205
| hello.rb:11:1:16:3 | Greeting | puts | calls.rb:87:5:87:17 | puts |
206+
| hello.rb:11:1:16:3 | Greeting | to_s | calls.rb:151:5:152:7 | to_s |
189207
| hello.rb:11:1:16:3 | Greeting | world | hello.rb:5:5:7:7 | world |
190208
| hello.rb:18:1:22:3 | HelloWorld | hello | hello.rb:2:5:4:7 | hello |
191209
| hello.rb:18:1:22:3 | HelloWorld | message | hello.rb:19:5:21:7 | message |
192210
| hello.rb:18:1:22:3 | HelloWorld | new | calls.rb:99:5:99:16 | new |
193211
| hello.rb:18:1:22:3 | HelloWorld | puts | calls.rb:87:5:87:17 | puts |
212+
| hello.rb:18:1:22:3 | HelloWorld | to_s | calls.rb:151:5:152:7 | to_s |
194213
| hello.rb:18:1:22:3 | HelloWorld | world | hello.rb:5:5:7:7 | world |
195214
| modules.rb:4:1:24:3 | Foo | method_in_another_definition_of_foo | modules.rb:27:3:28:5 | method_in_another_definition_of_foo |
196215
| modules.rb:4:1:24:3 | Foo | method_in_foo | modules.rb:16:3:17:5 | method_in_foo |
197216
| modules.rb:5:3:14:5 | Foo::Bar | method_in_another_definition_of_foo_bar | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar |
198217
| modules.rb:5:3:14:5 | Foo::Bar | method_in_foo_bar | modules.rb:9:5:10:7 | method_in_foo_bar |
199218
| modules.rb:6:5:7:7 | Foo::Bar::ClassInFooBar | new | calls.rb:99:5:99:16 | new |
200219
| modules.rb:6:5:7:7 | Foo::Bar::ClassInFooBar | puts | calls.rb:87:5:87:17 | puts |
220+
| modules.rb:6:5:7:7 | Foo::Bar::ClassInFooBar | to_s | calls.rb:151:5:152:7 | to_s |
201221
| modules.rb:19:3:20:5 | Foo::ClassInFoo | new | calls.rb:99:5:99:16 | new |
202222
| modules.rb:19:3:20:5 | Foo::ClassInFoo | puts | calls.rb:87:5:87:17 | puts |
223+
| modules.rb:19:3:20:5 | Foo::ClassInFoo | to_s | calls.rb:151:5:152:7 | to_s |
203224
| modules.rb:30:3:31:5 | Foo::ClassInAnotherDefinitionOfFoo | new | calls.rb:99:5:99:16 | new |
204225
| modules.rb:30:3:31:5 | Foo::ClassInAnotherDefinitionOfFoo | puts | calls.rb:87:5:87:17 | puts |
226+
| modules.rb:30:3:31:5 | Foo::ClassInAnotherDefinitionOfFoo | to_s | calls.rb:151:5:152:7 | to_s |
205227
| modules.rb:37:1:46:3 | Bar | method_a | modules.rb:38:3:39:5 | method_a |
206228
| modules.rb:37:1:46:3 | Bar | method_b | modules.rb:41:3:42:5 | method_b |
207229
| modules.rb:37:1:46:3 | Bar | new | calls.rb:99:5:99:16 | new |
208230
| modules.rb:37:1:46:3 | Bar | puts | calls.rb:87:5:87:17 | puts |
231+
| modules.rb:37:1:46:3 | Bar | to_s | calls.rb:151:5:152:7 | to_s |
209232
| modules.rb:49:3:50:5 | Foo::Bar::ClassInAnotherDefinitionOfFooBar | new | calls.rb:99:5:99:16 | new |
210233
| modules.rb:49:3:50:5 | Foo::Bar::ClassInAnotherDefinitionOfFooBar | puts | calls.rb:87:5:87:17 | puts |
234+
| modules.rb:49:3:50:5 | Foo::Bar::ClassInAnotherDefinitionOfFooBar | to_s | calls.rb:151:5:152:7 | to_s |
211235
| modules.rb:66:5:67:7 | Test::Foo1::Bar | new | calls.rb:99:5:99:16 | new |
212236
| modules.rb:66:5:67:7 | Test::Foo1::Bar | puts | calls.rb:87:5:87:17 | puts |
237+
| modules.rb:66:5:67:7 | Test::Foo1::Bar | to_s | calls.rb:151:5:152:7 | to_s |
213238
| modules.rb:72:5:73:7 | Test::Foo2::Foo2::Bar | new | calls.rb:99:5:99:16 | new |
214239
| modules.rb:72:5:73:7 | Test::Foo2::Foo2::Bar | puts | calls.rb:87:5:87:17 | puts |
240+
| modules.rb:72:5:73:7 | Test::Foo2::Foo2::Bar | to_s | calls.rb:151:5:152:7 | to_s |
215241
| modules.rb:112:1:113:3 | YY | new | calls.rb:99:5:99:16 | new |
216242
| modules.rb:112:1:113:3 | YY | puts | calls.rb:87:5:87:17 | puts |
243+
| modules.rb:112:1:113:3 | YY | to_s | calls.rb:151:5:152:7 | to_s |
217244
| modules.rb:116:7:117:9 | XX::YY | new | calls.rb:99:5:99:16 | new |
218245
| modules.rb:116:7:117:9 | XX::YY | puts | calls.rb:87:5:87:17 | puts |
246+
| modules.rb:116:7:117:9 | XX::YY | to_s | calls.rb:151:5:152:7 | to_s |
247+
| modules_rec.rb:1:1:2:3 | B::A | new | calls.rb:99:5:99:16 | new |
248+
| modules_rec.rb:1:1:2:3 | B::A | puts | calls.rb:87:5:87:17 | puts |
249+
| modules_rec.rb:1:1:2:3 | B::A | to_s | calls.rb:151:5:152:7 | to_s |
250+
| modules_rec.rb:4:1:5:3 | A::B | new | calls.rb:99:5:99:16 | new |
251+
| modules_rec.rb:4:1:5:3 | A::B | puts | calls.rb:87:5:87:17 | puts |
252+
| modules_rec.rb:4:1:5:3 | A::B | to_s | calls.rb:151:5:152:7 | to_s |
219253
| private.rb:1:1:29:3 | E | new | calls.rb:99:5:99:16 | new |
220254
| private.rb:1:1:29:3 | E | private2 | private.rb:8:3:9:5 | private2 |
221255
| private.rb:1:1:29:3 | E | private3 | private.rb:14:3:15:5 | private3 |
222256
| private.rb:1:1:29:3 | E | private4 | private.rb:17:3:18:5 | private4 |
223257
| private.rb:1:1:29:3 | E | private_on_main | private.rb:31:1:32:3 | private_on_main |
224258
| private.rb:1:1:29:3 | E | public | private.rb:5:3:6:5 | public |
225259
| private.rb:1:1:29:3 | E | puts | calls.rb:87:5:87:17 | puts |
260+
| private.rb:1:1:29:3 | E | to_s | calls.rb:151:5:152:7 | to_s |
226261
| private.rb:42:1:60:3 | F | private2 | private.rb:49:3:50:5 | private2 |
227262
| private.rb:42:1:60:3 | F | private3 | private.rb:55:3:56:5 | private3 |
228263
| private.rb:42:1:60:3 | F | private4 | private.rb:58:3:59:5 | private4 |

0 commit comments

Comments
 (0)