DIRECTORY RegressUtils;
RegressArray: CEDAR PROGRAM
IMPORTS RegressUtils
= BEGIN
TestInt: PROC = {
localArrayOfInt: ArrayOfInt ← ALL[0];
FOR i: ArrayOfIntIndex IN ArrayOfIntIndex DO
RegressUtils.Test[localArrayOfInt[i] # 0, "TestInt: localArrayOfInt[i] # 0"];
localArrayOfInt[i] ← i;
RegressUtils.Test[localArrayOfInt[i] # i, "localArrayOfInt[i] # i"];
RegressUtils.Test[globalArrayOfInt[i] # 0, "globalArrayOfInt[i] # 0"];
globalArrayOfInt[i] ← i;
RegressUtils.Test[globalArrayOfInt[i] # i, "globalArrayOfInt[i] # i"];
ENDLOOP;
globalArrayOfInt ← ALL[0];
FOR i: ArrayOfIntIndex IN ArrayOfIntIndex DO
RegressUtils.Test[globalArrayOfInt[i] # 0, "globalArrayOfInt[i] # 0"];
ENDLOOP;
};
TestRef: PROC = {
localArrayOfRef: ArrayOfRef ← ALL[NIL];
FOR i: ArrayOfRefIndex IN ArrayOfRefIndex DO
RegressUtils.Test[localArrayOfRef[i] # NIL, "localArrayOfRef[i] # NIL"];
localArrayOfRef[i] ← globalAtomArray[i];
RegressUtils.Test[localArrayOfRef[i] # globalAtomArray[i],
"localArrayOfRef[i] # globalAtomArray[i]"];
RegressUtils.Test[globalArrayOfRef[i] # NIL, "globalArrayOfRef[i] # NIL"];
globalArrayOfRef[i] ← globalAtomArray[i];
RegressUtils.Test[globalArrayOfRef[i] # globalAtomArray[i],
"globalArrayOfRef[i] # globalAtomArray[i]"];
ENDLOOP;
globalArrayOfRef ← ALL[NIL];
FOR i: ArrayOfRefIndex IN ArrayOfRefIndex DO
RegressUtils.Test[globalArrayOfRef[i] # NIL, "globalArrayOfRef[i] # NIL"];
ENDLOOP;
};
TestPackedOfBit: PROC = {
PackedBits: TYPE = PACKED ARRAY PackedBitsIndex OF BIT;
PackedBitsIndex: TYPE = [0..8);
LongPackedBits: TYPE = PACKED ARRAY LongPackedBitsIndex OF BIT;
LongPackedBitsIndex: TYPE = [0..8*BITS[WORD]);
pba: PackedBits ← ALL[0];
lpba: LongPackedBits ← ALL[0];
FOR i: PackedBitsIndex IN PackedBitsIndex DO
RegressUtils.Test[pba[i] # 0, "pba[i] # 0 (after init to ALL[0])"];
pba[i] ← i MOD 2;
RegressUtils.Test[pba[i] # i MOD 2, "lpba[i] # i MOD 2"];
ENDLOOP;
pba ← [0, 1, 0, 1, 0, 1, 0, 1];
FOR i: PackedBitsIndex IN PackedBitsIndex DO
RegressUtils.Test[pba[i] # i MOD 2, "pba[i] # i MOD 2"];
ENDLOOP;
pba ← ALL[1];
FOR i: PackedBitsIndex IN PackedBitsIndex DO
RegressUtils.Test[pba[i] # 1, "pba[i] # 1 (after pba := ALL[1])"];
ENDLOOP;
RegressUtils.Test[LOOPHOLE[pba, CARDINAL] # 255,
"LOOPHOLE[pba, CARDINAL] # 255 (after pba := ALL[1])"];
FOR i: LongPackedBitsIndex IN LongPackedBitsIndex DO
RegressUtils.Test[lpba[i] # 0, "lpba[i] # 0 (after init to ALL[0])"];
lpba[i] ← i MOD 2;
RegressUtils.Test[lpba[i] # i MOD 2, "lpba[i] # i MOD 2"];
ENDLOOP;
lpba ← ALL[0];
FOR i: LongPackedBitsIndex IN LongPackedBitsIndex DO
RegressUtils.Test[lpba[i] # 0, "lpba[i] # 0 (after lpba ← ALL[0])"];
ENDLOOP;
lpba ← ALL[1];
FOR i: LongPackedBitsIndex IN LongPackedBitsIndex DO
RegressUtils.Test[lpba[i] # 1, "lpba[i] # 1 (after lpba ← ALL[1])"];
ENDLOOP;
};
ArrayOfInt: TYPE = ARRAY ArrayOfIntIndex OF INT;
ArrayOfIntIndex: TYPE = [0..8);
ArrayOfRef: TYPE = ARRAY ArrayOfRefIndex OF REF;
ArrayOfRefIndex: TYPE = [0..8);
globalArrayOfInt: ArrayOfInt ← ALL[0];
globalArrayOfRef: ArrayOfRef ← ALL[NIL];
globalAtomArray: ArrayOfRef ← [$a0, $a1, $a2, $a3, $a4, $a5, $a6, $a7];
TestArray: PROC = {
RegressUtils.NoteProc["RegressArray.TestInt"];
TestInt[];
RegressUtils.NoteProc["RegressArray.TestRef"];
TestRef[];
RegressUtils.NoteProc["RegressArray.TestPackedOfBit"];
TestPackedOfBit[];
};
RegressUtils.Register["RegressArray", TestArray];
END.