Guards: Add support for wrappers that may throw exceptions.

This commit is contained in:
Anders Schack-Mulligen
2025-07-23 15:31:34 +02:00
parent b156bd5ce2
commit f90b6ab005
4 changed files with 33 additions and 0 deletions

View File

@@ -202,4 +202,14 @@ public class Guards {
break;
}
}
static void ensureNotNull(Object o) throws Exception {
if (o == null) throw new Exception();
}
void testExceptionWrapper(String s) throws Exception {
chk(); // nothing guards here
ensureNotNull(s);
chk(); // $ guarded='ensureNotNull(...):no exception' guarded='s:not null'
}
}

View File

@@ -112,3 +112,5 @@
| Guards.java:201:9:201:13 | chk(...) | 'testEnumWrapper(...):FAILURE' |
| Guards.java:201:9:201:13 | chk(...) | 'testEnumWrapper(...):match FAILURE' |
| Guards.java:201:9:201:13 | chk(...) | g(1):false |
| Guards.java:213:5:213:9 | chk(...) | 'ensureNotNull(...):no exception' |
| Guards.java:213:5:213:9 | chk(...) | 's:not null' |