Browse Source

* refcount fixed, it is now correctly using the same temp

peter 21 years ago
parent
commit
dc67ea9d52
1 changed files with 8 additions and 6 deletions
  1. 8 6
      tests/webtbs/tw2911.pp

+ 8 - 6
tests/webtbs/tw2911.pp

@@ -48,19 +48,21 @@ begin
 end;
 
 begin
-        writeln('All reference counts should be 1 for the following...');
         onestring := 'one';
         twostring := 'two';
         ARecordWithStrings.one := onestring + twostring;
         twostring := onestring + twostring;
-        RefCount(ARecordWithStrings.one,2);
+        RefCount(ARecordWithStrings.one,1);
+        { Here we allocate a temp so refcount will be 2 }
         ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
         twostring := onestring + twostring;
-        RefCount(ARecordWithStrings.one,3);
+        RefCount(ARecordWithStrings.one,2);
+        { Temp is reused, refcount should stay 2 }
         ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
         twostring := onestring + twostring;
-        RefCount(ARecordWithStrings.one,4);
+        RefCount(ARecordWithStrings.one,2);
+        { Temp is reused, refcount should stay 2 }
         ARecordWithStrings := FunctionResultIsRecord(ARecordWithStrings);
         twostring := onestring + twostring;
-        RefCount(ARecordWithStrings.one,5);
-end.
+        RefCount(ARecordWithStrings.one,2);
+end.