RosettaCodeData/Task/Assertions/PL-I/assertions.pli

19 lines
560 B
Plaintext

/* PL/I does not have an assert function as such, */
/* but it is something that can be implemented in */
/* any of several ways. A straight-forward way */
/* raises a user-defined interrupt. */
on condition (assert_failure) snap
put skip list ('Assert failure');
....
if a ^= b then signal condition(assert_failure);
/* Another way is to use the preprocessor, thus: */
%assert: procedure (a, b) returns (character);
return ('if ' || a || '^=' || b ||
' then signal condition(assert_failure);');
%end assert;
%activate assert;
assert(a, 42);