mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
ruby: add tests
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
| 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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
@@ -0,0 +1,2 @@
|
||||
query: queries/variables/DeadStoreOfLocal.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
@@ -0,0 +1,36 @@
|
||||
def test_basic(x)
|
||||
y = x #$ Alert
|
||||
y = x + 2
|
||||
return y
|
||||
end
|
||||
|
||||
def test_retry
|
||||
x = 0
|
||||
begin
|
||||
if x == 0
|
||||
raise "error"
|
||||
end
|
||||
rescue
|
||||
x = 2 #$ SPURIOUS: Alert
|
||||
retry
|
||||
end
|
||||
return 42
|
||||
end
|
||||
|
||||
def test_binding
|
||||
x = 4 #$ SPURIOUS: Alert
|
||||
return binding
|
||||
end
|
||||
|
||||
class Sup
|
||||
def m(x)
|
||||
print(x + 1)
|
||||
end
|
||||
end
|
||||
|
||||
class Sub < Sup
|
||||
def m(y)
|
||||
y = 3 # OK - the call to `super` sees the value of y
|
||||
super
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
require 'erb'
|
||||
|
||||
template = ERB.new <<EOF
|
||||
<%#-*- coding: Big5 -*-%>
|
||||
\_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
|
||||
x is <%= x %>.
|
||||
EOF
|
||||
x = 5 #$ SPURIOUS: Alert
|
||||
puts template.result
|
||||
Reference in New Issue
Block a user