InlineTest.mesa
mna
Foote, October 12, 1992 11:24 am PDT
DIRECTORY
XMesaProcs, RunRegressions;
InlineTest: PROGRAM
IMPORTS RunRegressions, XMesaProcs
= BEGIN
filename: STRING = "InlineTest";
callerType: TYPE = PROCEDURE [i : INTEGER ← 7] ← AnotherProc;
caller: callerType ← OtherProc;
procInt: INTEGER ← 0;
typeWithInit: TYPE = INTEGER ← 6;
DoInlineTests: PROC = {
XMesaProcs.PrintS[filename];
XMesaProcs.PrintCR;
TestSimpleConsts[]; -- simple constant use / declaration
TestComplexConsts[]; -- complex constant use / declaration
TestComplexBuiltins[]; -- complex builtin constant use
TestProcVariables[]; -- constant procs variable
};
globalConstA: CARDINAL = 41;
globalConstB: INTEGER = 42;
globalConstC: INTEGER = globalConstA - globalConstB;
globalCardinal: CARDINAL;
TestSimpleConsts: PROC[] = {
a: INTEGER = 6;
b: INTEGER = 3;
c: INTEGER ← a;
XMesaProcs.Isequal[a, c, 10, filename];
XMesaProcs.Isequal[a, 6, 13, filename];
XMesaProcs.Isequal[c, 6, 15, filename];
c ← b;
XMesaProcs.Isequal[b, c, 20, filename];
c ← globalConstA;
XMesaProcs.Isequal[globalConstA, c, 30, filename];
globalCardinal ← globalConstA;
XMesaProcs.Isequal[globalConstA, globalCardinal, 50, filename];
XMesaProcs.Isequal[globalConstA, 41, 55, filename];
globalCardinal ← a;
XMesaProcs.Isequal[a, globalCardinal, 60, filename];
c ← a - b;
XMesaProcs.Isequal[a - b, c, 70, filename];
XMesaProcs.Isequal[3, c, 80, filename];
};
z: ZONE = NIL;
p: PROCESS = NIL;
s: STRING = NIL;
TestComplexConsts: PROC[] = {
a: typeWithInit;
b: typeWithInit ← 7;
c: typeWithInit = 8;
XMesaProcs.Isequal[7, b, 300, filename];
XMesaProcs.Isequal[8, c, 310, filename];
XMesaProcs.Isequal[6, a, 320, filename];
};
TestComplexBuiltins: PROC[] = {
zVar: ZONE;
pVar: PROCESS;
sVar: STRING;
sVar ← s;
--pVar ← p;
zVar ← z;
IF ~ProcProcedure[pVar] THEN
XMesaProcs.PutFailMessage[100, filename];
--IF ~ProcProcedure[p] THEN XMesaProcs.PutFailMessage[110, filename];
--IF ~ProcProcedure[] THEN XMesaProcs.PutFailMessage[120, filename];
IF ~StringProcedure[sVar] THEN
XMesaProcs.PutFailMessage[130, filename];
IF ~StringProcedure[s] THEN
XMesaProcs.PutFailMessage[140, filename];
IF ~StringProcedure[] THEN
XMesaProcs.PutFailMessage[150, filename];
IF ~ZoneProcedure[zVar] THEN
XMesaProcs.PutFailMessage[160, filename];
IF ~ZoneProcedure[z] THEN
XMesaProcs.PutFailMessage[170, filename];
IF ~ZoneProcedure[] THEN
XMesaProcs.PutFailMessage[180, filename];
};
ProcProcedure: PROCEDURE [theProcess: PROCESS ← p] RETURNS [BOOL] = {
RETURN [theProcess = NIL];
};
StringProcedure: PROCEDURE [theString: STRING ← s] RETURNS [BOOL] = {
RETURN [theString = NIL];
};
ZoneProcedure: PROCEDURE [theZone: ZONE ← z] RETURNS [BOOL] = {
RETURN [theZone = NIL];
};
TestProcVariables: PROCEDURE = {
c: callerType ← Doit;
d: callerType;
d[]; -- call AnotherProc, procInt = 8
c[7]; -- call Doit, procInt = 10
caller[]; -- call OtherProc, procInt = 11
InlineProc[]; -- procInt = 15
XMesaProcs.Isequal[procInt, 15, 400, filename];
};
InlineProc: callerType = INLINE {
XMesaProcs.Isequal[i, 7, 430, filename];
procInt ← procInt + 4;
};
Doit: callerType = {
XMesaProcs.Isequal[i, 7, 410, filename];
procInt ← procInt + 2;
};
OtherProc: callerType = {
XMesaProcs.Isequal[i, 7, 420, filename];
procInt ← procInt + 1;
};
AnotherProc: callerType = {
XMesaProcs.Isequal[i, 7, 440, filename];
procInt ← procInt + 8;
};
ExternalNames: PROC = MACHINE CODE {
"^ExternalNames\n";
"MumbleProc MumbleProc\n";
};
RunRegressions.RegisterTest[DoInlineTests, "InlineTests"];
END.