RosettaCodeData/Task/Assertions/PL-I/assertions.pli
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

18 lines
560 B
Text

/* 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);