Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions javascript/ql/lib/semmle/javascript/frameworks/xUnit.qll
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ private predicate possiblyAttribute(Expr e, string name) {
)
}

final private class FinalExpr = Expr;

/**
* A bracketed list of expressions.
*
Expand All @@ -34,15 +36,22 @@ private predicate possiblyAttribute(Expr e, string name) {
*
* We also allow singleton lists, as in `[a][b]`.
*/
abstract private class BracketedListOfExpressions extends Expr {
abstract private class BracketedListOfExpressions extends FinalExpr {
/** Gets the `i`th element expression of this list. */
abstract Expr getElement(int i);

/** Gets the first token in this bracketed list of expressions */
Token getFirstToken() { result = Expr.super.getFirstToken() }

/** Gets the last token in this bracketed list of expressions */
Token getLastToken() { result = Expr.super.getLastToken() }
}

/**
* An array expression viewed as a bracketed list of expressions.
*/
private class ArrayExprIsABracketedListOfExpressions extends ArrayExpr, BracketedListOfExpressions {
private class ArrayExprIsABracketedListOfExpressions extends BracketedListOfExpressions instanceof ArrayExpr
{
/** Gets the `i`th element of this array literal. */
override Expr getElement(int i) { result = ArrayExpr.super.getElement(i) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ xUnitAnnotationfrom
| tst.js:5:5:5:13 | [Fixture] | tst.js:6:5:13:5 | functio ... }\\n } |
| tst.js:7:9:7:14 | [Fact] | tst.js:8:9:12:9 | functio ... } |
| tst.js:16:1:16:43 | [Import ... t.js")] | tst.js:18:1:22:2 | Test.xU ... ..]\\n\\n}; |
| tst.js:17:1:17:9 | Fixture | tst.js:18:1:22:2 | Test.xU ... ..]\\n\\n}; |
| tst.js:17:2:17:8 | Fixture | tst.js:18:1:22:2 | Test.xU ... ..]\\n\\n}; |
| tst.js:24:1:24:9 | [Fixture] | tst.js:25:1:34:2 | Test.Ex ... }\\n}; |
| tst.js:27:5:29:7 | [Import ... })] | tst.js:31:5:33:5 | functio ... ]\\n } |
| tst.js:30:5:30:10 | Fact | tst.js:31:5:33:5 | functio ... ]\\n } |
| tst.js:30:6:30:9 | Fact | tst.js:31:5:33:5 | functio ... ]\\n } |
xUnitAttribute
| tst.js:3:2:3:8 | Fixture | Fixture | 0 |
| tst.js:5:6:5:12 | Fixture | Fixture | 0 |
Expand All @@ -24,7 +24,7 @@ xUnitFixture
| tst.js:4:20:14:1 | functio ... }\\n} | tst.js:3:1:3:9 | [Fixture] |
| tst.js:6:5:13:5 | functio ... }\\n } | tst.js:5:5:5:13 | [Fixture] |
| tst.js:18:24:22:1 | functio ... ...]\\n\\n} | tst.js:16:1:16:43 | [Import ... t.js")] |
| tst.js:18:24:22:1 | functio ... ...]\\n\\n} | tst.js:17:1:17:9 | Fixture |
| tst.js:18:24:22:1 | functio ... ...]\\n\\n} | tst.js:17:2:17:8 | Fixture |
| tst.js:25:21:34:1 | functio ... }\\n} | tst.js:24:1:24:9 | [Fixture] |
xUnitTarget
| tst.js:4:1:14:2 | Test.Ex ... }\\n}; |
Expand Down