Ruby: Add call graph test for unsupported constructs

This commit is contained in:
Tom Hvitved
2022-09-21 14:14:12 +02:00
parent f0f4fe7286
commit fa6da788dc
6 changed files with 776 additions and 422 deletions

View File

@@ -1,8 +1,8 @@
#-----| BasicObject
#-----| Class
#-----| super -> Module
#-----| BasicObject
#-----| Complex
#-----| super -> Numeric
@@ -92,6 +92,11 @@ calls.rb:
# 399| SingletonOverride2
#-----| super -> SingletonOverride1
# 414| ConditionalInstanceMethods
#-----| super -> Object
# 477| ExtendSingletonMethod
hello.rb:
# 1| EnglishWords

View File

@@ -157,6 +157,26 @@ getTarget
| calls.rb:397:1:397:34 | call to call_singleton2 | calls.rb:389:5:391:7 | call_singleton2 |
| calls.rb:402:13:402:48 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:407:9:407:44 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:417:13:417:48 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:422:9:422:44 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:425:13:425:48 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:428:17:428:52 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:436:9:440:11 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:436:9:440:15 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:438:17:438:40 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:444:1:444:30 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:444:1:444:33 | call to m1 | calls.rb:416:9:418:11 | m1 |
| calls.rb:445:1:445:30 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:446:1:446:30 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:446:1:446:33 | call to m2 | calls.rb:421:5:433:7 | m2 |
| calls.rb:447:1:447:30 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:448:1:448:30 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:449:1:449:30 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:454:13:454:22 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:458:5:462:7 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:458:5:462:11 | call to new | calls.rb:114:5:114:16 | new |
| calls.rb:460:13:460:22 | call to puts | calls.rb:102:5:102:30 | puts |
| calls.rb:466:13:466:27 | call to puts | calls.rb:102:5:102:30 | puts |
| hello.rb:12:5:12:24 | call to include | calls.rb:107:5:107:20 | include |
| hello.rb:14:16:14:20 | call to hello | hello.rb:2:5:4:7 | hello |
| hello.rb:20:16:20:20 | call to super | hello.rb:13:5:15:7 | message |
@@ -233,6 +253,37 @@ unresolvedCall
| calls.rb:310:9:310:20 | call to instance |
| calls.rb:411:1:411:34 | call to call_singleton1 |
| calls.rb:412:1:412:34 | call to call_singleton2 |
| calls.rb:415:8:415:13 | call to rand |
| calls.rb:415:8:415:17 | ... > ... |
| calls.rb:432:9:432:10 | call to m3 |
| calls.rb:435:8:435:13 | call to rand |
| calls.rb:435:8:435:17 | ... > ... |
| calls.rb:436:9:440:18 | call to m5 |
| calls.rb:445:1:445:33 | call to m3 |
| calls.rb:447:1:447:33 | call to m3 |
| calls.rb:448:1:448:33 | call to m4 |
| calls.rb:449:1:449:33 | call to m5 |
| calls.rb:450:1:450:4 | call to exit |
| calls.rb:451:27:469:3 | call to new |
| calls.rb:452:5:452:11 | call to [] |
| calls.rb:452:5:456:7 | call to each |
| calls.rb:458:5:462:15 | call to bar |
| calls.rb:464:5:464:11 | call to [] |
| calls.rb:464:5:468:7 | call to each |
| calls.rb:465:9:467:11 | call to define_method |
| calls.rb:471:1:471:27 | call to new |
| calls.rb:471:1:471:31 | call to foo |
| calls.rb:472:1:472:27 | call to new |
| calls.rb:472:1:472:31 | call to bar |
| calls.rb:473:1:473:27 | call to new |
| calls.rb:473:1:473:33 | call to baz_0 |
| calls.rb:474:1:474:27 | call to new |
| calls.rb:474:1:474:33 | call to baz_1 |
| calls.rb:475:1:475:27 | call to new |
| calls.rb:475:1:475:33 | call to baz_2 |
| calls.rb:479:9:479:46 | call to puts |
| calls.rb:482:5:482:15 | call to extend |
| calls.rb:485:1:485:31 | call to singleton |
| hello.rb:20:16:20:26 | ... + ... |
| hello.rb:20:16:20:34 | ... + ... |
| hello.rb:20:16:20:40 | ... + ... |
@@ -257,6 +308,8 @@ privateMethod
| calls.rb:275:1:283:3 | create |
| calls.rb:340:1:356:3 | pattern_dispatch |
| calls.rb:364:1:368:3 | add_singleton |
| calls.rb:453:9:455:11 | foo |
| calls.rb:459:9:461:11 | bar |
| private.rb:2:11:3:5 | private1 |
| private.rb:8:3:9:5 | private2 |
| private.rb:14:3:15:5 | private3 |

View File

@@ -410,3 +410,76 @@ end
SingletonOverride2.call_singleton1
SingletonOverride2.call_singleton2
class ConditionalInstanceMethods
if rand() > 0 then
def m1
puts "ConditionalInstanceMethods#m1"
end
end
def m2
puts "ConditionalInstanceMethods#m2"
def m3
puts "ConditionalInstanceMethods#m3"
def m4
puts "ConditionalInstanceMethods#m4"
end
end
m3
end
if rand() > 0 then
Class.new do
def m5
puts "AnonymousClass#m5"
end
end.new.m5
end
end
ConditionalInstanceMethods.new.m1
ConditionalInstanceMethods.new.m3 # NoMethodError
ConditionalInstanceMethods.new.m2
ConditionalInstanceMethods.new.m3 # currently unable to resolve
ConditionalInstanceMethods.new.m4 # currently unable to resolve
ConditionalInstanceMethods.new.m5 # NoMethodError
exit
EsotericInstanceMethods = Class.new do
[0,1,2].each do
def foo
puts "foo"
end
end
Class.new do
def bar
puts "bar"
end
end.new.bar
[0,1,2].each do |i|
define_method("baz_#{i}") do
puts "baz_#{i}"
end
end
end
EsotericInstanceMethods.new.foo # currently unable to resolve
EsotericInstanceMethods.new.bar # NoMethodError
EsotericInstanceMethods.new.baz_0 # currently unable to resolve
EsotericInstanceMethods.new.baz_1 # currently unable to resolve
EsotericInstanceMethods.new.baz_2 # currently unable to resolve
module ExtendSingletonMethod
def singleton
puts "ExtendSingletonMethod#singleton"
end
extend self
end
ExtendSingletonMethod.singleton # currently unable to resolve

View File

@@ -36,6 +36,9 @@ getMethod
| calls.rb:322:1:326:3 | C1 | instance | calls.rb:323:5:325:7 | instance |
| calls.rb:328:1:332:3 | C2 | instance | calls.rb:329:5:331:7 | instance |
| calls.rb:334:1:338:3 | C3 | instance | calls.rb:335:5:337:7 | instance |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | m1 | calls.rb:416:9:418:11 | m1 |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | m2 | calls.rb:421:5:433:7 | m2 |
| calls.rb:477:1:483:3 | ExtendSingletonMethod | singleton | calls.rb:478:5:480:7 | singleton |
| hello.rb:1:1:8:3 | EnglishWords | hello | hello.rb:2:5:4:7 | hello |
| hello.rb:1:1:8:3 | EnglishWords | world | hello.rb:5:5:7:7 | world |
| hello.rb:11:1:16:3 | Greeting | message | hello.rb:13:5:15:7 | message |
@@ -329,6 +332,23 @@ lookupMethod
| calls.rb:399:1:409:3 | SingletonOverride2 | private_on_main | calls.rb:182:1:183:3 | private_on_main |
| calls.rb:399:1:409:3 | SingletonOverride2 | puts | calls.rb:102:5:102:30 | puts |
| calls.rb:399:1:409:3 | SingletonOverride2 | to_s | calls.rb:169:5:170:7 | to_s |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | add_singleton | calls.rb:364:1:368:3 | add_singleton |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | call_block | calls.rb:81:1:83:3 | call_block |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | call_instance_m | calls.rb:39:1:41:3 | call_instance_m |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | create | calls.rb:275:1:283:3 | create |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | foo | calls.rb:1:1:3:3 | foo |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | foo | calls.rb:85:1:89:3 | foo |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | funny | calls.rb:137:1:139:3 | funny |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | indirect | calls.rb:155:1:157:3 | indirect |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | m1 | calls.rb:416:9:418:11 | m1 |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | m2 | calls.rb:421:5:433:7 | m2 |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | new | calls.rb:114:5:114:16 | new |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | optional_arg | calls.rb:76:1:79:3 | optional_arg |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | pattern_dispatch | calls.rb:340:1:356:3 | pattern_dispatch |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | private_on_main | calls.rb:182:1:183:3 | private_on_main |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | puts | calls.rb:102:5:102:30 | puts |
| calls.rb:414:1:442:3 | ConditionalInstanceMethods | to_s | calls.rb:169:5:170:7 | to_s |
| calls.rb:477:1:483:3 | ExtendSingletonMethod | singleton | calls.rb:478:5:480:7 | singleton |
| file://:0:0:0:0 | Class | include | calls.rb:107:5:107:20 | include |
| file://:0:0:0:0 | Class | module_eval | calls.rb:106:5:106:24 | module_eval |
| file://:0:0:0:0 | Class | new | calls.rb:114:5:114:16 | new |
@@ -705,6 +725,42 @@ enclosingMethod
| calls.rb:407:9:407:44 | self | calls.rb:406:5:408:7 | singleton2 |
| calls.rb:407:14:407:44 | "SingletonOverride2#singleton2" | calls.rb:406:5:408:7 | singleton2 |
| calls.rb:407:15:407:43 | SingletonOverride2#singleton2 | calls.rb:406:5:408:7 | singleton2 |
| calls.rb:417:13:417:48 | call to puts | calls.rb:416:9:418:11 | m1 |
| calls.rb:417:13:417:48 | self | calls.rb:416:9:418:11 | m1 |
| calls.rb:417:18:417:48 | "ConditionalInstanceMethods#m1" | calls.rb:416:9:418:11 | m1 |
| calls.rb:417:19:417:47 | ConditionalInstanceMethods#m1 | calls.rb:416:9:418:11 | m1 |
| calls.rb:422:9:422:44 | call to puts | calls.rb:421:5:433:7 | m2 |
| calls.rb:422:9:422:44 | self | calls.rb:421:5:433:7 | m2 |
| calls.rb:422:14:422:44 | "ConditionalInstanceMethods#m2" | calls.rb:421:5:433:7 | m2 |
| calls.rb:422:15:422:43 | ConditionalInstanceMethods#m2 | calls.rb:421:5:433:7 | m2 |
| calls.rb:424:9:430:11 | m3 | calls.rb:421:5:433:7 | m2 |
| calls.rb:425:13:425:48 | call to puts | calls.rb:424:9:430:11 | m3 |
| calls.rb:425:13:425:48 | self | calls.rb:424:9:430:11 | m3 |
| calls.rb:425:18:425:48 | "ConditionalInstanceMethods#m3" | calls.rb:424:9:430:11 | m3 |
| calls.rb:425:19:425:47 | ConditionalInstanceMethods#m3 | calls.rb:424:9:430:11 | m3 |
| calls.rb:427:13:429:15 | m4 | calls.rb:424:9:430:11 | m3 |
| calls.rb:428:17:428:52 | call to puts | calls.rb:427:13:429:15 | m4 |
| calls.rb:428:17:428:52 | self | calls.rb:427:13:429:15 | m4 |
| calls.rb:428:22:428:52 | "ConditionalInstanceMethods#m4" | calls.rb:427:13:429:15 | m4 |
| calls.rb:428:23:428:51 | ConditionalInstanceMethods#m4 | calls.rb:427:13:429:15 | m4 |
| calls.rb:432:9:432:10 | call to m3 | calls.rb:421:5:433:7 | m2 |
| calls.rb:432:9:432:10 | self | calls.rb:421:5:433:7 | m2 |
| calls.rb:438:17:438:40 | call to puts | calls.rb:437:13:439:15 | m5 |
| calls.rb:438:17:438:40 | self | calls.rb:437:13:439:15 | m5 |
| calls.rb:438:22:438:40 | "AnonymousClass#m5" | calls.rb:437:13:439:15 | m5 |
| calls.rb:438:23:438:39 | AnonymousClass#m5 | calls.rb:437:13:439:15 | m5 |
| calls.rb:454:13:454:22 | call to puts | calls.rb:453:9:455:11 | foo |
| calls.rb:454:13:454:22 | self | calls.rb:453:9:455:11 | foo |
| calls.rb:454:18:454:22 | "foo" | calls.rb:453:9:455:11 | foo |
| calls.rb:454:19:454:21 | foo | calls.rb:453:9:455:11 | foo |
| calls.rb:460:13:460:22 | call to puts | calls.rb:459:9:461:11 | bar |
| calls.rb:460:13:460:22 | self | calls.rb:459:9:461:11 | bar |
| calls.rb:460:18:460:22 | "bar" | calls.rb:459:9:461:11 | bar |
| calls.rb:460:19:460:21 | bar | calls.rb:459:9:461:11 | bar |
| calls.rb:479:9:479:46 | call to puts | calls.rb:478:5:480:7 | singleton |
| calls.rb:479:9:479:46 | self | calls.rb:478:5:480:7 | singleton |
| calls.rb:479:14:479:46 | "ExtendSingletonMethod#singleton" | calls.rb:478:5:480:7 | singleton |
| calls.rb:479:15:479:45 | ExtendSingletonMethod#singleton | calls.rb:478:5:480:7 | singleton |
| hello.rb:3:9:3:22 | return | hello.rb:2:5:4:7 | hello |
| hello.rb:3:16:3:22 | "hello" | hello.rb:2:5:4:7 | hello |
| hello.rb:3:17:3:21 | hello | hello.rb:2:5:4:7 | hello |

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
#-----| BasicObject
#-----| Class
#-----| -> Module
#-----| BasicObject
#-----| Complex
#-----| -> Numeric
@@ -88,6 +88,11 @@ calls.rb:
# 399| SingletonOverride2
#-----| -> SingletonOverride1
# 414| ConditionalInstanceMethods
#-----| -> Object
# 477| ExtendSingletonMethod
hello.rb:
# 1| EnglishWords