/[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 576 - (show annotations) (download) (as text)
Tue May 9 03:42:08 2006 UTC (18 years, 8 months ago) by johnpye
File MIME type: text/x-ascend
File size: 721 byte(s)
Changed all cases of *.fixed := {TRUE,FALSE} to 'FIX' and 'FREE' statements.
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 FIX use_linear;
28 FIX x;
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