-- IntervalTimerTest.mesa
Last Edited by: Swinehart, May 16, 1984 10:03:39 am PDT
Last Edited by: L. Stewart December 27, 1983 3:33 pm
DIRECTORY
IntervalTimer,
IO,
Process,
Commander;
IntervalTimerTest: PROGRAM
IMPORTS IntervalTimer, IO, Process, Commander = {
out: IO.STREAM;
SetStream: Commander.CommandProc =
TRUSTED {
out ← cmd.out;
};
Test: Commander.CommandProc =
TRUSTED {
out ← cmd.out;
out.PutRope["Should print ten large numbers, at one second intervals, beginning in one second.\n"];
Start[4 * 1000000];
Start[10 * 1000000];
Start[1 * 1000000];
Start[8 * 1000000];
Start[5 * 1000000];
Start[9 * 1000000];
Start[2 * 1000000];
Start[6 * 1000000];
Start[3 * 1000000];
Start[7 * 1000000];
};
Uest: Commander.CommandProc =
TRUSTED {
out ← cmd.out;
out.PutRope["Should print two large numbers immediately, "];
out.PutRope["then ten large numbers, at one second intervals, beginning in one second, "];
out.PutRope["except that the numbers at seven and nine seconds should be missing.\n"];
TTart[IntervalTimer.Now[] + 4000000];
TTart[IntervalTimer.Now[] + 10000000];
TTart[IntervalTimer.Now[] + 1000000];
TTart[IntervalTimer.Now[] + 8000000];
TTart[IntervalTimer.Now[] + 5000000];
TTart[IntervalTimer.Now[] - 9000000];
TTart[IntervalTimer.Now[] + 2000000];
TTart[IntervalTimer.Now[] + 6000000];
TTart[IntervalTimer.Now[] + 3000000];
TTart[IntervalTimer.Now[] - 7000000];
};
Start: PROC[pulses: LONG CARDINAL] = {
Process.Detach[FORK Wait[pulses]];
};
TTart: PROC[pulses: LONG CARDINAL] = {
Process.Detach[FORK Xait[pulses]];
};
Wait: PROC[pulses: LONG CARDINAL] = {
IntervalTimer.WaitForExpirationInterval[pulses];
IF out # NIL THEN out.PutF["%d\n", IO.card[pulses]];
};
Xait: PROC[pulses: LONG CARDINAL] = {
IntervalTimer.WaitForExpirationTime[pulses];
IF out # NIL THEN out.PutF["%d\n", IO.card[pulses]];
};
Now: PROC RETURNS [pulses: LONG CARDINAL] = {
RETURN[IntervalTimer.Now[]];
};
NowInPulses: PROC RETURNS [pulses: LONG CARDINAL] = {
RETURN[IntervalTimer.NowInPulses[]];
};
Commander.Register["ITTest", Test, "Test IntervalTimer"];
Commander.Register["JTTest", Uest, "Test IntervalTimer another way"];
Commander.Register["SetStream", SetStream, "Set printout stream for IntervalTimer test"];
}.
December 27, 1983 3:33 pm, Stewart, Cedar 5