XMesaCmplr9:
PROGRAM
IMPORTS RunRegressions, XMesaProcs =
BEGIN
filename: LONG STRING = "XMesaCmplr9"L;
XMesaCall9:
PROCEDURE = {
XMesaProcs.PrintS[filename];
XMesaProcs.PrintCR;
XMesa9a[]; --Machine dependent basic Built-in Types
XMesa9b[]; --Numeric subranges
XMesa9c[]; --Arrays and array constructors
XMesa9d[]; --MACHINE DEPENDENT RECORD
XMesa9e[]; --Record types, operations
XMesa9f[]; --VARIANT RECORDs
XMesa9g[]; --Bounds faults
XMesaProcs.PrintS["Done"L];
XMesaProcs.PrintCR;
}; --end of XMesaCall1
CSize:
CARDINAL =
SIZE[
CARDINAL];
conditional compilation hack:
CSize = 1 for PrincOps
CSize = 2 for 80386
CSize = 4 for Sun 3/4
The test should keep this module from being compiled with non-Sun compilers
checkCSize: BOOL [TRUE..TRUE] = (CSize = 4);
XMesa9a:
PROCEDURE = {
Machine dependent basic Built-in Types
check number of words each type occupies
firstInt: INTEGER = LOOPHOLE[80000000H];
minusOne: INTEGER ← -1;
realLastCard: CARDINAL = LOOPHOLE[minusOne];
testLastCard: CARDINAL ← LAST[CARDINAL];
testLastLongCard: LONG CARDINAL ← LAST[LONG CARDINAL];
XMesaProcs.Isequal[SIZE[INTEGER], 4, 800, filename];
XMesaProcs.Isequal[SIZE[LONG INTEGER], 4, 810, filename];
XMesaProcs.Isequal[SIZE[CARDINAL], 4, 820, filename];
XMesaProcs.Isequal[SIZE[LONG CARDINAL], 4, 830, filename];
XMesaProcs.Isequal[SIZE[REAL], 4, 840, filename];
XMesaProcs.Isequal[SIZE[BOOL], 4, 850, filename];
XMesaProcs.Isequal[SIZE[CHAR], 4, 860, filename];
This is also a bug in the princops compiler:
XMesaProcs.Isequal[FIRST[INTEGER], firstInt, 870, filename];
XMesaProcs.Isequal[LAST[INTEGER], 7FFFFFFFH, 880, filename];
XMesaProcs.IsLongCardEqual[FIRST[CARDINAL], 0, 890, filename];
XMesaProcs.IsLongCardEqual[testLastCard, realLastCard, 900, filename];
XMesaProcs.Islongequal[FIRST[LONG INTEGER], firstInt, 910, filename];
XMesaProcs.Islongequal[LAST[LONG INTEGER], 7FFFFFFFH, 920, filename];
XMesaProcs.IsLongCardEqual[FIRST[LONG CARDINAL], 0, 925, filename];
XMesaProcs.IsLongCardEqual[testLastLongCard, realLastCard, 930, filename];
};
XMesa9b:
PROCEDURE = {
--Numeric subranges
s1: TYPE = [-10..10];
s2: TYPE = [100..33000];
tint: TYPE = MACHINE DEPENDENT{red, blue, green, (255)};
XMesaProcs.Isequal[SIZE[s1], 4, 1160, filename];
XMesaProcs.Islongequal[SIZE[s2], 4, 1170, filename];
XMesaProcs.Isequal[SIZE[tint], 4, 1110, filename];
};
XMesa9c:
PROCEDURE = {
--Arrays and array constructors
textarray: TYPE = PACKED ARRAY [0..31] OF CHARACTER;
XMesaProcs.Isequal[SIZE[textarray], 32, 1280, filename];
};
XMesa9d:
PROCEDURE = {
--MACHINE DEPENDENT RECORDS
nchannels: INTEGER = 8;
DeviceNumber: TYPE = [0..255];
ChannelCommand: TYPE = [0..65000];
InterruptWord:
TYPE =
MSBIT
WORD16
MACHINE
DEPENDENT
RECORD [
channel(0:8..10): [0..nchannels),
device(0:0..7): DeviceNumber,
stopCode(0:11..15):
MACHINE
DEPENDENT{
finishedOK(0), errorStop(1), powerOff(3)},
command(1:0..15): ChannelCommand];
Interrupt: InterruptWord;
XMesaProcs.Isequal[SIZE[InterruptWord], 4, 1520, filename];
Interrupt.channel ¬ 1;
Interrupt.device ¬ 250;
Interrupt.stopCode ¬ finishedOK;
Interrupt.command ¬ 60000;
XMesaProcs.Isboolequal[(Interrupt = [1, 250, finishedOK, 60000]), TRUE, 1530, filename];
};
XMesa9e:
PROCEDURE = {
--Record types, operations
militarytime: TYPE = RECORD [hrs: [0..24), mins: [0..60)];
elements: TYPE = RECORD [CARDINAL, INTEGER, BOOLEAN];
XMesaProcs.Isequal[SIZE[elements], 12, 1390, filename];
XMesaProcs.Isequal[SIZE[militarytime], 8, 1410, filename];
};
XMesa9f:
PROCEDURE = {
--Record types, operations
StreamType: TYPE = {disk, display, keyboard};
Stream:
TYPE =
RECORD [
Get: INTEGER,
Put: INTEGER,
body:
SELECT type: StreamType
FROM
disk => [
fileid: INTEGER,
buffer:
SELECT size: *
FROM
short => [b: CARDINAL],
long => [b: INTEGER],
ENDCASE],
display => [first: BOOL, last: INTEGER, nlines: [0..100]],
keyboard => [keys: INTEGER],
ENDCASE];
XMesaProcs.Isequal[SIZE[disk Stream], 24, 3090, filename];
};
XMesa9g:
PROCEDURE = {
-- bounds checking
long to short conversion
if b is requested the compiler checks the suitability of long to
short conversion
i: INTEGER ¬ 1;
li: LONG INTEGER ¬ 2;
c: CARDINAL ¬ 3;
S: TYPE = [0..10);
s: S;
signalRaised: BOOLEAN ¬ FALSE;
s ¬ 4;
i ¬ li;
XMesaProcs.Isequal[i, 2, 590, filename];
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
li ¬ FIRST[LONG INTEGER];
i ¬ INTEGER[li];
END;
XMesaProcs.Isboolequal[signalRaised, FALSE, 595, filename];
signalRaised ¬ FALSE;
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
c ¬ li;
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 600, filename];
signalRaised ¬ FALSE;
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
c ¬ CARDINAL[li];
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 610, filename];
signalRaised ¬ FALSE;
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
s ¬ li;
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 620, filename];
signalRaised ¬ FALSE;
BEGIN
ENABLE ANY => {signalRaised ¬ TRUE; CONTINUE};
s ¬ S[li];
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 630, filename];
signalRaised ¬ FALSE;
};
mainline
RunRegressions.RegisterTest[XMesaCall9, "test9"];
END...