From 2af3fb5ccaff3ba2dbc94ff14137f729402954d5 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Sun, 17 Oct 2021 08:40:55 +0200 Subject: [PATCH] add test for predicateExpr --- ql/test/callgraph/Foo.qll | 8 ++++++++ ql/test/callgraph/callgraph.expected | 4 ++++ ql/test/callgraph/callgraph.ql | 2 ++ 3 files changed, 14 insertions(+) diff --git a/ql/test/callgraph/Foo.qll b/ql/test/callgraph/Foo.qll index 3bd6484be12..1a2ac90e06e 100644 --- a/ql/test/callgraph/Foo.qll +++ b/ql/test/callgraph/Foo.qll @@ -37,3 +37,11 @@ module Buildins { predicate regexpCapture(string s) { "foo".regexpCapture("\\w", 1) = s } } + +cached +newtype TApiNode = MkRoot() + +private predicate edge(TApiNode a, TApiNode b) { a = b } + +cached +int distanceFromRoot(TApiNode nd) = shortestDistances(MkRoot/0, edge/2)(_, nd, result) diff --git a/ql/test/callgraph/callgraph.expected b/ql/test/callgraph/callgraph.expected index a931da5b1ff..4011cfb9925 100644 --- a/ql/test/callgraph/callgraph.expected +++ b/ql/test/callgraph/callgraph.expected @@ -22,3 +22,7 @@ getTarget | packs/src/SrcThing.qll:5:3:5:8 | PredicateCall | packs/src/SrcThing.qll:8:1:8:30 | ClasslessPredicate bar | dependsOn | packs/src/qlpack.yml:1:1:1:4 | ql-testing-src-pack | packs/lib/qlpack.yml:1:1:1:4 | ql-testing-lib-pack | +exprPredicate +| Foo.qll:24:22:24:31 | predicate | Foo.qll:22:3:22:32 | ClasslessPredicate myThing0 | +| Foo.qll:26:22:26:31 | predicate | Foo.qll:20:3:20:54 | ClasslessPredicate myThing2 | +| Foo.qll:47:65:47:70 | predicate | Foo.qll:44:9:44:56 | ClasslessPredicate edge | diff --git a/ql/test/callgraph/callgraph.ql b/ql/test/callgraph/callgraph.ql index 9ff79048b84..bf7f2ed1293 100644 --- a/ql/test/callgraph/callgraph.ql +++ b/ql/test/callgraph/callgraph.ql @@ -3,3 +3,5 @@ import ql query AstNode getTarget(Call call) { result = call.getTarget() } query YAML::QLPack dependsOn(YAML::QLPack pack) { result = pack.getADependency() } + +query Predicate exprPredicate(PredicateExpr expr) { result = expr.getResolvedPredicate() }