XMesaCmplr2:
PROGRAM
IMPORTS RunRegressions, XMesaProcs =
BEGIN
filename: LONG STRING ¬ "XMesaCmplr2"L;
XMesaCall2: PROCEDURE = {
XMesaProcs.PrintS[filename];
XMesaProcs.PrintCR;
XMesa2a[]; --Enumeration types
XMesa2b[]; --Machine dependent enumerations
XMesa2c[]; --Subrange types
XMesa2d[]; Numeric subranges (see XMesaCmplr9.XMesa9b)
XMesa2e[]; --Arrays and array constructors
XMesa2f[]; --Record types, operations
XMesa2g[]; MACHINE DEPENDENT RECORD (see XMesaCmplr9.XMesa9d)
XMesa2h[]; --Pointer types, operations
XMesa2i[]; --Type determination
XMesa2j[]; --Balancing
XMesaProcs.PrintS["Done"L];
XMesaProcs.PrintCR;
}; --end of XMesaCall2
XMesa2a:
PROCEDURE = {
--Enumeration types
color: TYPE = {red, orange, yellow, green, blue, violet};
i: CARDINAL;
foreground, background: color;
foreground ¬ orange;
XMesaProcs.Isboolequal[color[red] < color[orange], TRUE, 970, filename];
XMesaProcs.Isboolequal[color[red] < violet, TRUE, 980, filename];
XMesaProcs.Isboolequal[foreground IN [red..violet], TRUE, 990, filename];
XMesaProcs.Isboolequal[FIRST[color] = red, TRUE, 1000, filename];
XMesaProcs.Isboolequal[LAST[color] = violet, TRUE, 1010, filename];
background ¬ VAL[3];
XMesaProcs.Isboolequal[background = green, TRUE, 1020, filename];
i ¬ ORD[background];
XMesaProcs.Isequal[i, 3, 1030, filename];
i ¬ background.ORD;
XMesaProcs.Isequal[i, 3, 1040, filename];
i ¬ color.blue.ORD;
XMesaProcs.Isequal[i, 4, 1050, filename];
IF color.red # color[red] THEN XMesaProcs.PutFailMessage[1030, filename];
};
XMesa2b:
PROCEDURE = {
--Machine dependent enumerations
temp: UNSPECIFIED;
status:
TYPE =
MACHINE
DEPENDENT{
off(0), ready(1), busy(2), finished(4), broken(7)};
tint: TYPE = MACHINE DEPENDENT{red, blue, green, (255)};
palette: ARRAY tint OF INTEGER ¬ ALL[1];
temp ¬ SUCC[status[busy]];
XMesaProcs.Isequal[temp, 3, 1040, filename];
temp ¬ PRED[status[finished]];
XMesaProcs.Isequal[temp, 3, 1050, filename];
temp ¬ FIRST[status];
XMesaProcs.Isequal[temp, 0, 1060, filename];
temp ¬ LAST[status];
XMesaProcs.Isequal[temp, 7, 1070, filename];
XMesaProcs.Isequal[palette[red], 1, 1080, filename];
XMesaProcs.Isequal[palette[blue], 1, 1090, filename];
XMesaProcs.Isequal[palette[green], 1, 1100, filename];
};
XMesa2c:
PROCEDURE = {
--Subrange types
symmetricRange: TYPE = INTEGER [-1..1];
positiveInteger: TYPE = CARDINAL [1..LAST[INTEGER]];
upperCaseLetter: TYPE = CHAR ['A..'Z];
n: CARDINAL [0..10] ¬ 10;
m: INTEGER [-5..5] ¬ -5;
signalRaised: BOOLEAN ¬ FALSE;
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
n ¬ n + 1;
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 1120, filename];
signalRaised ¬ FALSE;
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
n ¬ m;
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 1130, filename];
signalRaised ¬ FALSE;
XMesaProcs.Isboolequal[FIRST[upperCaseLetter] = 'A, TRUE, 1140, filename];
XMesaProcs.Isboolequal[LAST[symmetricRange] = 1, TRUE, 1150, filename];
};
XMesa2e:
PROCEDURE = {
--Arrays and array constructors
temp: LONG POINTER TO ARRAY indextype OF INTEGER;
earningsPerQuarter: ARRAY [1..4] OF INTEGER ¬ [300, 500, 700, 900];
events: DESCRIPTOR FOR ARRAY OF INTEGER;
textarray: TYPE = PACKED ARRAY [0..31] OF CHARACTER;
matrix3by4: TYPE = ARRAY [1..3] OF ARRAY [1..4] OF INTEGER;
mxy: matrix3by4 ¬ ALL[ALL[1]];
indextype: TYPE = [0..10);
arrayType1: TYPE = ARRAY indextype OF INTEGER;
arrayType2: TYPE = ARRAY indextype OF INTEGER;
array1: arrayType1 ¬ ALL[5];
array2: arrayType2 ¬ ALL[6];
dash: ARRAY [0..7] OF CHARACTER ¬ ALL['-];
mxy[3][4] ¬ 0;
XMesaProcs.Isequal[earningsPerQuarter[1], 300, 1180, filename];
XMesaProcs.Isequal[earningsPerQuarter[2], 500, 1190, filename];
XMesaProcs.Isequal[earningsPerQuarter[3], 700, 1200, filename];
XMesaProcs.Isequal[earningsPerQuarter[4], 900, 1210, filename];
FOR begin:
INTEGER
IN [0..7]
DO
XMesaProcs.Ischarequal[dash[begin], '-, 1220, filename]; ENDLOOP;
XMesaProcs.Isequal[LENGTH[earningsPerQuarter], 4, 1220, filename];
XMesaProcs.Isequal[LENGTH[array1], 10, 1230, filename];
temp ¬ BASE[array1];
XMesaProcs.Isequal[temp[0], 5, 1240, filename];
XMesaProcs.Ispointerequal[BASE[array2], @array2[0], 1250, filename];
events ¬ DESCRIPTOR[array1];
XMesaProcs.Isequal[events.LENGTH, 10, 1260, filename];
XMesaProcs.Ispointerequal[events.BASE, @array1[0], 1270, filename];
XMesaProcs.Isequal[mxy[3][4], (mxy[3])[4], 1290, filename];
XMesaProcs.Isequal[(mxy[3][4]), 0, 1300, filename];
mxy[3][4] ¬ 34;
XMesaProcs.Isequal[(mxy[3][4]), 34, 1310, filename];
mxy[3][4] ¬ 1;
FOR begin:
INTEGER
IN [1..3]
DO
XMesaProcs.Isequal[mxy[begin][4], 1, 1320, filename]; ENDLOOP;
array1 ¬ array2;
FOR begin:
INTEGER
IN [0..10)
DO
XMesaProcs.Isequal[array1[begin], 6, 1330, filename]; ENDLOOP;
FOR begin:
INTEGER
IN [0..10)
DO
XMesaProcs.Isboolequal[array1[begin] = array2[begin], TRUE, 1340, filename];
ENDLOOP;
};
XMesa2f: PROCEDURE = { --Record types, operations
militarytime: TYPE = RECORD [hrs: [0..24), mins: [0..60)];
curhrs: [0..24);
curmins: [0..60);
oldtime, newtime: militarytime;
elements: TYPE = RECORD [CARDINAL, INTEGER, BOOLEAN];
element1, element2: elements;
fourbits: TYPE = PACKED ARRAY [0..4) OF BOOLEAN;
boolrecord: RECORD [a, b, c, d: fourbits];
R:
TYPE =
RECORD [
v1: CARDINAL,
v2: CARDINAL ¬ 1,
v3: CARDINAL ¬ 3,
v4: CARDINAL ¬ TRASH,
v5: CARDINAL ¬ 5 | NULL];
R1, R2, R3: R;
signalRaised: BOOLEAN ¬ FALSE;
selements: TYPE = RECORD [CARDINAL[0..10], INT16, BOOLEAN];
selement1: selements;
c: CARDINAL[0..10] ← 3;
oldtime ¬ militarytime[12, 45];
XMesaProcs.Isequal[oldtime.hrs, 12, 1350, filename];
XMesaProcs.Isequal[oldtime.mins, 45, 1360, filename];
newtime ¬ oldtime;
XMesaProcs.Isequal[newtime.hrs, 12, 1370, filename];
XMesaProcs.Isequal[newtime.mins, 45, 1380, filename];
element1 ¬ elements[65535, -32767, TRUE];
element2 ¬ elements[0, 0, FALSE];
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
selement1 ¬ selements[c*4, 0, ];
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 1395, filename];
signalRaised ¬ FALSE;
<<BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
element1 ¬ elements[32000, 0, ];
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 1395, filename];
signalRaised ¬ FALSE;>>
oldtime ¬ militarytime[1, 45];
newtime ¬ militarytime[2, 00];
XMesaProcs.Isnotequal[oldtime.hrs, newtime.hrs, 1400, filename];
boolrecord.a ¬ [TRUE, FALSE, TRUE, FALSE];
boolrecord.b ¬ [TRUE, FALSE, TRUE, FALSE];
boolrecord.c ¬ [TRUE, FALSE, TRUE, FALSE];
boolrecord.d ¬ [TRUE, FALSE, TRUE, FALSE];
XMesaProcs.Isboolequal[
(boolrecord.a = [TRUE, FALSE, TRUE, FALSE]), TRUE, 1420, filename];
XMesaProcs.Isboolequal[
(boolrecord.b = [TRUE, FALSE, TRUE, FALSE]), TRUE, 1430, filename];
XMesaProcs.Isboolequal[
(boolrecord.c = [TRUE, FALSE, TRUE, FALSE]), TRUE, 1440, filename];
XMesaProcs.Isboolequal[
(boolrecord.d = [TRUE, FALSE, TRUE, FALSE]), TRUE, 1450, filename];
R1 ¬ R[v1: 1, v2: 2];
XMesaProcs.Isboolequal[R1.v1 = 1, TRUE, 1460, filename];
XMesaProcs.Isboolequal[R1.v2 = 2, TRUE, 1461, filename];
XMesaProcs.Isboolequal[R1.v3 = 3, TRUE, 1462, filename];
XMesaProcs.Isboolequal[R1.v5 = 5, TRUE, 1463, filename];
R2 ¬ R[v1:, v2: 2, v5:];
XMesaProcs.Isboolequal[R2.v2 = 2, TRUE, 1471, filename];
XMesaProcs.Isboolequal[R2.v3 = 3, TRUE, 1472, filename];
XMesaProcs.Isboolequal[R2.v5 = 5, TRUE, 1473, filename];
R3 ¬ R[v1: 1, v2: 2, v5: NULL];
XMesaProcs.Isboolequal[R3.v1 = 1, TRUE, 1480, filename];
XMesaProcs.Isboolequal[R3.v2 = 2, TRUE, 1481, filename];
XMesaProcs.Isboolequal[R3.v3 = 3, TRUE, 1482, filename];
[curhrs, curmins] ¬ oldtime;
XMesaProcs.Isequal[curhrs, 1, 1490, filename];
XMesaProcs.Isequal[curmins, 45, 1500, filename];
[curhrs] ¬ newtime;
XMesaProcs.Isequal[curhrs, 2, 1510, filename];
};
XMesa2h:
PROCEDURE = {
--Pointer types, operations
unspptr: LONG POINTER TO person;
otherptr: LONG POINTER TO constantrec;
intptr: LONG POINTER TO INTEGER ¬ NIL;
boolptr: LONG POINTER TO BOOL;
constantrec:
TYPE =
RECORD [
age: CARDINAL ¬ 99,
sex: {male, female} ¬ male,
party: {Democratic, Republican} ¬ Democratic];
constant: constantrec;
ROptr: LONG POINTER TO READONLY constantrec ¬ NIL;
person:
TYPE =
RECORD [
age: [0..200], sex: {male, female}, party: {Democratic, Republican}];
candidate1: person;
winner, loser: LONG POINTER TO person;
orderedptr: LONG ORDERED POINTER TO person ¬ NIL;
temp: UNSPECIFIED ¬ 535;
tempp: person;
tempc: constantrec;
intptr ¬ @temp;
XMesaProcs.Isequal[intptr, 535, 1540, filename];
temp ¬ FALSE;
boolptr ¬ @temp;
XMesaProcs.Isboolequal[boolptr, FALSE, 1550, filename];
tempp ¬ person[98, female, Republican];
winner ¬ @tempp;
XMesaProcs.Isboolequal[
winner = [98, female, Republican], TRUE, 1560, filename];
XMesaProcs.Isequal[winner.age, 98, 1570, filename];
tempp ¬ person[99, male, Democratic];
loser ¬ @tempp;
winner ¬ loser;
XMesaProcs.Isboolequal[winner = [99, male, Democratic],
TRUE, 1580, filename];
XMesaProcs.Ispointerequal[winner, loser, 1590, filename];
XMesaProcs.Isboolequal[winner = loser, TRUE, 1600, filename];
winner ¬ loser;
XMesaProcs.Ispointerequal[winner, loser, 1610, filename];
XMesaProcs.Isboolequal[winner = loser, TRUE, 1620, filename];
candidate1 ¬ person[60, male, Republican];
winner ¬ @candidate1;
XMesaProcs.Isboolequal[
(winner = [60, male, Republican]), TRUE, 1630, filename];
tempc ¬ constantrec[99, male, Democratic];
ROptr ← @tempc;
XMesaProcs.Isboolequal[(ROptr=[99,male,Democratic]), TRUE, 1640, filename];
unspptr ¬ @candidate1;
XMesaProcs.Isboolequal[
(unspptr = person[60, male, Republican]), TRUE, 1650, filename];
otherptr ¬ @constant;
XMesaProcs.Isboolequal[(otherptr = constantrec[99, male, Democratic]),
TRUE, 1660, filename];
};
XMesa2i:
PROCEDURE = {
--Type determination
constantrec:
TYPE =
RECORD [
age: CARDINAL ¬ 99,
sex: {male, female} ¬ male,
party: {Democratic, Republican} ¬ Democratic];
constant: constantrec ¬ [0, male, Democratic];
b: BOOL ¬ FALSE;
n: CARDINAL;
XMesaProcs.Isboolequal[ISTYPE[constant, constantrec], TRUE, 1670, filename];
n ¬ LOOPHOLE[b, CARDINAL];
XMesaProcs.Isequal[n, 0, 1675, filename];
LOOPHOLE[n, BOOLEAN] ¬ b;
XMesaProcs.Isboolequal[LOOPHOLE[n, BOOLEAN], FALSE, 1680, filename];
};
XMesa2j: PROCEDURE = { --Balancing
mainline
RunRegressions.RegisterTest[XMesaCall2, "test2"];
END...