Skip to content

Commit

Permalink
annotation tests for GA languages (semgrep#2143)
Browse files Browse the repository at this point in the history
  • Loading branch information
colleend authored Dec 2, 2020
1 parent e9fac6f commit 08e32a9
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 0 deletions.
4 changes: 4 additions & 0 deletions semgrep-core/tests/POLYGLOT/metavar_anno.sgrep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@$X
class $CLASS {
...
}
21 changes: 21 additions & 0 deletions semgrep-core/tests/java/metavar_anno.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ERROR:
@AnnoFoo
class Foo {
int foo = 1;
}

// ERROR:
@Anno1
@Anno2
class FooBar {
int foobar = 2;
}

@AnnoBar(bar = "bar")
class Bar {
int bar = 1;
}

class NoAnno {
int noanno = 2;
}
18 changes: 18 additions & 0 deletions semgrep-core/tests/java/metavar_func_anno.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Foo {
// ERROR:
@Override
public void foo1() {
int x = 1;
}

// ERROR:
@Anno1
@Anno2
public void foo2() {
int x = 2;
}

public void foo3() {
int x = 3;
}
}
4 changes: 4 additions & 0 deletions semgrep-core/tests/java/metavar_func_anno.sgrep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@$X
public void $FUNC (...) {
...
}
21 changes: 21 additions & 0 deletions semgrep-core/tests/js/metavar_anno.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ERROR:
@Anno1
class Foo {
var foo = 1;
}

// ERROR:
@Anno1
@Anno2
class FooBar {
var foo = 2;
}

@AnnoVar("Bar")
class Bar {
var bar = 1;
}

class NoAnno {
var no_anno = 1;
}
19 changes: 19 additions & 0 deletions semgrep-core/tests/python/metavar_anno.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ERROR:
@anno1
def bar(foo: 'foo'):
x = 2

# ERROR:
@anno1
@anno2
def foobar():
x = 3

@app.route('/foo')
def foo():
x = 1

def no_anno():
x = 2


3 changes: 3 additions & 0 deletions semgrep-core/tests/python/metavar_anno.sgrep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@$X
def $FUNC(...):
...

0 comments on commit 08e32a9

Please sign in to comment.