@@ -127,6 +127,13 @@ class ConsistencyTests extends AnyFunSuite with Matchers {
127127 body = None
128128 )()
129129
130+ val pred =
131+ Predicate (
132+ name = " P" ,
133+ formalArgs = Seq (LocalVarDecl (" x" , Int )()),
134+ body = None
135+ )()
136+
130137 val callerIntVarDecl = LocalVarDecl (" intRes" , Int )()
131138 val callerIntVar = LocalVar (" intRes" , Int )()
132139 val callerBoolVarDecl = LocalVarDecl (" boolRes" , Bool )()
@@ -147,23 +154,35 @@ class ConsistencyTests extends AnyFunSuite with Matchers {
147154 Seq ()
148155 )()
149156
157+ val callerPosts =
158+ Seq (
159+ // Wrong: zero arguments
160+ PredicateAccessPredicate (PredicateAccess (Seq (), " P" )(), FullPerm ()())(),
161+ // Wrong: wrong argument type
162+ PredicateAccessPredicate (PredicateAccess (Seq (callerBoolVar), " P" )(), FullPerm ()())(),
163+ // Correct
164+ PredicateAccessPredicate (PredicateAccess (Seq (callerIntVar), " P" )(), FullPerm ()())()
165+ )
166+
150167 val caller =
151168 Method (
152169 name = " caller" ,
153170 formalArgs = Seq (),
154171 formalReturns = Seq (callerIntVarDecl, callerBoolVarDecl),
155172 pres = Seq (),
156- posts = Seq () ,
173+ posts = callerPosts ,
157174 body = Some (callerBody)
158175 )()
159176
160177 val program =
161- Program (domains = Seq (), fields = Seq (), functions = Seq (func), predicates = Seq (), methods = Seq (caller), extensions = Seq ())()
178+ Program (domains = Seq (), fields = Seq (), functions = Seq (func), predicates = Seq (pred ), methods = Seq (caller), extensions = Seq ())()
162179
163180 program.checkTransitively shouldBe Seq (
164181 ConsistencyError (" Function f with formal arguments List(x: Int) cannot be applied to provided arguments List()." , NoPosition ),
165182 ConsistencyError (" No matching function f found of return type Bool, instead found with return type Int." , NoPosition ),
166183 ConsistencyError (" Function f with formal arguments List(x: Int) cannot be applied to provided arguments List(boolRes)." , NoPosition ),
184+ ConsistencyError (" Predicate P with formal arguments List(x: Int) cannot be used with provided arguments List()." , NoPosition ),
185+ ConsistencyError (" Predicate P with formal arguments List(x: Int) cannot be used with provided arguments List(boolRes)." , NoPosition ),
167186 ConsistencyError (" No matching identifier g found of type Function." , NoPosition )
168187 )
169188 }
0 commit comments