@@ -226,6 +226,61 @@ func TestCLIComplexityFail(t *testing.T) {
226226 assert .NotContains (t , output , moduleDir )
227227}
228228
229+ func TestCLIPredicatesFail (t * testing.T ) {
230+ binary := buildBinary (t )
231+ moduleDir := writeModule (t , module {
232+ GoMod : []string {
233+ "module example.com/predicates" ,
234+ "" ,
235+ "go 1.26" ,
236+ },
237+ Files : map [string ][]string {"a.go" : {
238+ "package predicates" ,
239+ "" ,
240+ "func F(a, b bool) {" ,
241+ "\t if a && b {" ,
242+ "\t \t println(\" both\" )" ,
243+ "\t }" ,
244+ "}" ,
245+ }},
246+ })
247+
248+ output , err := runConstable (t , binary , moduleDir )
249+
250+ require .Error (t , err )
251+ assert .Contains (t , output , `use predicate function instead of "b" in compound conditional` )
252+ assert .NotContains (t , output , moduleDir )
253+ }
254+
255+ func TestCLIPredicatesPass (t * testing.T ) {
256+ binary := buildBinary (t )
257+ moduleDir := writeModule (t , module {
258+ GoMod : []string {
259+ "module example.com/predicatespass" ,
260+ "" ,
261+ "go 1.26" ,
262+ },
263+ Files : map [string ][]string {"a.go" : {
264+ "package predicates" ,
265+ "" ,
266+ "func isA() bool { return true }" ,
267+ "" ,
268+ "func isB() bool { return false }" ,
269+ "" ,
270+ "func F() {" ,
271+ "\t if isA() && isB() {" ,
272+ "\t \t println(\" both\" )" ,
273+ "\t }" ,
274+ "}" ,
275+ }},
276+ })
277+
278+ output , err := runConstable (t , binary , moduleDir )
279+
280+ require .NoError (t , err , output )
281+ assert .Empty (t , output )
282+ }
283+
229284func TestCLIComplexityPass (t * testing.T ) {
230285 binary := buildBinary (t )
231286
0 commit comments