Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
Fixed immutable queue enumerator bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Krüger committed May 16, 2013
1 parent e4b889c commit 4f14901
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool IEnumerator.MoveNext()
if (frontStack == null)
{
frontStack = start.frontStack;
backStack = start.backStack;
backStack = Reverse (start.backStack);
}
else if (!frontStack.IsEmpty)
{
Expand All @@ -159,7 +159,7 @@ bool IEnumerator.MoveNext()
{
backStack = backStack.Pop();
}
return !(frontStack.IsEmpty || backStack.IsEmpty);
return !(frontStack.IsEmpty && backStack.IsEmpty);
}

void IEnumerator.Reset()
Expand Down
3 changes: 2 additions & 1 deletion UnitTests/ImmutableQueueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System;
using NUnit.Framework;
using System.Collections.Immutable;
using System.Linq;

namespace UnitTests
{
Expand Down Expand Up @@ -121,7 +122,7 @@ public void TestEnumerator()
s = s.Enqueue(i);

i = 1;

Assert.AreEqual (99, s.Count ());
foreach (int x in s)
{
Assert.AreEqual(i, x, "#4");
Expand Down
1 change: 1 addition & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Private>False</Private>
</Reference>
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ImmutableStackTests.cs" />
Expand Down

0 comments on commit 4f14901

Please sign in to comment.