Skip to content

Commit

Permalink
Prettify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smowton committed Sep 4, 2024
1 parent 4c5344d commit fe9d879
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
15 changes: 7 additions & 8 deletions go/ql/test/library-tests/semmle/go/aliases/MethodDefs/test.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ newtype TEntityWithDeclInfo =
MkEntityWithDeclInfo(Entity e, int nDecls) { nDecls = count(e.getDeclaration()) and nDecls > 0 }

class EntityWithDeclInfo extends TEntityWithDeclInfo {
string toString() {
exists(Entity e, int nDecls | this = MkEntityWithDeclInfo(e, nDecls) |
result = e.toString() + " (" + nDecls + " declaration sites)"
)
}
Entity e;
int nDecls;

EntityWithDeclInfo() { this = MkEntityWithDeclInfo(e, nDecls) }

string toString() { result = e.toString() + " (" + nDecls + " declaration sites)" }

predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
exists(Entity e | this = MkEntityWithDeclInfo(e, _) |
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}

Expand Down
12 changes: 6 additions & 6 deletions go/ql/test/library-tests/semmle/go/aliases/defsuses/test.ql
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import go
newtype TEntityWithDeclInfo = MkEntityWithDeclInfo(Entity e)

class EntityWithDeclInfo extends TEntityWithDeclInfo {
Entity e;

EntityWithDeclInfo() { this = MkEntityWithDeclInfo(e) }

string toString() {
exists(Entity e | this = MkEntityWithDeclInfo(e) |
result = e.toString() + " (" + count(e.getDeclaration()) + " declaration sites)"
)
result = e.toString() + " (" + count(e.getDeclaration()) + " declaration sites)"
}

predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
exists(Entity e | this = MkEntityWithDeclInfo(e) |
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}

Expand Down

0 comments on commit fe9d879

Please sign in to comment.