Browse Source

* Stack is enumerated from bottom up

michael 5 years ago
parent
commit
c72c0faa30
2 changed files with 5 additions and 5 deletions
  1. 1 1
      packages/rtl/generics.collections.pas
  2. 4 4
      test/tcgenericstack.pp

+ 1 - 1
packages/rtl/generics.collections.pas

@@ -314,7 +314,7 @@ type
 
 
       { TEnumerator }
       { TEnumerator }
 
 
-      TEnumerator = class(TCustomInvertedListEnumerator<T>)
+      TEnumerator = class(TCustomListEnumerator<T>)
       public
       public
         constructor Create(AStack: TMyType);
         constructor Create(AStack: TMyType);
       end;
       end;

+ 4 - 4
test/tcgenericstack.pp

@@ -357,7 +357,7 @@ begin
   For I:=1 to 3 do
   For I:=1 to 3 do
     begin
     begin
     SI:=IntToStr(I);
     SI:=IntToStr(I);
-    AssertEquals('Value '+SI,SI,A[3-i]);
+    AssertEquals('Value '+SI,SI,A[i-1]);
     end;
     end;
 end;
 end;
 
 
@@ -371,12 +371,12 @@ Var
 
 
 begin
 begin
   DoAdd(3);
   DoAdd(3);
-  I:=3;
+  I:=1;
   For A in Stack do
   For A in Stack do
     begin
     begin
     SI:=IntToStr(i);
     SI:=IntToStr(i);
     AssertEquals('Value '+SI,SI,A);
     AssertEquals('Value '+SI,SI,A);
-    Dec(I);
+    Inc(I);
     end;
     end;
 end;
 end;
 
 
@@ -392,7 +392,7 @@ procedure TTestSimpleStack.TestValueNotificationDelete;
 begin
 begin
   DoAdd(3);
   DoAdd(3);
   Stack.OnNotify:=@DoValueNotify;
   Stack.OnNotify:=@DoValueNotify;
-  SetExpectValues('Clear',['3','2','1'],[cnRemoved,cnRemoved,cnRemoved],{$IFDEF FPC}true{$ELSE}False{$endif});
+  SetExpectValues('Clear',['3','2','1'],[cnRemoved,cnRemoved,cnRemoved],False);
   Stack.Clear;
   Stack.Clear;
   DoneExpectValues;
   DoneExpectValues;
 end;
 end;