Skip to content

Commit 817a2b7

Browse files
committed
Add more tests
1 parent 557b49c commit 817a2b7

File tree

10 files changed

+92
-24
lines changed

10 files changed

+92
-24
lines changed
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
| main.rb:3:13:3:21 | call to source | main.rb:3:9:3:9 | x |
22
| main.rb:3:13:3:21 | call to source | main.rb:3:9:3:21 | ... = ... |
33
| main.rb:3:13:3:21 | call to source | main.rb:4:9:4:12 | view [@x] |
4-
| main.rb:3:13:3:21 | call to source | main.rb:4:9:4:26 | ... = ... [@x] |
5-
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:26 | call to new [@x] |
6-
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:26 | synthetic splat argument [splat position 0] |
7-
| main.rb:3:13:3:21 | call to source | main.rb:4:25:4:25 | x |
4+
| main.rb:3:13:3:21 | call to source | main.rb:4:9:4:27 | ... = ... [@x] |
5+
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:27 | call to new [@x] |
6+
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:27 | synthetic splat argument [splat position 0] |
7+
| main.rb:3:13:3:21 | call to source | main.rb:4:26:4:26 | x |
88
| main.rb:3:13:3:21 | call to source | main.rb:5:9:5:20 | synthetic splat argument [splat position 0, ... (2)] |
99
| main.rb:3:13:3:21 | call to source | main.rb:5:16:5:19 | view [@x] |
10-
| main.rb:3:13:3:21 | call to source | main.rb:5:16:5:19 | view [Ext] [@x] |
11-
| main.rb:3:13:3:21 | call to source | view.rb:2:5:4:7 | synthetic splat parameter [splat position 0] |
12-
| main.rb:3:13:3:21 | call to source | view.rb:2:20:2:20 | x |
13-
| main.rb:3:13:3:21 | call to source | view.rb:2:20:2:20 | x |
14-
| main.rb:3:13:3:21 | call to source | view.rb:3:9:3:10 | [post] self [@x] |
15-
| main.rb:3:13:3:21 | call to source | view.rb:3:9:3:14 | ... = ... |
16-
| main.rb:3:13:3:21 | call to source | view.rb:3:14:3:14 | x |
10+
| main.rb:3:13:3:21 | call to source | view1.rb:5:5:7:7 | synthetic splat parameter [splat position 0] |
11+
| main.rb:3:13:3:21 | call to source | view1.rb:5:20:5:20 | x |
12+
| main.rb:3:13:3:21 | call to source | view1.rb:5:20:5:20 | x |
13+
| main.rb:3:13:3:21 | call to source | view1.rb:6:9:6:10 | [post] self [@x] |
14+
| main.rb:3:13:3:21 | call to source | view1.rb:6:9:6:14 | ... = ... |
15+
| main.rb:3:13:3:21 | call to source | view1.rb:6:14:6:14 | x |
16+
| main.rb:15:13:15:21 | call to source | main.rb:15:9:15:9 | x |
17+
| main.rb:15:13:15:21 | call to source | main.rb:15:9:15:21 | ... = ... |
18+
| main.rb:15:13:15:21 | call to source | main.rb:16:9:16:12 | view [@x] |
19+
| main.rb:15:13:15:21 | call to source | main.rb:16:9:16:27 | ... = ... [@x] |
20+
| main.rb:15:13:15:21 | call to source | main.rb:16:16:16:27 | call to new [@x] |
21+
| main.rb:15:13:15:21 | call to source | main.rb:16:16:16:27 | synthetic splat argument [splat position 0] |
22+
| main.rb:15:13:15:21 | call to source | main.rb:16:26:16:26 | x |
23+
| main.rb:15:13:15:21 | call to source | main.rb:17:9:17:20 | synthetic splat argument [splat position 0, ... (2)] |
24+
| main.rb:15:13:15:21 | call to source | main.rb:17:16:17:19 | view [@x] |
25+
| main.rb:15:13:15:21 | call to source | view3.rb:2:5:4:7 | synthetic splat parameter [splat position 0] |
26+
| main.rb:15:13:15:21 | call to source | view3.rb:2:20:2:20 | x |
27+
| main.rb:15:13:15:21 | call to source | view3.rb:2:20:2:20 | x |
28+
| main.rb:15:13:15:21 | call to source | view3.rb:3:9:3:10 | [post] self [@x] |
29+
| main.rb:15:13:15:21 | call to source | view3.rb:3:9:3:14 | ... = ... |
30+
| main.rb:15:13:15:21 | call to source | view3.rb:3:14:3:14 | x |
31+
| view1.html.erb:6:5:6:13 | call to source | view1.html.erb:6:1:6:14 | synthetic splat argument [splat position 0] |
32+
| view2.html.erb:3:5:3:13 | call to source | view2.html.erb:3:1:3:14 | synthetic splat argument [splat position 0] |
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
class App
2-
def run
2+
def run1
33
x = source(1)
4-
view = View.new(x)
4+
view = View1.new(x)
55
render(view)
66
end
7-
end
7+
8+
def run2
9+
view = View2.new
10+
render(view)
11+
view.foo
12+
end
13+
14+
def run3
15+
x = source(4)
16+
view = View3.new(x)
17+
render(view)
18+
end
19+
end

ruby/ql/test/library-tests/dataflow/erb/view.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.

ruby/ql/test/library-tests/dataflow/erb/view.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<%# Flow through an ERB template %>
2+
<%= foo() %>
3+
4+
<%# Flow out of an ERB template %>
5+
<%
6+
set(source(2))
7+
foo()
8+
%>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class ViewComponent::Base
2+
end
3+
4+
class View1 < ViewComponent::Base
5+
def initialize(x)
6+
@x = x
7+
end
8+
9+
def foo
10+
sink(@x) # $ hasValueFlow=1 $ hasValueFlow=2
11+
end
12+
13+
def set(x)
14+
@x = x
15+
end
16+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<%# Flow out of an ERB template (side-effect) %>
2+
<%
3+
set(source(3))
4+
%>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class View2 < ViewComponent::Base
2+
def foo
3+
sink(@x) # $ hasValueFlow=3
4+
end
5+
6+
def set(x)
7+
@x = x
8+
end
9+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<%# Flow into an ERB template %>
2+
<%
3+
sink(get) # $ hasValueFlow=4
4+
%>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class View3 < ViewComponent::Base
2+
def initialize(x)
3+
@x = x
4+
end
5+
6+
def get
7+
@x
8+
end
9+
end

0 commit comments

Comments
 (0)