TestSharedErrors.mesa
Copyright Ó 1990, 1992 by Xerox Corporation. All rights reserved.
Chauser, January 25, 1991 2:29 pm PST
DIRECTORY
Commander,
IO,
SharedErrors USING [Fork],
RuntimeError USING [UNCAUGHT];
TestSharedErrors: CEDAR PROGRAM
IMPORTS Commander, IO, RuntimeError, SharedErrors
~ BEGIN
e1: ERROR [i, j: INT ] ~ CODE;
Test0: PROC [] RETURNS [x, y, z: INT ¬ 0] ~ { -- 1, 1, 1 --
ENABLE RuntimeError.UNCAUGHT => {GOTO out};
p1: PROC [] RETURNS [] ~ {
x ¬ 1;
};
p2: PROC [] RETURNS [] ~ {
y ¬ 1;
};
TRUSTED {SharedErrors.Fork[LIST[p1, p2]]};
z ¬ 1;
EXITS
out => NULL;
};
Test1: PROC [] RETURNS [x, y, z: INT ¬ 0] ~ { -- 1, 1, 0 --
ENABLE RuntimeError.UNCAUGHT => {GOTO out};
p1: PROC [] RETURNS [] ~ {
x ¬ 1;
};
p2: PROC [] RETURNS [] ~ {
y ¬ 1;
ERROR e1[14, 27];
};
TRUSTED {SharedErrors.Fork[LIST[p1, p2]]};
z ¬ 1;
EXITS
out => NULL;
};
Test2: PROC [] RETURNS [x, y, z: INT ¬ 0] ~ { -- 14, 27, 0 or 1, 27, 0 --
ENABLE e1 => {x ¬ i; y ¬ j; GOTO out};
p1: PROC [] RETURNS [] ~ {
x ¬ 1;
};
p2: PROC [] RETURNS [] ~ {
y ¬ 1;
ERROR e1[14, 27];
};
TRUSTED {SharedErrors.Fork[LIST[p1, p2]]};
z ¬ 1;
EXITS
out => NULL;
};
sig1: SIGNAL [i, j: INT ] RETURNS [INT] ~ CODE;
Test3: PROC [] RETURNS [x, y, z: INT ¬ 0] ~ { -- 27, 14, 5 or 1, 14, 5 --
ENABLE sig1 => {x ¬ j; y ¬ 2; RESUME[i]};
p1: PROC [] RETURNS [] ~ {
x ¬ 1;
};
p2: PROC [] RETURNS [] ~ {
y ¬ 1;
y ¬ SIGNAL sig1[14, 27];
z ¬ 2;
};
TRUSTED {SharedErrors.Fork[LIST[p1, p2]]};
z ¬ z+3;
};
Test4: PROC [] RETURNS [x, y, z: INT ¬ 0] ~ { -- 45, 140, 83 --
ENABLE sig1 => {z ¬ z+j; RESUME[i]};
p1: PROC [] RETURNS [] ~ {
y ¬ 0;
FOR i: INT IN [0..10) DO
y ¬ y + sig1[14, 1];
ENDLOOP;
};
p2: PROC [] RETURNS [] ~ {
x ¬ 0;
FOR i: INT IN [0..10) DO
x ¬ x + sig1[i, 7];
ENDLOOP;
};
TRUSTED {SharedErrors.Fork[LIST[p1, p2]]};
z ¬ z+3;
};
DoTest0: Commander.CommandProc ~ {
x, y, z: INT;
[x, y, z] ¬ Test0[];
IO.PutF[cmd.out, "%g %g %g\n", [integer[x]], [integer[y]], [integer[z]] ];
};
DoTest1: Commander.CommandProc ~ {
x, y, z: INT;
[x, y, z] ¬ Test1[];
IO.PutF[cmd.out, "%g %g %g\n", [integer[x]], [integer[y]], [integer[z]] ];
};
DoTest2: Commander.CommandProc ~ {
x, y, z: INT;
[x, y, z] ¬ Test2[];
IO.PutF[cmd.out, "%g %g %g\n", [integer[x]], [integer[y]], [integer[z]] ];
};
DoTest3: Commander.CommandProc ~ {
x, y, z: INT;
[x, y, z] ¬ Test3[];
IO.PutF[cmd.out, "%g %g %g\n", [integer[x]], [integer[y]], [integer[z]] ];
};
DoTest4: Commander.CommandProc ~ {
x, y, z: INT;
[x, y, z] ¬ Test4[];
IO.PutF[cmd.out, "%g %g %g\n", [integer[x]], [integer[y]], [integer[z]] ];
};
Commander.Register["TestSharedErrors0", DoTest0];
Commander.Register["TestSharedErrors1", DoTest1];
Commander.Register["TestSharedErrors2", DoTest2];
Commander.Register["TestSharedErrors3", DoTest3];
Commander.Register["TestSharedErrors4", DoTest4];
END.