Add more tests

This commit is contained in:
Tom Hvitved
2024-01-17 09:51:45 +01:00
parent 557b49cfc5
commit 817a2b71a8
10 changed files with 92 additions and 24 deletions

View File

@@ -1,16 +1,32 @@
| main.rb:3:13:3:21 | call to source | main.rb:3:9:3:9 | x |
| main.rb:3:13:3:21 | call to source | main.rb:3:9:3:21 | ... = ... |
| main.rb:3:13:3:21 | call to source | main.rb:4:9:4:12 | view [@x] |
| main.rb:3:13:3:21 | call to source | main.rb:4:9:4:26 | ... = ... [@x] |
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:26 | call to new [@x] |
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:26 | synthetic splat argument [splat position 0] |
| main.rb:3:13:3:21 | call to source | main.rb:4:25:4:25 | x |
| main.rb:3:13:3:21 | call to source | main.rb:4:9:4:27 | ... = ... [@x] |
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:27 | call to new [@x] |
| main.rb:3:13:3:21 | call to source | main.rb:4:16:4:27 | synthetic splat argument [splat position 0] |
| main.rb:3:13:3:21 | call to source | main.rb:4:26:4:26 | x |
| main.rb:3:13:3:21 | call to source | main.rb:5:9:5:20 | synthetic splat argument [splat position 0, ... (2)] |
| main.rb:3:13:3:21 | call to source | main.rb:5:16:5:19 | view [@x] |
| main.rb:3:13:3:21 | call to source | main.rb:5:16:5:19 | view [Ext] [@x] |
| main.rb:3:13:3:21 | call to source | view.rb:2:5:4:7 | synthetic splat parameter [splat position 0] |
| main.rb:3:13:3:21 | call to source | view.rb:2:20:2:20 | x |
| main.rb:3:13:3:21 | call to source | view.rb:2:20:2:20 | x |
| main.rb:3:13:3:21 | call to source | view.rb:3:9:3:10 | [post] self [@x] |
| main.rb:3:13:3:21 | call to source | view.rb:3:9:3:14 | ... = ... |
| main.rb:3:13:3:21 | call to source | view.rb:3:14:3:14 | x |
| main.rb:3:13:3:21 | call to source | view1.rb:5:5:7:7 | synthetic splat parameter [splat position 0] |
| main.rb:3:13:3:21 | call to source | view1.rb:5:20:5:20 | x |
| main.rb:3:13:3:21 | call to source | view1.rb:5:20:5:20 | x |
| main.rb:3:13:3:21 | call to source | view1.rb:6:9:6:10 | [post] self [@x] |
| main.rb:3:13:3:21 | call to source | view1.rb:6:9:6:14 | ... = ... |
| main.rb:3:13:3:21 | call to source | view1.rb:6:14:6:14 | x |
| main.rb:15:13:15:21 | call to source | main.rb:15:9:15:9 | x |
| main.rb:15:13:15:21 | call to source | main.rb:15:9:15:21 | ... = ... |
| main.rb:15:13:15:21 | call to source | main.rb:16:9:16:12 | view [@x] |
| main.rb:15:13:15:21 | call to source | main.rb:16:9:16:27 | ... = ... [@x] |
| main.rb:15:13:15:21 | call to source | main.rb:16:16:16:27 | call to new [@x] |
| main.rb:15:13:15:21 | call to source | main.rb:16:16:16:27 | synthetic splat argument [splat position 0] |
| main.rb:15:13:15:21 | call to source | main.rb:16:26:16:26 | x |
| main.rb:15:13:15:21 | call to source | main.rb:17:9:17:20 | synthetic splat argument [splat position 0, ... (2)] |
| main.rb:15:13:15:21 | call to source | main.rb:17:16:17:19 | view [@x] |
| main.rb:15:13:15:21 | call to source | view3.rb:2:5:4:7 | synthetic splat parameter [splat position 0] |
| main.rb:15:13:15:21 | call to source | view3.rb:2:20:2:20 | x |
| main.rb:15:13:15:21 | call to source | view3.rb:2:20:2:20 | x |
| main.rb:15:13:15:21 | call to source | view3.rb:3:9:3:10 | [post] self [@x] |
| main.rb:15:13:15:21 | call to source | view3.rb:3:9:3:14 | ... = ... |
| main.rb:15:13:15:21 | call to source | view3.rb:3:14:3:14 | x |
| view1.html.erb:6:5:6:13 | call to source | view1.html.erb:6:1:6:14 | synthetic splat argument [splat position 0] |
| view2.html.erb:3:5:3:13 | call to source | view2.html.erb:3:1:3:14 | synthetic splat argument [splat position 0] |

View File

@@ -1,7 +1,19 @@
class App
def run
def run1
x = source(1)
view = View.new(x)
view = View1.new(x)
render(view)
end
end
def run2
view = View2.new
render(view)
view.foo
end
def run3
x = source(4)
view = View3.new(x)
render(view)
end
end

View File

@@ -1 +0,0 @@
<%= foo() %>

View File

@@ -1,9 +0,0 @@
class View
def initialize(x)
@x = x
end
def foo
sink(@x) # $ hasValueFlow=1
end
end

View File

@@ -0,0 +1,8 @@
<%# Flow through an ERB template %>
<%= foo() %>
<%# Flow out of an ERB template %>
<%
set(source(2))
foo()
%>

View File

@@ -0,0 +1,16 @@
class ViewComponent::Base
end
class View1 < ViewComponent::Base
def initialize(x)
@x = x
end
def foo
sink(@x) # $ hasValueFlow=1 $ hasValueFlow=2
end
def set(x)
@x = x
end
end

View File

@@ -0,0 +1,4 @@
<%# Flow out of an ERB template (side-effect) %>
<%
set(source(3))
%>

View File

@@ -0,0 +1,9 @@
class View2 < ViewComponent::Base
def foo
sink(@x) # $ hasValueFlow=3
end
def set(x)
@x = x
end
end

View File

@@ -0,0 +1,4 @@
<%# Flow into an ERB template %>
<%
sink(get) # $ hasValueFlow=4
%>

View File

@@ -0,0 +1,9 @@
class View3 < ViewComponent::Base
def initialize(x)
@x = x
end
def get
@x
end
end