Skip to content

Commit 0dc3ea5

Browse files
committed
Add test-cases for forward arguments and endless methods
1 parent e44064c commit 0dc3ea5

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

ql/test/library-tests/ast/Ast.expected

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,50 @@ calls/calls.rb:
611611
# 320| getReceiver: [Self] self
612612
# 320| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 1
613613
# 320| getAnOperand/getRightOperand: [IntegerLiteral] 2
614+
# 323| getStmt: [Method] foo
615+
# 323| getStmt: [MethodCall] call to bar
616+
# 323| getReceiver: [Self] self
617+
# 324| getStmt: [Method] foo
618+
# 324| getStmt: [MethodCall] call to bar
619+
# 324| getReceiver: [Self] self
620+
# 325| getStmt: [Method] foo
621+
# 325| getParameter: [SimpleParameter] x
622+
# 325| getDefiningAccess: [LocalVariableAccess] x
623+
# 325| getStmt: [MethodCall] call to bar
624+
# 325| getReceiver: [Self] self
625+
# 326| getStmt: [SingletonMethod] foo
626+
# 326| getObject: [ConstantReadAccess] Object
627+
# 326| getStmt: [MethodCall] call to bar
628+
# 326| getReceiver: [Self] self
629+
# 327| getStmt: [SingletonMethod] foo
630+
# 327| getObject: [ConstantReadAccess] Object
631+
# 327| getParameter: [SimpleParameter] x
632+
# 327| getDefiningAccess: [LocalVariableAccess] x
633+
# 327| getStmt: [MethodCall] call to bar
634+
# 327| getReceiver: [Self] self
635+
# 328| getStmt: [Method] foo
636+
# 328| getStmt: [RescueModifierExpr] ... rescue ...
637+
# 328| getBody: [MethodCall] call to bar
638+
# 328| getReceiver: [Self] self
639+
# 328| getHandler: [ParenthesizedExpr] ( ... )
640+
# 328| getStmt: [MethodCall] call to print
641+
# 328| getReceiver: [Self] self
642+
# 328| getArgument: [StringLiteral] "error"
643+
# 328| getComponent: [StringTextComponent] error
644+
# 331| getStmt: [Method] foo
645+
# 331| getParameter: [ForwardParameter] ...
646+
# 332| getStmt: [SuperCall] call to super
647+
# 332| getArgument: [ForwardedArguments] ...
648+
# 335| getStmt: [Method] foo
649+
# 335| getParameter: [SimpleParameter] a
650+
# 335| getDefiningAccess: [LocalVariableAccess] a
651+
# 335| getParameter: [SimpleParameter] b
652+
# 335| getDefiningAccess: [LocalVariableAccess] b
653+
# 335| getParameter: [ForwardParameter] ...
654+
# 336| getStmt: [MethodCall] call to bar
655+
# 336| getReceiver: [Self] self
656+
# 336| getArgument: [LocalVariableAccess] b
657+
# 336| getArgument: [ForwardedArguments] ...
614658
control/cases.rb:
615659
# 1| [Toplevel] cases.rb
616660
# 2| getStmt: [AssignExpr] ... = ...

ql/test/library-tests/ast/ValueText.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
| calls/calls.rb:320:9:320:9 | __synth__1 | 0 |
5656
| calls/calls.rb:320:31:320:31 | 1 | 1 |
5757
| calls/calls.rb:320:37:320:37 | 2 | 2 |
58+
| calls/calls.rb:328:31:328:37 | "error" | error |
5859
| constants/constants.rb:3:19:3:27 | "const_a" | const_a |
5960
| constants/constants.rb:6:15:6:23 | "const_b" | const_b |
6061
| constants/constants.rb:17:12:17:18 | "Hello" | Hello |

ql/test/library-tests/ast/calls/calls.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ callsWithArguments
8686
| calls.rb:320:1:320:32 | call to []= | []= | 4 | calls.rb:320:34:320:35 | __synth__4 |
8787
| calls.rb:320:21:320:31 | ... + ... | + | 0 | calls.rb:320:31:320:31 | 1 |
8888
| calls.rb:320:34:320:35 | ... * ... | * | 0 | calls.rb:320:37:320:37 | 2 |
89+
| calls.rb:328:25:328:37 | call to print | print | 0 | calls.rb:328:31:328:37 | "error" |
90+
| calls.rb:332:3:332:12 | call to super | super | 0 | calls.rb:332:9:332:11 | ... |
91+
| calls.rb:336:3:336:13 | call to bar | bar | 0 | calls.rb:336:7:336:7 | b |
92+
| calls.rb:336:3:336:13 | call to bar | bar | 1 | calls.rb:336:10:336:12 | ... |
8993
callsWithReceiver
9094
| calls.rb:2:1:2:5 | call to foo | calls.rb:2:1:2:5 | self |
9195
| calls.rb:5:1:5:10 | call to bar | calls.rb:5:1:5:3 | Foo |
@@ -316,6 +320,14 @@ callsWithReceiver
316320
| calls.rb:320:21:320:27 | call to boo | calls.rb:320:21:320:23 | call to foo |
317321
| calls.rb:320:21:320:31 | ... + ... | calls.rb:320:21:320:27 | call to boo |
318322
| calls.rb:320:34:320:35 | ... * ... | calls.rb:320:1:320:32 | call to [] |
323+
| calls.rb:323:11:323:13 | call to bar | calls.rb:323:11:323:13 | self |
324+
| calls.rb:324:13:324:15 | call to bar | calls.rb:324:13:324:15 | self |
325+
| calls.rb:325:14:325:16 | call to bar | calls.rb:325:14:325:16 | self |
326+
| calls.rb:326:18:326:20 | call to bar | calls.rb:326:18:326:20 | self |
327+
| calls.rb:327:22:327:24 | call to bar | calls.rb:327:22:327:24 | self |
328+
| calls.rb:328:13:328:15 | call to bar | calls.rb:328:13:328:15 | self |
329+
| calls.rb:328:25:328:37 | call to print | calls.rb:328:25:328:37 | self |
330+
| calls.rb:336:3:336:13 | call to bar | calls.rb:336:3:336:13 | self |
319331
callsWithBlock
320332
| calls.rb:17:1:17:17 | call to foo | calls.rb:17:5:17:17 | { ... } |
321333
| calls.rb:20:1:22:3 | call to foo | calls.rb:20:5:22:3 | do ... end |
@@ -339,6 +351,7 @@ superCalls
339351
| calls.rb:292:5:292:30 | call to super |
340352
| calls.rb:293:5:293:33 | call to super |
341353
| calls.rb:305:5:305:9 | call to super |
354+
| calls.rb:332:3:332:12 | call to super |
342355
superCallsWithArguments
343356
| calls.rb:288:5:288:16 | call to super | 0 | calls.rb:288:11:288:16 | "blah" |
344357
| calls.rb:289:5:289:17 | call to super | 0 | calls.rb:289:11:289:11 | 1 |
@@ -348,6 +361,7 @@ superCallsWithArguments
348361
| calls.rb:292:5:292:30 | call to super | 1 | calls.rb:292:14:292:14 | 5 |
349362
| calls.rb:293:5:293:33 | call to super | 0 | calls.rb:293:11:293:11 | 6 |
350363
| calls.rb:293:5:293:33 | call to super | 1 | calls.rb:293:14:293:14 | 7 |
364+
| calls.rb:332:3:332:12 | call to super | 0 | calls.rb:332:9:332:11 | ... |
351365
superCallsWithBlock
352366
| calls.rb:290:5:290:23 | call to super | calls.rb:290:11:290:23 | { ... } |
353367
| calls.rb:291:5:291:26 | call to super | calls.rb:291:11:291:26 | do ... end |

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,20 @@ def another_method
318318
self.count += 1
319319
foo[0] += 1
320320
foo.bar[0, foo.baz, foo.boo + 1] *= 2
321+
322+
# endless method definitions
323+
def foo = bar
324+
def foo() = bar
325+
def foo(x) = bar
326+
def Object.foo = bar
327+
def Object.foo (x) = bar
328+
def foo() = bar rescue (print "error")
329+
330+
# forward parameter and forwarded arguments
331+
def foo(...)
332+
super(...)
333+
end
334+
335+
def foo(a, b, ...)
336+
bar(b, ...)
337+
end

0 commit comments

Comments
 (0)