queue-test.mlw 479 Bytes
Newer Older
1 2 3

module Test

4 5 6
  use int.Int
  use list.List
  use queue.Queue
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

  let test0 () =
    let s = Queue.create () : Queue.t 'a in
    assert { s.elts = Nil };
    let b = Queue.is_empty s in
    assert { b = True };
    let n = Queue.length s in
    assert { n = 0 }

  let test1 ()
    raises { Queue.Empty }
  = let s = Queue.create () in
    Queue.push 1 s;
    let x = Queue.peek s in assert { x = 1 };
    Queue.push 2 s;
    let x = Queue.peek s in assert { x = 1 };
    ()

end