Moved unstable/cce/queue to unstable/queue.
This commit is contained in:
parent
1d0c069a6c
commit
70858e93e5
53
collects/tests/unstable/queue.rkt
Normal file
53
collects/tests/unstable/queue.rkt
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#lang racket
|
||||||
|
|
||||||
|
(require rackunit rackunit/text-ui unstable/queue "helpers.rkt")
|
||||||
|
|
||||||
|
(run-tests
|
||||||
|
(test-suite "queue.ss"
|
||||||
|
(test-suite "queue-empty?"
|
||||||
|
(test-case "make-queue"
|
||||||
|
(check-true (queue-empty? (make-queue))))
|
||||||
|
(test-case "enqueue! once"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(check-false (queue-empty? q))))
|
||||||
|
(test-case "enqueue! once / dequeue! once"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(dequeue! q)
|
||||||
|
(check-true (queue-empty? q))))
|
||||||
|
(test-case "enqueue! twice"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(enqueue! q 2)
|
||||||
|
(check-false (queue-empty? q))))
|
||||||
|
(test-case "enqueue! twice / dequeue! once"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(enqueue! q 2)
|
||||||
|
(dequeue! q)
|
||||||
|
(check-false (queue-empty? q))))
|
||||||
|
(test-case "enqueue! twice / dequeue! twice"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(enqueue! q 2)
|
||||||
|
(dequeue! q)
|
||||||
|
(dequeue! q)
|
||||||
|
(check-true (queue-empty? q)))))
|
||||||
|
(test-suite "dequeue!"
|
||||||
|
(test-case "make-queue"
|
||||||
|
(check-exn exn:fail:contract? (lambda () (dequeue! (make-queue)))))
|
||||||
|
(test-case "enqueue! once"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(check-equal? (dequeue! q) 1)
|
||||||
|
(check-exn exn:fail:contract?
|
||||||
|
(lambda () (dequeue! q)))))
|
||||||
|
(test-case "enqueue! twice"
|
||||||
|
(let* ([q (make-queue)])
|
||||||
|
(enqueue! q 1)
|
||||||
|
(enqueue! q 2)
|
||||||
|
(check-equal? (dequeue! q) 1)
|
||||||
|
(check-equal? (dequeue! q) 2)
|
||||||
|
(check-exn exn:fail:contract?
|
||||||
|
(lambda () (dequeue! q))))))))
|
|
@ -15,7 +15,6 @@
|
||||||
@include-section["set.scrbl"]
|
@include-section["set.scrbl"]
|
||||||
@include-section["dict.scrbl"]
|
@include-section["dict.scrbl"]
|
||||||
@include-section["hash.scrbl"]
|
@include-section["hash.scrbl"]
|
||||||
@include-section["queue.scrbl"]
|
|
||||||
|
|
||||||
@include-section["syntax.scrbl"]
|
@include-section["syntax.scrbl"]
|
||||||
@include-section["define.scrbl"]
|
@include-section["define.scrbl"]
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
"test-hash.ss"
|
"test-hash.ss"
|
||||||
"test-planet.ss"
|
"test-planet.ss"
|
||||||
"test-port.ss"
|
"test-port.ss"
|
||||||
"test-queue.ss"
|
|
||||||
"test-regexp.ss"
|
"test-regexp.ss"
|
||||||
"test-require-provide.ss"
|
"test-require-provide.ss"
|
||||||
"test-sandbox.ss"
|
"test-sandbox.ss"
|
||||||
|
@ -29,7 +28,6 @@
|
||||||
hash-suite
|
hash-suite
|
||||||
planet-suite
|
planet-suite
|
||||||
port-suite
|
port-suite
|
||||||
queue-suite
|
|
||||||
regexp-suite
|
regexp-suite
|
||||||
require-provide-suite
|
require-provide-suite
|
||||||
sandbox-suite
|
sandbox-suite
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#lang scheme
|
|
||||||
|
|
||||||
(require "checks.ss"
|
|
||||||
"../queue.ss")
|
|
||||||
|
|
||||||
(provide queue-suite)
|
|
||||||
|
|
||||||
(define queue-suite
|
|
||||||
(test-suite "queue.ss"
|
|
||||||
(test-suite "queue-empty?"
|
|
||||||
(test-case "make-queue"
|
|
||||||
(check-true (queue-empty? (make-queue))))
|
|
||||||
(test-case "enqueue! once"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(check-false (queue-empty? q))))
|
|
||||||
(test-case "enqueue! once / dequeue! once"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(dequeue! q)
|
|
||||||
(check-true (queue-empty? q))))
|
|
||||||
(test-case "enqueue! twice"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(enqueue! q 2)
|
|
||||||
(check-false (queue-empty? q))))
|
|
||||||
(test-case "enqueue! twice / dequeue! once"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(enqueue! q 2)
|
|
||||||
(dequeue! q)
|
|
||||||
(check-false (queue-empty? q))))
|
|
||||||
(test-case "enqueue! twice / dequeue! twice"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(enqueue! q 2)
|
|
||||||
(dequeue! q)
|
|
||||||
(dequeue! q)
|
|
||||||
(check-true (queue-empty? q)))))
|
|
||||||
(test-suite "dequeue!"
|
|
||||||
(test-case "make-queue"
|
|
||||||
(check-exn exn:fail:contract? (lambda () (dequeue! (make-queue)))))
|
|
||||||
(test-case "enqueue! once"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(check-equal? (dequeue! q) 1)
|
|
||||||
(check-exn exn:fail:contract?
|
|
||||||
(lambda () (dequeue! q)))))
|
|
||||||
(test-case "enqueue! twice"
|
|
||||||
(let* ([q (make-queue)])
|
|
||||||
(enqueue! q 1)
|
|
||||||
(enqueue! q 2)
|
|
||||||
(check-equal? (dequeue! q) 1)
|
|
||||||
(check-equal? (dequeue! q) 2)
|
|
||||||
(check-exn exn:fail:contract?
|
|
||||||
(lambda () (dequeue! q))))))))
|
|
|
@ -1,4 +1,4 @@
|
||||||
#lang scheme
|
#lang racket
|
||||||
|
|
||||||
;; A Queue is a circularly linked list of queue structures.
|
;; A Queue is a circularly linked list of queue structures.
|
||||||
;; The head of the circle is identified by the distinguished head value.
|
;; The head of the circle is identified by the distinguished head value.
|
|
@ -1,13 +1,11 @@
|
||||||
#lang scribble/doc
|
#lang scribble/manual
|
||||||
@(require scribble/manual
|
@(require scribble/eval "utils.rkt" (for-label racket unstable/queue))
|
||||||
scribble/eval
|
|
||||||
"../scribble.ss"
|
|
||||||
"eval.ss")
|
|
||||||
@(require (for-label scheme unstable/cce/queue))
|
|
||||||
|
|
||||||
@title[#:style 'quiet #:tag "cce-queue"]{Imperative Queues}
|
@title{Imperative Queues}
|
||||||
|
|
||||||
@defmodule[unstable/cce/queue]
|
@defmodule[unstable/queue]
|
||||||
|
|
||||||
|
@unstable[@author+email["Carl Eastlund" "cce@racket-lang.org"]]
|
||||||
|
|
||||||
This module provides a mutable queue representation.
|
This module provides a mutable queue representation.
|
||||||
|
|
||||||
|
@ -23,7 +21,7 @@ Adds an element to the back of a queue.
|
||||||
Removes an element from the front of a nonempty queue, and returns that element.
|
Removes an element from the front of a nonempty queue, and returns that element.
|
||||||
|
|
||||||
@defexamples[
|
@defexamples[
|
||||||
#:eval (evaluator 'unstable/cce/queue)
|
#:eval (eval/require 'unstable/queue)
|
||||||
(define q (make-queue))
|
(define q (make-queue))
|
||||||
(enqueue! q 1)
|
(enqueue! q 1)
|
||||||
(dequeue! q)
|
(dequeue! q)
|
||||||
|
@ -38,7 +36,7 @@ Removes an element from the front of a nonempty queue, and returns that element.
|
||||||
Recognizes whether a queue is empty or not.
|
Recognizes whether a queue is empty or not.
|
||||||
|
|
||||||
@defexamples[
|
@defexamples[
|
||||||
#:eval (evaluator 'unstable/cce/queue)
|
#:eval (eval/require 'unstable/queue)
|
||||||
(define q (make-queue))
|
(define q (make-queue))
|
||||||
(queue-empty? q)
|
(queue-empty? q)
|
||||||
(enqueue! q 1)
|
(enqueue! q 1)
|
||||||
|
@ -52,7 +50,7 @@ Recognizes whether a queue is empty or not.
|
||||||
This predicate recognizes queues.
|
This predicate recognizes queues.
|
||||||
|
|
||||||
@defexamples[
|
@defexamples[
|
||||||
#:eval (evaluator 'unstable/cce/queue)
|
#:eval (eval/require 'unstable/queue)
|
||||||
(queue? (make-queue))
|
(queue? (make-queue))
|
||||||
(queue? 'not-a-queue)
|
(queue? 'not-a-queue)
|
||||||
]
|
]
|
|
@ -81,6 +81,7 @@ Keep documentation and tests up to date.
|
||||||
@include-section["net.scrbl"]
|
@include-section["net.scrbl"]
|
||||||
@include-section["path.scrbl"]
|
@include-section["path.scrbl"]
|
||||||
@include-section["pretty.scrbl"]
|
@include-section["pretty.scrbl"]
|
||||||
|
@include-section["queue.scrbl"]
|
||||||
@include-section["srcloc.scrbl"]
|
@include-section["srcloc.scrbl"]
|
||||||
@include-section["string.scrbl"]
|
@include-section["string.scrbl"]
|
||||||
@include-section["struct.scrbl"]
|
@include-section["struct.scrbl"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user