mirror of
https://github.com/github/codeql.git
synced 2026-02-20 08:53:49 +01:00
Add test for Module
This commit is contained in:
43
ql/test/library-tests/ast/modules/modules.expected
Normal file
43
ql/test/library-tests/ast/modules/modules.expected
Normal file
@@ -0,0 +1,43 @@
|
||||
modules
|
||||
| modules.rb:1:1:2:3 | Empty | Module | Empty |
|
||||
| modules.rb:4:1:24:3 | Foo | Module | Foo |
|
||||
| modules.rb:5:3:14:5 | Bar | Module | Bar |
|
||||
| modules.rb:26:1:35:3 | Foo | Module | Foo |
|
||||
| modules.rb:37:1:46:3 | Bar | Module | Bar |
|
||||
| modules.rb:48:1:57:3 | Bar | Module | Bar |
|
||||
modulesWithScopeResolutionNames
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:48:8:48:15 | ...::Bar |
|
||||
exprsInModules
|
||||
| modules.rb:4:1:24:3 | Foo | 0 | modules.rb:5:3:14:5 | Bar | Module |
|
||||
| modules.rb:4:1:24:3 | Foo | 1 | modules.rb:16:3:17:5 | method_in_foo | Method |
|
||||
| modules.rb:4:1:24:3 | Foo | 2 | modules.rb:19:3:20:5 | ClassInFoo | Class |
|
||||
| modules.rb:4:1:24:3 | Foo | 3 | modules.rb:22:3:22:19 | call to puts | Call |
|
||||
| modules.rb:4:1:24:3 | Foo | 4 | modules.rb:23:3:23:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:5:3:14:5 | Bar | 0 | modules.rb:6:5:7:7 | ClassInFooBar | Class |
|
||||
| modules.rb:5:3:14:5 | Bar | 1 | modules.rb:9:5:10:7 | method_in_foo_bar | Method |
|
||||
| modules.rb:5:3:14:5 | Bar | 2 | modules.rb:12:5:12:26 | call to puts | Call |
|
||||
| modules.rb:5:3:14:5 | Bar | 3 | modules.rb:13:5:13:19 | ... = ... | AssignExpr |
|
||||
| modules.rb:26:1:35:3 | Foo | 0 | modules.rb:27:3:28:5 | method_in_another_definition_of_foo | Method |
|
||||
| modules.rb:26:1:35:3 | Foo | 1 | modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo | Class |
|
||||
| modules.rb:26:1:35:3 | Foo | 2 | modules.rb:33:3:33:25 | call to puts | Call |
|
||||
| modules.rb:26:1:35:3 | Foo | 3 | modules.rb:34:3:34:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:37:1:46:3 | Bar | 0 | modules.rb:38:3:39:5 | method_a | Method |
|
||||
| modules.rb:37:1:46:3 | Bar | 1 | modules.rb:41:3:42:5 | method_b | Method |
|
||||
| modules.rb:37:1:46:3 | Bar | 2 | modules.rb:44:3:44:19 | call to puts | Call |
|
||||
| modules.rb:37:1:46:3 | Bar | 3 | modules.rb:45:3:45:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:48:1:57:3 | Bar | 0 | modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar | Class |
|
||||
| modules.rb:48:1:57:3 | Bar | 1 | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar | Method |
|
||||
| modules.rb:48:1:57:3 | Bar | 2 | modules.rb:55:3:55:30 | call to puts | Call |
|
||||
| modules.rb:48:1:57:3 | Bar | 3 | modules.rb:56:3:56:17 | ... = ... | AssignExpr |
|
||||
methodsInModules
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:16:3:17:5 | method_in_foo |
|
||||
| modules.rb:5:3:14:5 | Bar | modules.rb:9:5:10:7 | method_in_foo_bar |
|
||||
| modules.rb:26:1:35:3 | Foo | modules.rb:27:3:28:5 | method_in_another_definition_of_foo |
|
||||
| modules.rb:37:1:46:3 | Bar | modules.rb:38:3:39:5 | method_a |
|
||||
| modules.rb:37:1:46:3 | Bar | modules.rb:41:3:42:5 | method_b |
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar |
|
||||
classesInModules
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:19:3:20:5 | ClassInFoo |
|
||||
| modules.rb:5:3:14:5 | Bar | modules.rb:6:5:7:7 | ClassInFooBar |
|
||||
| modules.rb:26:1:35:3 | Foo | modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo |
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar |
|
||||
17
ql/test/library-tests/ast/modules/modules.ql
Normal file
17
ql/test/library-tests/ast/modules/modules.ql
Normal file
@@ -0,0 +1,17 @@
|
||||
import ruby
|
||||
|
||||
query predicate modules(Module m, string pClass, string name) {
|
||||
pClass = m.getAPrimaryQlClass() and name = m.getName()
|
||||
}
|
||||
|
||||
query predicate modulesWithScopeResolutionNames(Module m, ScopeResolution name) {
|
||||
name = m.getNameScopeResolution()
|
||||
}
|
||||
|
||||
query predicate exprsInModules(Module m, int i, Expr e, string eClass) {
|
||||
e = m.getExpr(i) and eClass = e.getAPrimaryQlClass()
|
||||
}
|
||||
|
||||
query predicate methodsInModules(Module mod, Method method) { method = mod.getAMethod() }
|
||||
|
||||
query predicate classesInModules(Module m, Class c) { c = m.getAClass() }
|
||||
57
ql/test/library-tests/ast/modules/modules.rb
Normal file
57
ql/test/library-tests/ast/modules/modules.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
module Empty
|
||||
end
|
||||
|
||||
module Foo
|
||||
module Bar
|
||||
class ClassInFooBar
|
||||
end
|
||||
|
||||
def method_in_foo_bar
|
||||
end
|
||||
|
||||
puts 'module Foo::Bar'
|
||||
$global_var = 0
|
||||
end
|
||||
|
||||
def method_in_foo
|
||||
end
|
||||
|
||||
class ClassInFoo
|
||||
end
|
||||
|
||||
puts 'module Foo'
|
||||
$global_var = 1
|
||||
end
|
||||
|
||||
module Foo
|
||||
def method_in_another_definition_of_foo
|
||||
end
|
||||
|
||||
class ClassInAnotherDefinitionOfFoo
|
||||
end
|
||||
|
||||
puts 'module Foo again'
|
||||
$global_var = 2
|
||||
end
|
||||
|
||||
module Bar
|
||||
def method_a
|
||||
end
|
||||
|
||||
def method_b
|
||||
end
|
||||
|
||||
puts 'module Bar'
|
||||
$global_var = 3
|
||||
end
|
||||
|
||||
module Foo::Bar
|
||||
class ClassInAnotherDefinitionOfFooBar
|
||||
end
|
||||
|
||||
def method_in_another_definition_of_foo_bar
|
||||
end
|
||||
|
||||
puts 'module Foo::Bar again'
|
||||
$global_var = 4
|
||||
end
|
||||
Reference in New Issue
Block a user