/// <summary> /// A test for Empty /// </summary> /// <typeparam name="T">The type of elements held in the stack.</typeparam> private void EmptyTestHelper <T>() where T : new() { IImmutableStack <T> actual = ImmutableStack <T> .Empty; Assert.NotNull(actual); Assert.True(actual.IsEmpty); AssertAreSame(ImmutableStack <T> .Empty, actual.Clear()); AssertAreSame(ImmutableStack <T> .Empty, actual.Push(new T()).Clear()); }
public void TestClear() { ImmutableTreeStack <int> stack = ImmutableTreeStack <int> .Empty; Assert.Same(stack, stack.Clear()); foreach (int item in Enumerable.Range(0, 10)) { stack = stack.Push(item); } Assert.NotEmpty(stack); Assert.Same(ImmutableTreeStack <int> .Empty, stack.Clear()); // Test through the IImmutableStack<T> interface IImmutableStack <int> immutableStack = stack; Assert.NotEmpty(immutableStack); Assert.Same(ImmutableTreeStack <int> .Empty, immutableStack.Clear()); }
public static IImmutableStack <T> clear <T>(IImmutableStack <T> stack) => stack.Clear();