test_stack = proc()
    % a few initial variables
    intstack = stack_t[int]
    x,y,z:int
    okay : bool

    %CREATE
    % this can only try to create.. the rest of the test will
    % come with the other tests. If create is wrong none of the others
    % should work
    st1 : intstack := intstack$create()
    st2 : intstack := intstack$create()
    % END CREATE

    % PUSH/POP
    % this will try to push elements and pop them. Also try the
    % empty stack
    % initial stack
       okay := false
       x := intstack$pop(st1) except when empty: okay := true end
       assert("pop on empty", okay)
       intstack$push(st1, 5)   % first element should be a five
       intstack$push(st1, 6)   % we should pop off a six first
       assert("pop", ((intstack$pop(st1) = 6) & (intstack$pop(st1) = 5)))
       okay := false
       intstack$pop(st1)
        except when empty: okay := true end
       assert("pop", okay)
       intstack$push(st1, 5)   % first element should be a five
      intstack$push(st1, 6)   % we should pop off a six first
       intstack$pop(st1)       % get rid of the six
       intstack$push(st1, 2)   % stack should be 2 over 5
       assert("pop", ((intstack$pop(st1) = 2) & (intstack$pop(st1) = 5)))
    % end PUSH/POP

    % COPY
    % this will make a copy of an empty stack. test it. Then, a copy of a
    % stack with one element, and test it.
      st3:intstack := intstack$copy(st1)  % st1 is empty
      okay := false
      intstack$pop(st3) except when empty: okay := true end
      assert("copy", okay)
      intstack$push(st1, 5)
      st3 := intstack$copy(st1)   % st3 should also have a 5 but be seperate
      assert("copy", (intstack$pop(st3) = 5) & (intstack$pop(st1) = 5))
    % copy a stack with 2 elements
      st4 : intstack := intstack$create()
      intstack$push(st4,1)
      intstack$push(st4,2)
      st5 : intstack := intstack$copy(st4)
      assert("copy part 1",(intstack$pop(st4) = 2) & (intstack$pop(st5) = 2))
      assert("copy part 2",(intstack$pop(st4) = 1) & (intstack$pop(st5) = 1))
      ok1:bool := false
      ok2:bool := false
      intstack$pop(st4)
       except when empty:
          ok1 := true
        end
      intstack$pop(st4)
       except when empty:
          ok2 := true
        end
      assert("copy: both empty",(ok1 = true) & (ok2 = true))



    % END COPY

    % EMPTY
    % this will test an empty stack and a non-empty stack
        assert("empty", intstack$empty(st2))
        intstack$push(st2, 10)
        assert("empty", ~intstack$empty(st2))
    % END EMPTY

    % PEEK
    % this will peek at an empty stack, a one element stack, and a
    % three element stack.  st2 currently has a 10 in it
    % one element:
        assert("peek", ((intstack$peek(st2) = 10) &
                        (intstack$pop(st2) = 10)))
    % zero elements
        okay := false
        intstack$peek(st2) except when empty: okay := true end
        assert("peek",okay)
    % three elements
        intstack$push(st2, 1)
        intstack$push(st2, 2)
        intstack$push(st2, 3)
        assert("peek", (((intstack$peek(st2) = 3) &
                         (intstack$pop(st2) = 3)) &
                        ((intstack$peek(st2) = 2) &
                         (intstack$pop(st2) = 2)) &
                        ((intstack$peek(st2) = 1) &
                         (intstack$pop(st2) = 1))))
     % END PEEK
     % DEPTH
     % this will try a zero, 1 and 3 element stack
        assert("depth", intstack$depth(st2) = 0)
        intstack$push(st2, 1)
        assert("depth", intstack$depth(st2) = 1)
        intstack$push(st2, 2)
        intstack$push(st2, 3)
        assert("depth", intstack$depth(st2) = 3)
     % END DEPTH

    end test_stack

