/[ascend]/trunk/models/johnpye/when_test.a4c
ViewVC logotype

Contents of /trunk/models/johnpye/when_test.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 157 - (show annotations) (download) (as text)
Fri Dec 23 01:30:46 2005 UTC (14 years, 3 months ago) by johnpye
File MIME type: text/x-ascend
File size: 741 byte(s)
Adding test for other WHEN branch
Colour highlighting of failed ASSERTs on xterm
1 REQUIRE "atoms.a4l";
2
3 MODEL when_test;
4
5 x IS_A variable;
6 y IS_A variable;
7
8 lin: y = x - 1;
9 quad: y = x^2 / 4;
10
11 use_linear IS_A boolean_var;
12
13 WHEN(use_linear)
14 CASE TRUE:
15 USE lin;
16 CASE FALSE:
17 USE quad;
18 END WHEN;
19
20 METHODS
21 METHOD default_self;
22 RUN reset;
23 RUN values;
24 END default_self;
25
26 METHOD specify;
27 use_linear.fixed := TRUE;
28 x.fixed := TRUE;
29 END specify;
30
31 METHOD values;
32 use_linear := FALSE;
33 x := -4;
34 END values;
35
36 METHOD self_test;
37 ASSERT y == 4;
38 END self_test;
39
40 END when_test;
41
42 (* test the other branch of the WHEN... *)
43
44 MODEL when_test_2 REFINES when_test;
45 (* nothing here *)
46
47 METHODS
48 METHOD values;
49 use_linear := TRUE;
50 x := -4;
51 END values;
52
53 METHOD self_test;
54 ASSERT y == -5;
55 END self_test;
56
57 END when_test_2;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22