Test: Commander.CommandProc = {
time: BasicTime.Pulses;
foos, foos2: Foos;
IO.PutF[cmd.out, "Testing constructors; "];
IF EqLists[foos1, NIL] THEN ERROR;
IF NOT EqLists[foos1, foos1] THEN ERROR;
IF Member[foo3, foos1] THEN ERROR;
IF NOT Member[foo2, foos1] THEN ERROR;
foos ← CONS [foo3, foos1];
IF Length[foos]#3 THEN ERROR;
foos ← NARROW [Append[foos, foos1]];
IF Length[foos]#5 THEN ERROR;
foos ← NARROW [Copy[foos]];
IF Length[foos]#5 THEN ERROR;
foos ← NARROW [Reverse[foos]];
foos is foo2 foo1 foo2 foo1 foo3
IF Length[foos]#5 THEN ERROR;
foos ← NARROW [Remove[foo1, foos]];
IF Length[foos]#3 THEN ERROR;
foos ← NARROW [Remove[foo1, foos]];
IF Length[foos]#3 THEN ERROR;
foos ← NARROW [Union[foos1, foos]];
IF Length[foos]#4 THEN ERROR;
foos ← NARROW [Intersection[foos1, foos]];
IF Length[foos]#2 THEN ERROR;
foos ← NARROW [ListDifference[foos1, foos]];
IF Length[foos]#0 THEN ERROR;
IO.PutF[cmd.out, "Testing destructive constructors; "];
foos ← NARROW [Copy[foos1]];
foos ← NARROW [Nconc[foos, Copy[foos]]];
IF Length[foos]#4 THEN ERROR;
foos ← NARROW [Nconc[foos, foos2 ← LIST [foo1]]];
IF Length[foos]#5 THEN ERROR;
foos ← NARROW [DReverse[foos]];
IF Length[foos]#5 THEN ERROR;
foos ← NARROW [DRemove[foo1, foos]];
IF Length[foos]#4 THEN ERROR;
foos ← NARROW [DSubst[foo1, foo2, foos]];
IF Length[foos]#4 THEN ERROR;
IF foos1.first#foo1 THEN ERROR;
foos ← NARROW [NthTail[foos, 2]];
IF Length[foos]#2 THEN ERROR;
IF NthElement[foos, 2]#foo1 THEN ERROR;
foos ← NARROW [Copy[Append[foos1, foos1]]];
foos ← NARROW [Subst[foo1, foo2, foos]];
foos2 ← LIST [foo1, foo1, foo1, foo1];
IF NOT EqLists[foos, foos2] THEN ERROR;
IO.PutF[cmd.out, "Testing sorts; "];
foos ← NARROW [Copy[Append[foos1, foos1]]];
foos ← NARROW [Sort[foos, Compare]];
foos2 ← LIST [foo1, foo1, foo2, foo2];
IF NOT EqLists[foos, foos2] THEN ERROR;
foos ← NARROW [UniqueSort[foos, Compare]];
IF NOT EqLists[foos, foos1] THEN ERROR;
IO.PutF[cmd.out, "Timing; "];
foos2 ← foos ← NIL;
THROUGH [1 .. 4000] DO foos ← CONS [foo1, foos] ENDLOOP;
SafeStorage.ReclaimCollectibleObjects[TRUE];
SafeStorage.ReclaimCollectibleObjects[TRUE];
time ← BasicTime.GetClockPulses[];
UNTIL foos =
NIL
DO
foos2 ← CONS [foos.first, foos2];
foos ← foos.rest;
ENDLOOP;
time ← BasicTime.GetClockPulses[] - time;
IO.PutF[cmd.out, "Typed Reverse %g us ; ", IO.int[BasicTime.PulsesToMicroseconds[time]]];
foos2 ← foos ← NIL;
THROUGH [1 .. 4000] DO foos ← CONS [foo1, foos] ENDLOOP;
SafeStorage.ReclaimCollectibleObjects[TRUE];
SafeStorage.ReclaimCollectibleObjects[TRUE];
time ← BasicTime.GetClockPulses[];
foos2 ← NARROW [Reverse[foos]];
time ← BasicTime.GetClockPulses[] - time;
IO.PutF[cmd.out, "GList Reverse %g us ; ", IO.int[BasicTime.PulsesToMicroseconds[time]]];
IO.PutF[cmd.out, "Test done\n"];
};