Skip to content

Commit b205fed

Browse files
committed
ruby: add tests
1 parent e5fc1b0 commit b205fed

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| DeadStoreOfLocal.rb:2:5:2:5 | y | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:2:5:2:5 | y | y |
2+
| DeadStoreOfLocal.rb:14:9:14:9 | x | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:8:5:8:5 | x | x |
3+
| DeadStoreOfLocal.rb:21:5:21:5 | x | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:21:5:21:5 | x | x |
4+
| TestTemplate.rb:9:1:9:1 | x | This assignment to $@ is useless, since its value is never read. | TestTemplate.rb:9:1:9:1 | x | x |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: queries/variables/DeadStoreOfLocal.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
def test_basic(x)
2+
y = x #$ Alert
3+
y = x + 2
4+
return y
5+
end
6+
7+
def test_retry
8+
x = 0
9+
begin
10+
if x == 0
11+
raise "error"
12+
end
13+
rescue
14+
x = 2 #$ SPURIOUS: Alert
15+
retry
16+
end
17+
return 42
18+
end
19+
20+
def test_binding
21+
x = 4 #$ SPURIOUS: Alert
22+
return binding
23+
end
24+
25+
class Sup
26+
def m(x)
27+
print(x + 1)
28+
end
29+
end
30+
31+
class Sub < Sup
32+
def m(y)
33+
y = 3 # OK - the call to `super` sees the value of y
34+
super
35+
end
36+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
require 'erb'
3+
4+
template = ERB.new <<EOF
5+
<%#-*- coding: Big5 -*-%>
6+
\_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
7+
x is <%= x %>.
8+
EOF
9+
x = 5 #$ SPURIOUS: Alert
10+
puts template.result

0 commit comments

Comments
 (0)