Skip to content

Commit 66b2c39

Browse files
committed
More tests
1 parent 578b944 commit 66b2c39

6 files changed

Lines changed: 519 additions & 82 deletions

File tree

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

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
#-----| Object
2-
#-----| super -> BasicObject
1+
calls.rb:
2+
# 101| Hash
3+
#-----| super -> Object
4+
5+
# 77| Integer
6+
#-----| super -> Numeric
7+
8+
# 86| Kernel
9+
10+
# 90| Module
11+
#-----| super -> Object
12+
13+
# 96| Object
314
#-----| include -> Kernel
15+
#-----| super -> BasicObject
416

5-
#-----| Array
17+
# 105| Array
618
#-----| super -> Object
719

820
#-----| BasicObject
@@ -19,17 +31,6 @@
1931
#-----| Float
2032
#-----| super -> Numeric
2133

22-
#-----| Hash
23-
#-----| super -> Object
24-
25-
#-----| Integer
26-
#-----| super -> Numeric
27-
28-
#-----| Kernel
29-
30-
#-----| Module
31-
#-----| super -> Object
32-
3334
#-----| NilClass
3435
#-----| super -> Object
3536

@@ -42,7 +43,6 @@
4243
#-----| TrueClass
4344
#-----| super -> Object
4445

45-
calls.rb:
4646
# 15| M
4747

4848
# 29| C
@@ -52,6 +52,18 @@ calls.rb:
5252
# 51| D
5353
#-----| super -> C
5454

55+
# 82| String
56+
#-----| super -> Object
57+
58+
# 143| S
59+
#-----| super -> Object
60+
61+
# 149| A
62+
#-----| super -> S
63+
64+
# 154| B
65+
#-----| super -> S
66+
5567
hello.rb:
5668
# 1| EnglishWords
5769

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,86 @@
11
getTarget
2+
| calls.rb:2:5:2:14 | call to puts | calls.rb:87:5:87:17 | puts |
23
| calls.rb:5:1:5:3 | call to foo | calls.rb:1:1:3:3 | foo |
4+
| calls.rb:5:1:5:3 | call to foo | calls.rb:71:1:75:3 | foo |
5+
| calls.rb:8:5:8:14 | call to puts | calls.rb:87:5:87:17 | puts |
36
| calls.rb:11:1:11:8 | call to bar | calls.rb:7:1:9:3 | bar |
47
| calls.rb:13:1:13:8 | call to foo | calls.rb:1:1:3:3 | foo |
8+
| calls.rb:13:1:13:8 | call to foo | calls.rb:71:1:75:3 | foo |
59
| calls.rb:22:5:22:15 | call to singleton_m | calls.rb:17:5:17:29 | singleton_m |
610
| calls.rb:23:5:23:20 | call to singleton_m | calls.rb:17:5:17:29 | singleton_m |
711
| calls.rb:27:1:27:13 | call to singleton_m | calls.rb:17:5:17:29 | singleton_m |
12+
| calls.rb:30:5:30:13 | call to include | calls.rb:92:5:92:20 | include |
813
| calls.rb:38:9:38:18 | call to instance_m | calls.rb:16:5:16:23 | instance_m |
914
| calls.rb:39:9:39:23 | call to instance_m | calls.rb:16:5:16:23 | instance_m |
15+
| calls.rb:46:5:46:9 | call to new | calls.rb:98:5:98:16 | new |
1016
| calls.rb:47:1:47:5 | call to baz | calls.rb:37:5:43:7 | baz |
1117
| calls.rb:49:1:49:12 | call to instance_m | calls.rb:16:5:16:23 | instance_m |
1218
| calls.rb:53:9:53:13 | call to super | calls.rb:37:5:43:7 | baz |
19+
| calls.rb:57:5:57:9 | call to new | calls.rb:98:5:98:16 | new |
1320
| calls.rb:58:1:58:5 | call to baz | calls.rb:52:5:54:7 | baz |
1421
| calls.rb:60:1:60:12 | call to instance_m | calls.rb:16:5:16:23 | instance_m |
22+
| calls.rb:63:5:63:16 | call to bit_length | calls.rb:78:5:78:23 | bit_length |
23+
| calls.rb:64:5:64:16 | call to bit_length | calls.rb:78:5:78:23 | bit_length |
24+
| calls.rb:72:11:72:18 | call to new | calls.rb:98:5:98:16 | new |
25+
| calls.rb:73:5:73:10 | ...[...] | calls.rb:102:5:102:15 | [] |
26+
| calls.rb:74:5:74:29 | call to call_block | calls.rb:67:1:69:3 | call_block |
27+
| calls.rb:74:22:74:27 | ...[...] | calls.rb:102:5:102:15 | [] |
28+
| calls.rb:97:5:97:18 | call to include | calls.rb:92:5:92:20 | include |
29+
| calls.rb:111:15:111:25 | call to length | calls.rb:107:3:107:17 | length |
30+
| calls.rb:112:18:112:24 | ...[...] | calls.rb:106:3:106:13 | [] |
31+
| calls.rb:122:1:122:30 | call to funny | calls.rb:118:1:120:3 | funny |
32+
| calls.rb:122:13:122:29 | call to puts | calls.rb:87:5:87:17 | puts |
33+
| calls.rb:124:1:124:14 | call to capitalize | calls.rb:83:5:83:23 | capitalize |
34+
| calls.rb:125:1:125:12 | call to bit_length | calls.rb:78:5:78:23 | bit_length |
35+
| calls.rb:126:1:126:5 | call to abs | calls.rb:79:5:79:16 | abs |
36+
| calls.rb:128:1:128:62 | call to foreach | calls.rb:109:3:115:5 | foreach |
37+
| calls.rb:128:32:128:61 | call to puts | calls.rb:87:5:87:17 | puts |
38+
| calls.rb:130:1:130:35 | call to foreach | calls.rb:109:3:115:5 | foreach |
39+
| calls.rb:132:1:132:40 | call to foreach | calls.rb:109:3:115:5 | foreach |
40+
| calls.rb:132:23:132:39 | call to puts | calls.rb:87:5:87:17 | puts |
41+
| calls.rb:134:1:134:37 | call to foreach | calls.rb:109:3:115:5 | foreach |
42+
| calls.rb:134:27:134:36 | call to puts | calls.rb:87:5:87:17 | puts |
43+
| calls.rb:137:5:137:17 | call to call_block | calls.rb:67:1:69:3 | call_block |
44+
| calls.rb:140:1:140:28 | call to indirect | calls.rb:136:1:138:3 | indirect |
45+
| calls.rb:159:1:159:5 | call to new | calls.rb:98:5:98:16 | new |
46+
| calls.rb:159:1:159:14 | call to s_method | calls.rb:144:5:146:7 | s_method |
47+
| calls.rb:160:1:160:5 | call to new | calls.rb:98:5:98:16 | new |
48+
| calls.rb:160:1:160:14 | call to s_method | calls.rb:144:5:146:7 | s_method |
49+
| calls.rb:161:1:161:5 | call to new | calls.rb:98:5:98:16 | new |
50+
| calls.rb:161:1:161:14 | call to s_method | calls.rb:144:5:146:7 | s_method |
51+
| hello.rb:12:5:12:24 | call to include | calls.rb:92:5:92:20 | include |
1552
| hello.rb:14:16:14:20 | call to hello | hello.rb:2:5:4:7 | hello |
1653
| hello.rb:20:16:20:20 | call to super | hello.rb:13:5:15:7 | message |
1754
| hello.rb:20:30:20:34 | call to world | hello.rb:5:5:7:7 | world |
55+
| modules.rb:12:5:12:26 | call to puts | calls.rb:87:5:87:17 | puts |
56+
| modules.rb:22:3:22:19 | call to puts | calls.rb:87:5:87:17 | puts |
57+
| modules.rb:33:3:33:25 | call to puts | calls.rb:87:5:87:17 | puts |
58+
| modules.rb:44:3:44:19 | call to puts | calls.rb:87:5:87:17 | puts |
59+
| modules.rb:55:3:55:30 | call to puts | calls.rb:87:5:87:17 | puts |
60+
| modules.rb:89:3:89:16 | call to include | calls.rb:92:5:92:20 | include |
61+
| modules.rb:90:3:90:38 | call to module_eval | calls.rb:91:5:91:24 | module_eval |
62+
| modules.rb:90:24:90:36 | call to prepend | calls.rb:93:5:93:20 | prepend |
63+
| modules.rb:96:3:96:14 | call to include | calls.rb:92:5:92:20 | include |
64+
| modules.rb:102:3:102:16 | call to prepend | calls.rb:93:5:93:20 | prepend |
1865
unresolvedCall
19-
| calls.rb:2:5:2:14 | call to puts |
20-
| calls.rb:8:5:8:14 | call to puts |
2166
| calls.rb:19:5:19:14 | call to instance_m |
2267
| calls.rb:20:5:20:19 | call to instance_m |
2368
| calls.rb:26:1:26:12 | call to instance_m |
24-
| calls.rb:30:5:30:13 | call to include |
2569
| calls.rb:31:5:31:14 | call to instance_m |
2670
| calls.rb:32:5:32:19 | call to instance_m |
2771
| calls.rb:34:5:34:15 | call to singleton_m |
2872
| calls.rb:35:5:35:20 | call to singleton_m |
2973
| calls.rb:41:9:41:19 | call to singleton_m |
3074
| calls.rb:42:9:42:24 | call to singleton_m |
31-
| calls.rb:46:5:46:9 | call to new |
3275
| calls.rb:48:1:48:13 | call to singleton_m |
33-
| calls.rb:57:5:57:9 | call to new |
3476
| calls.rb:59:1:59:13 | call to singleton_m |
35-
| hello.rb:12:5:12:24 | call to include |
36-
| modules.rb:12:5:12:26 | call to puts |
37-
| modules.rb:22:3:22:19 | call to puts |
38-
| modules.rb:33:3:33:25 | call to puts |
39-
| modules.rb:44:3:44:19 | call to puts |
40-
| modules.rb:55:3:55:30 | call to puts |
41-
| modules.rb:89:3:89:16 | call to include |
42-
| modules.rb:90:3:90:38 | call to module_eval |
43-
| modules.rb:90:24:90:36 | call to prepend |
44-
| modules.rb:96:3:96:14 | call to include |
45-
| modules.rb:102:3:102:16 | call to prepend |
77+
| calls.rb:68:5:68:11 | yield ... |
78+
| calls.rb:112:9:112:24 | yield ... |
79+
| calls.rb:119:5:119:20 | yield ... |
80+
| calls.rb:122:18:122:29 | call to capitalize |
81+
| calls.rb:128:48:128:59 | call to capitalize |
82+
| calls.rb:130:23:130:34 | call to bit_length |
83+
| calls.rb:132:28:132:39 | call to capitalize |
84+
| calls.rb:134:32:134:36 | call to abs |
85+
| calls.rb:140:16:140:27 | call to bit_length |
86+
| calls.rb:145:9:145:17 | call to to_s |

ql/test/library-tests/modules/calls.rb

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,105 @@ def baz
5757
d = D.new
5858
d.baz
5959
d.singleton_m # NoMethodError
60-
d.instance_m
60+
d.instance_m
61+
62+
def optional_arg(a = 4, b: 5)
63+
a.bit_length
64+
b.bit_length
65+
end
66+
67+
def call_block
68+
yield 1
69+
end
70+
71+
def foo()
72+
var = Hash.new
73+
var[1]
74+
call_block { |x| var[x] }
75+
end
76+
77+
class Integer
78+
def bit_length; end
79+
def abs; end
80+
end
81+
82+
class String
83+
def capitalize; end
84+
end
85+
86+
module Kernel
87+
def puts; end
88+
end
89+
90+
class Module
91+
def module_eval; end
92+
def include; end
93+
def prepend; end
94+
end
95+
96+
class Object < Module
97+
include Kernel
98+
def new; end
99+
end
100+
101+
class Hash
102+
def []; end
103+
end
104+
105+
class Array
106+
def []; end
107+
def length; end
108+
109+
def foreach &body
110+
x = 0
111+
while x < self.length
112+
yield x, self[x]
113+
x += 1
114+
end
115+
end
116+
end
117+
118+
def funny
119+
yield "prefix: "
120+
end
121+
122+
funny { |i| puts i.capitalize}
123+
124+
"a".capitalize
125+
1.bit_length
126+
1.abs
127+
128+
["a","b","c"].foreach { |i, v| puts "#{i} -> #{v.capitalize}"} # TODO should resolve to String.capitalize
129+
130+
[1,2,3].foreach { |i| i.bit_length}
131+
132+
[1,2,3].foreach { |i| puts i.capitalize} # NoMethodError
133+
134+
[1,-2,3].foreach { |_, v| puts v.abs} # TODO should resolve to Integer.abs
135+
136+
def indirect &b
137+
call_block &b
138+
end
139+
140+
indirect { |i| i.bit_length}
141+
142+
143+
class S
144+
def s_method
145+
self.to_s
146+
end
147+
end
148+
149+
class A < S
150+
def to_s
151+
end
152+
end
153+
154+
class B < S
155+
def to_s
156+
end
157+
end
158+
159+
S.new.s_method
160+
A.new.s_method
161+
B.new.s_method

0 commit comments

Comments
 (0)