TestMonitorSCPmCode.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created: October 12, 1987 5:52:44 pm PDT
Pradeep Sindhu October 14, 1987 0:04:01 am PDT
Tests Monitoring code.
DIRECTORY
CommandTool, MonitorSCPmCode, Rope;
TestMonitorSCPmCode: CEDAR PROGRAM
IMPORTS CommandTool, MonitorSCPmCode
~ BEGIN
IndexType: TYPE = {Label, ReturnAddress, IOAddr};
Index: ARRAY IndexType OF NATALL [0];
-- Begin Labels
PC0: NAT = Next[Label];
PC1: NAT = Next[Label];
PC2: NAT = Next[Label];
PC3: NAT = Next[Label];
PC4: NAT = Next[Label];
PC5: NAT = Next[Label];
-- End Labels
MaxPC: NAT = Next[Label];
Next: PROC [it: IndexType] RETURNS [index: NAT] = {
index ← Index[it];
Index[it] ← Index[it]+1;
};
Simple: PROC [p, newPC: NAT] = {
vs: PROC [ix: NAT] RETURNS [NAT] = {
RETURN[ix]
};
Jmp: PROC [dest: NAT] = {
PC ← dest;
MonitorSCPmCode.RecordPC[h, PC]
};
SELECT p FROM
= 0 => NULL;
= 1 => NULL;
= 2 => {
SELECT vs[PC] FROM -- Begin Transitions
= PC0 => {
Jmp[PC1];
};
= PC1 => {
SELECT newPC FROM
= 2 => Jmp[PC2];
ENDCASE => Jmp[PC3]
};
= PC2 => {
Jmp[PC4];
};
= PC3 => {
Jmp[PC4];
};
= PC4 => {
Jmp[PC5];
};
= PC5 => {
Jmp[PC0];
};
ENDCASE => ERROR; -- End Transitions
};
ENDCASE => ERROR;
};
Test: PROC [] = {
PCPC0;
MonitorSCPmCode.RecordPC[h, PC];
Simple[2, 0]; --> PC1
Simple[2, 2]; --> PC2
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Simple[2, 0]; --> PC0
Simple[2, 0]; --> PC1
Simple[2, 3]; --> PC3
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Simple[2, 0]; --> PC0
Simple[2, 0]; --> PC1
Simple[2, 3]; --> PC3
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Simple[2, 0]; --> PC0
Simple[2, 0]; --> PC1
Simple[2, 2]; --> PC2
Simple[2, 0]; --> PC4
Simple[2, 0]; --> PC5
Finally, cause a disallowed transition (from PC5 to PC5)
MonitorSCPmCode.RecordPC[h, PC5];
MonitorSCPmCode.PrintUnVisitedPaths[h, LAST[NAT]];
ERROR
};
PC: NAT;
wDir: Rope.ROPE ← CommandTool.CurrentWorkingDirectory[];
h: MonitorSCPmCode.Handle ← MonitorSCPmCode.ParseMCode["TestMonitorSCPmCode.mesa", wDir];
END.