File: XMesaProcsImpl.mesa - created by MW. Last edit:
NFS   18-Aug-87 15:26:08
JKF 20-Jul-87 17:52:01
MW 13-Mar-87 10:54:01
Copyright (C) 1987 by Xerox Corporation. All rights reserved.
DIRECTORY
OSOps,
XMesaProcs;
XMesaProcsImpl: PROGRAM IMPORTS OSOps EXPORTS XMesaProcs =
BEGIN
Checkforpos: PUBLIC PROCEDURE [
var1: CHAR, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF LOOPHOLE[var1, INTEGER] < 0 THEN PutFailMessage[testnum, testname];};
Isequal: PUBLIC PROCEDURE [
var1: INTEGER, var2: INTEGER, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
IsCardequal: PUBLIC PROCEDURE [
var1: CARDINAL, var2: CARDINAL, testnum: LONG CARDINAL,
testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
IsLongCardEqual: PUBLIC PROCEDURE [
var1, var2: LONG CARDINAL, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
Isnotequal: PUBLIC PROCEDURE [
var1: INTEGER, var2: INTEGER, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 = var2 THEN PutFailMessage[testnum, testname];};
Isboolequal: PUBLIC PROCEDURE [
var1: BOOLEAN, var2: BOOLEAN, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
Ischarequal: PUBLIC PROCEDURE [
var1, var2: CHAR, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
Islongequal: PUBLIC PROCEDURE [
var1, var2: LONG INTEGER, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
Isrealequal: PUBLIC PROCEDURE [
var1, var2: REAL, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF AlmostEqual[var1, var2, -10] THEN RETURN
ELSE PutFailMessage[testnum, testname];};
Ispointerequal: PUBLIC PROCEDURE [
var1, var2: LONG POINTER TO UNSPECIFIED, testnum: LONG CARDINAL,
testname: LONG STRING] = {
IF var1 # var2 THEN PutFailMessage[testnum, testname];};
Isnotptrequal: PUBLIC PROCEDURE [
var1, var2: LONG POINTER TO UNSPECIFIED, testnum: LONG CARDINAL,
testname: LONG STRING] = {
IF var1 = var2 THEN PutFailMessage[testnum, testname];};
Isnotcharequal: PUBLIC PROCEDURE [
var1, var2: CHAR, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 = var2 THEN PutFailMessage[testnum, testname];};
Isnotboolequal: PUBLIC PROCEDURE [
var1, var2: BOOLEAN, testnum: LONG CARDINAL, testname: LONG STRING] = {
IF var1 = var2 THEN PutFailMessage[testnum, testname];};
PrintCR: PUBLIC PROCEDURE = {
Char[12C]};
PutFailMessage: PUBLIC PROCEDURE [x: LONG CARDINAL, modname: LONG STRING] = {
PrintS["Test "];
PrintLongDecimal[x];
PrintS[" in module "];
PrintS[modname];
PrintS[" failed; "L];
PrintCR[];};
PutPassMessage: PUBLIC PROCEDURE [x: LONG CARDINAL, modname: LONG STRING] = {
PrintS["Test "];
PrintLongDecimal[x];
PrintS[" in module "];
PrintS[modname];
PrintS[" passed; "L];
PrintCR[];};
PrintLongDecimal: PUBLIC PROCEDURE [n: LONG INTEGER] = {
s: LONG STRING ¬ [34];
AppendLongNumber[s, n, 10];
FormatNumber[s: s];};
AppendLongNumber: PROCEDURE [
s: LONG STRING, n: LONG UNSPECIFIED, radix: CARDINAL] = {
ps: POINTER TO LONG STRING = @s;
xn: PROCEDURE [n: LONG CARDINAL] =
BEGIN
lr: LONG CARDINAL ¬ n MOD radix;
r: CARDINAL;
n ¬ n/radix;
IF n # 0 THEN xn[n];
IF (r ¬ CARDINAL[lr]) > 9 THEN r ¬ r + 'A - '0 - 10;
AppendChar[s, r + '0];
END;
xn[n];}; --AppendLongNumber--
FormatNumber: PROCEDURE [
s: LONG STRING] = {
neg: BOOLEAN ¬ FALSE;
l: CARDINAL;
fill: LONG STRING ¬ [8];
fillChar: CHARACTER ¬ ' ;
FOR i: CARDINAL IN [0..8) DO fill[i] ¬ fillChar; ENDLOOP;
IF neg THEN l ¬ s.length + 1 ELSE l ¬ s.length;
IF l < 4 THEN
BEGIN
fillChars: CARDINAL ¬ 4 - l;
THROUGH [0..fillChars/8) DO
PrintS[fill];
ENDLOOP;
IF neg THEN Char['-];
END
ELSE IF neg THEN Char['-];
PrintS[s];};
AppendChar: PROCEDURE [s: LONG STRING, c: CHARACTER] = {
s[s.length] ¬ c;
s.length ¬ s.length + 1;
RETURN};
PrintS: PUBLIC PROCEDURE [s: LONG STRING] = {
FOR i: CARDINAL IN [0..s.length) DO
Char[s[i]];
ENDLOOP;
};
PrintD: PUBLIC PROCEDURE [i: INT] = {
OSOps.PutD[i];
};
AlmostEqual: PUBLIC PROC [y, x: REAL, distance: INTEGER [-126..0]]
RETURNS [BOOLEAN] = {RETURN[x = y];};
Char: PROCEDURE [ch: CHAR] = {OSOps.PutChar[ch];};
GetSystemUZone: PUBLIC PROCEDURE RETURNS [UNCOUNTED ZONE] = {
RETURN[OSOps.GetSystemUZone[]];};
END..