Skip to content

Commit af4c312

Browse files
committed
Test case for **nil parameter
1 parent 078a2aa commit af4c312

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,16 @@ params/params.rb:
21452145
# 70| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a
21462146
# 70| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b
21472147
# 70| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] c
2148+
# 73| getStmt: [Method] method_with_nil_splat
2149+
# 73| getParameter: [SimpleParameter] wibble
2150+
# 73| getDefiningAccess: [LocalVariableAccess] wibble
2151+
# 73| getParameter: [HashSplatNilParameter] **nil
2152+
# 77| getStmt: [MethodCall] call to each
2153+
# 77| getReceiver: [LocalVariableAccess] array
2154+
# 77| getBlock: [DoBlock] do ... end
2155+
# 77| getParameter: [SimpleParameter] val
2156+
# 77| getDefiningAccess: [LocalVariableAccess] val
2157+
# 77| getParameter: [HashSplatNilParameter] **nil
21482158
erb/template.html.erb:
21492159
# 19| [Toplevel] template.html.erb
21502160
# 19| getStmt: [StringLiteral] "hello world"

ruby/ql/test/library-tests/ast/params/params.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ idParams
3333
| params.rb:70:35:70:35 | a | a |
3434
| params.rb:70:38:70:38 | b | b |
3535
| params.rb:70:48:70:48 | c | c |
36+
| params.rb:73:27:73:32 | wibble | wibble |
37+
| params.rb:77:16:77:18 | val | val |
3638
blockParams
3739
| params.rb:46:28:46:33 | &block | block |
3840
| params.rb:62:29:62:34 | &block | block |
@@ -83,6 +85,8 @@ paramsInMethods
8385
| params.rb:58:1:59:3 | method_with_optional_params | 1 | params.rb:58:39:58:42 | val2 | OptionalParameter |
8486
| params.rb:58:1:59:3 | method_with_optional_params | 2 | params.rb:58:49:58:52 | val3 | OptionalParameter |
8587
| params.rb:62:1:64:3 | use_block_with_optional | 0 | params.rb:62:29:62:34 | &block | BlockParameter |
88+
| params.rb:73:1:74:3 | method_with_nil_splat | 0 | params.rb:73:27:73:32 | wibble | SimpleParameter |
89+
| params.rb:73:1:74:3 | method_with_nil_splat | 1 | params.rb:73:35:73:39 | **nil | HashSplatNilParameter |
8690
paramsInBlocks
8791
| params.rb:9:11:11:3 | do ... end | 0 | params.rb:9:15:9:17 | key | SimpleParameter |
8892
| params.rb:9:11:11:3 | do ... end | 1 | params.rb:9:20:9:24 | value | SimpleParameter |
@@ -94,6 +98,8 @@ paramsInBlocks
9498
| params.rb:49:24:51:3 | do ... end | 1 | params.rb:49:33:49:34 | yy | KeywordParameter |
9599
| params.rb:65:25:67:3 | do ... end | 0 | params.rb:65:29:65:32 | name | SimpleParameter |
96100
| params.rb:65:25:67:3 | do ... end | 1 | params.rb:65:35:65:37 | age | OptionalParameter |
101+
| params.rb:77:12:78:3 | do ... end | 0 | params.rb:77:16:77:18 | val | SimpleParameter |
102+
| params.rb:77:12:78:3 | do ... end | 1 | params.rb:77:21:77:25 | **nil | HashSplatNilParameter |
97103
paramsInLambdas
98104
| params.rb:14:7:14:33 | -> { ... } | 0 | params.rb:14:11:14:13 | foo | SimpleParameter |
99105
| params.rb:14:7:14:33 | -> { ... } | 1 | params.rb:14:16:14:18 | bar | SimpleParameter |
@@ -147,3 +153,7 @@ params
147153
| params.rb:70:35:70:35 | a | 0 | SimpleParameter |
148154
| params.rb:70:38:70:38 | b | 1 | OptionalParameter |
149155
| params.rb:70:48:70:48 | c | 2 | OptionalParameter |
156+
| params.rb:73:27:73:32 | wibble | 0 | SimpleParameter |
157+
| params.rb:73:35:73:39 | **nil | 1 | HashSplatNilParameter |
158+
| params.rb:77:16:77:18 | val | 0 | SimpleParameter |
159+
| params.rb:77:21:77:25 | **nil | 1 | HashSplatNilParameter |

ruby/ql/test/library-tests/ast/params/params.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ def use_block_with_optional(&block)
6767
end
6868

6969
# Lambda containing optional parameters
70-
lambda_with_optional_params = -> (a, b = 1000, c = 20) { a+b+c }
70+
lambda_with_optional_params = -> (a, b = 1000, c = 20) { a+b+c }
71+
72+
# Method containing nil hash-splat params
73+
def method_with_nil_splat(wibble, **nil)
74+
end
75+
76+
# Block with nil hash-splat parameter
77+
array.each do |val, **nil|
78+
end
79+

0 commit comments

Comments
 (0)