Browse Source

* test for operators in different units improoved

pierre 25 năm trước cách đây
mục cha
commit
25d48db77a
4 tập tin đã thay đổi với 87 bổ sung3 xóa
  1. 2 2
      tests/test/testop.pp
  2. 18 0
      tests/test/testop1.pp
  3. 47 1
      tests/test/testop2.pp
  4. 20 0
      tests/test/testop3.pp

+ 2 - 2
tests/test/testop.pp

@@ -9,7 +9,7 @@ begin
   a.x:=67;a.y:=-45;
   b.x:=89;b.y:=23;
   c:=a+b;
-  e.x:=67;e.y:=-45;
-  f.x:=89;f.y:=23;
+  e.x:=67;e.y:=-45;e.z:=67;
+  f.x:=89;f.y:=23;f.z:=56;
   d:=e+f;
 end.

+ 18 - 0
tests/test/testop1.pp

@@ -11,10 +11,28 @@ operator + (const a,b : op1) c : op1;
 
 implementation
 
+uses
+  testop2;
+
 operator + (const a,b : op1) c : op1;
 begin
   c.x:=a.x+b.x;
   c.y:=a.y+b.y;
 end;
 
+procedure test_op2;
+var
+  a,b,c : op2;
+begin
+  a.x:=44;
+  a.y:=67;
+  b.x:=-34;
+  b.y:=-57;
+  c:=a+b;
+  if (c.x<>10) or (c.y<>10) then
+    Halt(1);
+end;
+
+begin
+  test_op2;
 end.

+ 47 - 1
tests/test/testop2.pp

@@ -4,17 +4,63 @@ interface
 
 type
   op2 = record
-    x,y : longint;
+    x,y,z : longint;
   end;
 
 operator + (const a,b : op2) c : op2;
 
 implementation
 
+uses
+  testop1,testop3;
+
 operator + (const a,b : op2) c : op2;
 begin
   c.x:=a.x+b.x;
   c.y:=a.y+b.y;
 end;
 
+procedure test_op3;
+var
+  a,b,c : op3;
+begin
+  a.x:=44.0;
+  a.y:=67.0;
+  b.x:=-34.0;
+  b.y:=-57.0;
+  c:=a+b;
+  if (c.x<>10.0) or (c.y<>10.0) then
+    Halt(1);
+end;
+
+procedure test_op2;
+var
+  a,b,c : op2;
+begin
+  a.x:=44;
+  a.y:=67;
+  b.x:=-34;
+  b.y:=-57;
+  c:=a+b;
+  if (c.x<>10) or (c.y<>10) then
+    Halt(1);
+end;
+
+procedure test_op1;
+var
+  a,b,c : op1;
+begin
+  a.x:=44;
+  a.y:=67;
+  b.x:=-34;
+  b.y:=-57;
+  c:=a+b;
+  if (c.x<>10) or (c.y<>10) then
+    Halt(1);
+end;
+
+begin
+  test_op1;
+  test_op2;
+  test_op3;
 end.

+ 20 - 0
tests/test/testop3.pp

@@ -0,0 +1,20 @@
+unit testop3;
+
+interface
+
+type
+  op3 = record
+    x,y : real;
+  end;
+
+operator + (const a,b : op3) c : op3;
+
+implementation
+
+operator + (const a,b : op3) c : op3;
+begin
+  c.x:=a.x+b.x;
+  c.y:=a.y+b.y;
+end;
+
+end.