Skip to content

Commit 1a95961

Browse files
committed
JS: Port Classes test
1 parent 9a15a55 commit 1a95961

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

javascript/ql/test/library-tests/Classes/tests.expected

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
legacyDataFlowDifference
12
test_FieldInits
23
| dataflow.js:5:3:5:17 | #priv = source; | dataflow.js:5:11:5:16 | source |
34
| fields.js:3:3:3:8 | y = 42 | fields.js:3:7:3:8 | 42 |
@@ -287,9 +288,6 @@ getAccessModifier
287288
| tst.js:12:3:12:8 | m() {} | tst.js:12:3:12:3 | m | Public |
288289
| tst.js:13:3:13:10 | [m]() {} | tst.js:13:4:13:4 | m | Public |
289290
| tst.js:17:3:17:20 | m() { return 42; } | tst.js:17:3:17:3 | m | Public |
290-
dataflow
291-
| dataflow.js:2:15:2:22 | "source" | dataflow.js:14:7:14:25 | new Foo().getPriv() |
292-
| dataflow.js:2:15:2:22 | "source" | dataflow.js:16:7:16:33 | new Foo ... ivate() |
293291
staticInitializer
294292
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:6:10:8:3 | {\\n M ... 3;\\n } |
295293
| staticInitializer.js:1:1:18:1 | class M ... ;\\n }\\n} | staticInitializer.js:15:10:17:3 | {\\n t ... 6;\\n } |
@@ -312,3 +310,6 @@ privateIdentifier
312310
| privateFields.js:37:12:37:17 | #brand |
313311
| privateFields.js:37:29:37:35 | #method |
314312
| privateFields.js:37:47:37:53 | #getter |
313+
dataflow
314+
| dataflow.js:2:15:2:22 | "source" | dataflow.js:14:7:14:25 | new Foo().getPriv() |
315+
| dataflow.js:2:15:2:22 | "source" | dataflow.js:16:7:16:33 | new Foo ... ivate() |

javascript/ql/test/library-tests/Classes/tests.ql

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,30 @@ query string getAccessModifier(DataFlow::PropRef ref, Expr prop) {
5757
if ref.isPrivateField() then result = "Private" else result = "Public"
5858
}
5959

60-
class Configuration extends DataFlow::Configuration {
61-
Configuration() { this = "ClassDataFlowTestingConfig" }
62-
63-
override predicate isSource(DataFlow::Node source) {
60+
module TestConfig implements DataFlow::ConfigSig {
61+
predicate isSource(DataFlow::Node source) {
6462
source.getEnclosingExpr().(StringLiteral).getValue().toLowerCase() = "source"
6563
}
6664

67-
override predicate isSink(DataFlow::Node sink) {
65+
predicate isSink(DataFlow::Node sink) {
6866
any(DataFlow::CallNode call | call.getCalleeName() = "sink").getAnArgument() = sink
6967
}
7068
}
7169

72-
query predicate dataflow(DataFlow::Node pred, DataFlow::Node succ) {
73-
any(Configuration c).hasFlow(pred, succ)
70+
module TestFlow = DataFlow::Global<TestConfig>;
71+
72+
class LegacyConfig extends DataFlow::Configuration {
73+
LegacyConfig() { this = "LegacyConfig" }
74+
75+
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
76+
77+
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
7478
}
7579

80+
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
81+
82+
query predicate dataflow = TestFlow::flow/2;
83+
7684
query BlockStmt staticInitializer(ClassDefinition cd) { result = cd.getAStaticInitializerBlock() }
7785

7886
query Identifier privateIdentifier() { result.getName().matches("#%") }

0 commit comments

Comments
 (0)