-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyTestCase.vdmpp
36 lines (31 loc) · 999 Bytes
/
MyTestCase.vdmpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class MyTestCase
/*
Superclass for test classes, simpler but more practical than VDMUnit`TestCase.
For proper use, you have to do: New -> Add VDM Library -> IO.
JPF, FEUP, MFES, 2014/15.
*/
operations
-- Simulates assertion checking by reducing it to pre-condition checking.
-- If 'arg' does not hold, a pre-condition violation will be signaled.
protected assertTrue: bool ==> ()
assertTrue(arg) ==
return
pre arg;
protected assertFalse: bool ==> ()
assertFalse(arg) ==
return
pre not arg;
-- Simulates assertion checking by reducing it to post-condition checking.
-- If values are not equal, prints a message in the console and generates
-- a post-conditions violation.
protected assertEqual: ? * ? ==> ()
assertEqual(expected, actual) ==
if expected <> actual then (
IO`print("Actual value (");
IO`print(actual);
IO`print(") different from expected (");
IO`print(expected);
IO`println(")\n")
)
post expected = actual
end MyTestCase