(*
Title:  (*
Title:  TestVectors
Author: Xiaoyang Yu
Revised: 25-OCT-2002
  
Description: Black-Box test for any module named Vectors implementing MIS for Vectors ADT.

Module Interface Specification:
INTERFACE TestVectors;
END TestVectors.
*)


MODULE TestVectors;

IMPORT Out, Vectors;
     
(* Basic Test Procedure *)
PROCEDURE Test(x1,y1,x2,y2,r: REAL);
VAR  x,y: REAL; 
     v1,v2,sum,mul: Vectors.Vector;
BEGIN
  (* Displaying the giving inputs *)
  Out.String("*** Testing (x1,y1,x2,y2)=(");
  Out.Real(x1);  Out.String(",");
  Out.Real(y1);  Out.String(",");
  Out.Real(x2);  Out.String(",");
  Out.Real(y2);  Out.String("), r=");  
  Out.Real(r);   Out.String("***"); Out.Ln;
  
  (* Testing GetVec Procedure *)
  v1 := Vectors.GetVec(x1,y1);
  v2 := Vectors.GetVec(x2,y2);
  Out.String("GetVec v1 of (x1, y1) = (");
  Output(Vectors.XVal(v1),Vectors.YVal(v1));  
  Out.String("GetVec v2 of (x2, y2) = (");
  Output(Vectors.XVal(v2),Vectors.YVal(v2));   
  
  (* Testing XVal,YVal Procedures *)
  x := Vectors.XVal(v1);
  y := Vectors.YVal(v1);
  Out.String("XVal of v1= ");
  Out.Real(x);
  Out.String("; YVal of v1= ");
  Out.Real(y); Out.Ln;
  
  (* Testing Add Procedure *)
  sum := Vectors.Add(v1,v2);
  Out.String("v1 + v2 = (");
  Output(Vectors.XVal(sum),Vectors.YVal(sum));   
   
  (* Testing Mul Procedure *) 
  mul := Vectors.Mul(r,v1);
  Out.String("r * v1 = (");
  Output(Vectors.XVal(mul),Vectors.YVal(mul));   
END Test;

PROCEDURE Output(x,y: REAL);
BEGIN
  Out.Real(x);  Out.String(", ");
  Out.Real(y);  Out.String(")");   Out.Ln; 
END Output;

(* The Test *)
BEGIN
  Test(1,1,2,3,5); 
  Test(4,-6,4,-6,2); 
  Test(10.5,-6.5,4.6,-7.6,-2); 
  Test(Vectors.XVal(Vectors.Zero),Vectors.YVal(Vectors.Zero),2,3,0);
END TestVectors.