queue-test.mlw 500 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

module Test

  use import int.Int
  use import list.List
  use import queue.Queue

  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