Updating require paths, making tests succeed, and fixing docs

This commit is contained in:
Jay McCarthy 2011-06-24 13:47:47 -06:00
parent 375d6b8497
commit 6abeab42d5
31 changed files with 108 additions and 171 deletions

View File

@ -1,7 +1,6 @@
#lang racket/base
(require racket/require
(path-up "automata/dfa.rkt")
(path-up "automata/machine.rkt")
(require unstable/automata/dfa
unstable/automata/machine
tests/eli-tester)
(define M

View File

@ -1,8 +1,7 @@
#lang racket
(require racket/require
(path-up "automata/machine.rkt")
(path-up "automata/re.rkt")
(path-up "automata/re-ext.rkt")
(require unstable/automata/re
unstable/automata/re-ext
unstable/automata/machine
unstable/match
tests/eli-tester)

View File

@ -1,7 +1,6 @@
#lang racket/base
(require racket/require
(path-up "automata/nfa-ep.rkt")
(path-up "automata/machine.rkt")
(require unstable/automata/nfa-ep
unstable/automata/machine
tests/eli-tester)
(define M

View File

@ -1,7 +1,6 @@
#lang racket/base
(require racket/require
(path-up "automata/nfa-star.rkt")
(path-up "automata/machine.rkt")
(require unstable/automata/nfa-star
unstable/automata/machine
tests/eli-tester)
(define M

View File

@ -1,7 +1,6 @@
#lang racket/base
(require racket/require
(path-up "automata/nfa.rkt")
(path-up "automata/machine.rkt")
(require unstable/automata/nfa
unstable/automata/machine
tests/eli-tester)
(define M

View File

@ -1,8 +1,7 @@
#lang racket
(require racket/require
(path-up "automata/machine.rkt")
(path-up "automata/re.rkt")
(path-up "automata/re-ext.rkt")
(require unstable/automata/machine
unstable/automata/re
unstable/automata/re-ext
unstable/match
tests/eli-tester)

View File

@ -46,8 +46,7 @@
(-> (-> aff-> any/c) any/c)
raw 'pos 'neg))
(require racket/require
(path-up "temp-c/dsl.rkt"))
(require unstable/temp-c/dsl)
(define (rgx)
(contract
(with-monitor

View File

@ -25,7 +25,7 @@
(listof any/c))]))
(module qdsl-sort racket
(require racket/require (path-up "temp-c/dsl.rkt") 'raw-sort unstable/match)
(require unstable/temp-c/dsl 'raw-sort unstable/match)
(provide make-sort)
(define (make-sort)
(contract
@ -42,7 +42,7 @@
sort 'pos 'neg)))
(module dsl-sort racket
(require racket/require (path-up "temp-c/dsl.rkt") 'raw-sort)
(require unstable/temp-c/dsl 'raw-sort)
(provide make-sort)
(define (make-sort)
(contract (with-monitor (label 'sort (-> (label 'order (-> any/c any/c boolean?))
@ -57,7 +57,7 @@
'pos 'neg)))
(module smart-sort racket
(require racket/require (path-up "temp-c/monitor.rkt") 'raw-sort)
(require unstable/temp-c/monitor 'raw-sort)
(define returned? #f)
(define (sort-monitor evt)
(match evt

View File

@ -1,6 +1,5 @@
#lang racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
tests/eli-tester)
(define count 0)
@ -43,7 +42,8 @@
(test
(set! count 0)
(test-spec Race)
count => 2)
; This 1 represents the presence of the race
count => 1)
#:failure-prefix "Concurrent"
(test
(set! count 0)

View File

@ -1,6 +1,5 @@
#lang racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
tests/eli-tester)
(define (test-spec spec f)

View File

@ -6,7 +6,7 @@
|#
(module lock racket
(require racket/require (path-up "temp-c/monitor.rkt"))
(require unstable/temp-c/monitor)
(define (use-resource f)
(define (protect label g)
(contract (monitor/c monitor label (-> void)) g

View File

@ -1,6 +1,5 @@
#lang racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
unstable/match)
(define memory%

View File

@ -1,9 +1,10 @@
#lang racket
(require "ex-matthias-a.rkt")
(require tests/eli-tester
"ex-matthias-a.rkt")
(define memory (new memory%))
(define a (send memory malloc))
(send memory free a) (displayln `(freeing ,a))
(send memory free a) (displayln `(freeing ,a))
(send memory free a) (displayln `(freeing ,a))
(test
(send memory free a)
(send memory free a) =error> #rx"disallowed call")

View File

@ -12,13 +12,14 @@
[free (->m number? void)])]))
(module b racket
(require 'a)
(define memory (new memory%))
(define a (send memory malloc))
(send memory free a) (displayln `(freeing ,a))
(send memory free "foo") (displayln `(freeing ,a))
(send memory free a) (displayln `(freeing ,a)))
(require 'a tests/eli-tester)
(define memory (new memory%))
(define a (send memory malloc))
(test
(send memory free a)
(send memory free "foo") =error> #rx"expected \\<number"
(send memory free a)))
(require 'b)

View File

@ -1,7 +1,6 @@
#lang racket/load
(module a racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
unstable/match)
(define memory%
@ -23,13 +22,14 @@
(call 'free _ (== addr)))))))]))
(module b racket
(require 'a)
(define memory (new memory%))
(define a (send memory malloc))
(send memory free a) (displayln `(freeing ,a))
(send memory free a) (displayln `(freeing ,a))
(send memory free a) (displayln `(freeing ,a)))
(require 'a tests/eli-tester)
(define memory (new memory%))
(define a (send memory malloc))
(test
(send memory free a)
(send memory free a)
=error> #rx"disallowed call"))
(require 'b)

View File

@ -4,7 +4,7 @@
|#
(module mem racket
(require racket/require (path-up "temp-c/monitor.rkt"))
(require unstable/temp-c/monitor)
(define free-list empty)
(define last-addr 0)
@ -18,7 +18,7 @@
(set! free-list (cons addr free-list)))
(define allocated (make-weak-hasheq))
(define (monitor evt)
(define (mem-monitor evt)
; Only allow freeing of allocated things, disallow double frees
; and track addrs using malloc returns
(match evt
@ -34,8 +34,8 @@
#t]))
(provide/contract
[malloc (monitor/c monitor 'malloc (-> number?))]
[free (monitor/c monitor 'free (-> number? void))]))
[malloc (monitor/c mem-monitor 'malloc (-> number?))]
[free (monitor/c mem-monitor 'free (-> number? void))]))
(module mem-test racket
(require tests/eli-tester

View File

@ -4,7 +4,7 @@
|#
(module mem racket
(require racket/require (path-up "temp-c/monitor.rkt"))
(require unstable/temp-c/monitor)
(define heap%
(class object%
(define free-list empty)

View File

@ -1,53 +0,0 @@
#lang racket
(require racket/require
(path-up "temp-c/dsl.rkt")
tests/eli-tester)
(define turn%/c
(with-monitor
(class/c [place!
;; place a tile at a specific location, return the tile that the player gets in turn
;; -- always works the first time
;; -- works the (n+1)st time when the score change for the n-th call to place
;; ---- made one of the scores to cross the '18 line'
;; -- never works after rack! has been called
(->dm ([p (and/c placement/c
(lambda (p) (send this placable? p))
(lambda (p) (send this one-of-my-tiles (placement->tile p))))])
(r (or/c tile/c false/c)))]
[placable?
;; is this placement legitimate, considering the state of the game?
(->m placement/c boolean?)]
[one-of-my-tiles?
;; is this tile one of mine?
(->m tile/c boolean?)]
[rack!
;; re-rack your tiles ; call the function only if
;; -- the score returned from the last place call produces a score
;; -- such that none of the current tiles is associated with any of
;; -- the least scoring piece
;; CHANGE: this may return some of the same tiles
;; IF there aren't enough available on the administrator's side
(->m (listof tile/c))]
[end
;; signal end of turn
(-> void?)]))
(seq
(rec* x
(or
(seq
(call 'place! _)
(return 'place! _))
(seq*
(call 'place! _)
(return 'place! (? crossed-the-line?)))
x))
(call 'place! _)
(or
(seq (return 'place! (? a-score-such-that-none-of-the-current-tiles-is-associated-with-any-of-the-least-scoring-piece?))
(call 'rack!)
(return 'rack!))
(return 'place! _))
(call 'end)
(return 'end _))

View File

@ -1,6 +1,5 @@
#lang racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
tests/eli-tester)
(define manual-strange/c

View File

@ -1,7 +1,6 @@
#lang racket/base
(require tests/stress
racket/require
(path-up "temp-c/dsl.rkt")
unstable/temp-c/dsl
racket/match
racket/contract)

View File

@ -16,8 +16,7 @@ admin --------------------------------------------------------> player
;; -----------------------------------------------------------------------------
;; the interface module, defines turn% and how player is called via take-turn
(module player-admin-interface racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
unstable/match)
(define turn%
@ -66,7 +65,7 @@ admin --------------------------------------------------------> player
;; the admin module creates player, admin, and has admin call player
(module admin racket
(require 'player-admin-interface 'player)
(require 'player-admin-interface 'player tests/eli-tester)
(define admin%
(class object%
@ -78,7 +77,10 @@ admin --------------------------------------------------------> player
(define value1 (send turn1 observe))
;; ---
(define turn2 (new turn% [value 10]))
(send player take-turn turn2)
(test
(send player take-turn turn2)
=error>
#rx"disallowed call")
;; ---
(list 'bad-for-turn1: (not (= 2 (send turn1 observe)))
'bad-for-turn2: (= 10 (send turn2 observe))))

View File

@ -16,8 +16,7 @@ admin --------------------------------------------------------> player
;; -----------------------------------------------------------------------------
;; the interface module, defines turn% and how player is called via take-turn
(module player-admin-interface racket
(require racket/require
(path-up "temp-c/dsl.rkt")
(require unstable/temp-c/dsl
unstable/match)
(define turn%
@ -69,7 +68,7 @@ admin --------------------------------------------------------> player
;; the admin module creates player, admin, and has admin call player
(module admin racket
(require 'player-admin-interface 'player)
(require 'player-admin-interface 'player tests/eli-tester)
(define admin%
(class object%
@ -81,7 +80,10 @@ admin --------------------------------------------------------> player
(define value1 (send turn1 observe))
;; ---
(define turn2 (new turn% [value 10]))
(send player take-turn turn2)
(test
(send player take-turn turn2)
=error>
#rx"disallowed call")
;; ---
(list 'bad-for-turn1: (not (= 2 (send turn1 observe)))
'bad-for-turn2: (= 10 (send turn2 observe))))

View File

@ -17,7 +17,7 @@ racket-pth
(define-syntax-rule (stress-it ver ...)
(let ([x* 1])
(printf "Running ~a iterations\n" x*)
(stress 100
(stress 10
[(symbol->string 'ver)
(printf "Running ~a\n" 'ver)
(for ([i (in-range x*)])

View File

@ -137,8 +137,7 @@
(not os-turn?))])))
(require unstable/match
racket/require
(path-up "temp-c/dsl.rkt"))
unstable/temp-c/dsl)
(provide
(rename-out [tic-tac-toe
tic-tac-toe:raw]))

View File

@ -1,3 +0,0 @@
#lang setup/infotab
(define scribblings '(("scribblings/automata.scrbl")))

View File

@ -12,15 +12,15 @@
@author[@author+email["Jay McCarthy" "jay@racket-lang.org"]]
@defmodule[automata]
@defmodule[unstable/automata]
This package provides macros and functions for writing state machines over @racketmodname[racket/match] patterns (as opposed to concrete characters.)
@section[#:tag "machine"]{Machines}
@defmodule[automata/machine]
@(require (for-label "../machine.rkt"))
@interaction-eval[#:eval our-eval (require automata/machine)]
@defmodule[unstable/automata/machine]
@(require (for-label unstable/automata/machine))
@interaction-eval[#:eval our-eval (require unstable/automata/machine)]
Each of the subsequent macros compile to instances of the machines provided by this module. This is a documented feature of the modules, so these functions should be used to, for example, determine if the machine is currently accepting.
@ -88,9 +88,9 @@ Each of the subsequent macros compile to instances of the machines provided by t
@section[#:tag "dfa"]{Deterministic Finite Automata}
@defmodule[automata/dfa]
@(require (for-label "../dfa.rkt"))
@interaction-eval[#:eval our-eval (require automata/dfa)]
@defmodule[unstable/automata/dfa]
@(require (for-label unstable/automata/dfa))
@interaction-eval[#:eval our-eval (require unstable/automata/dfa)]
This module provides a macro for deterministic finite automata.
@ -123,9 +123,9 @@ This module provides a macro for deterministic finite automata.
@section[#:tag "nfa"]{Non-Deterministic Finite Automata}
@defmodule[automata/nfa]
@(require (for-label "../nfa.rkt"))
@interaction-eval[#:eval our-eval (require automata/nfa)]
@defmodule[unstable/automata/nfa]
@(require (for-label unstable/automata/nfa))
@interaction-eval[#:eval our-eval (require unstable/automata/nfa)]
This module provides a macro for non-deterministic finite automata.
@ -164,9 +164,9 @@ This module provides a macro for non-deterministic finite automata.
@section[#:tag "nfa-ep"]{Non-Deterministic Finite Automata (with epsilon transitions)}
@defmodule[automata/nfa-ep]
@(require (for-label "../nfa-ep.rkt"))
@interaction-eval[#:eval our-eval (require automata/nfa-ep)]
@defmodule[unstable/automata/nfa-ep]
@(require (for-label unstable/automata/nfa-ep))
@interaction-eval[#:eval our-eval (require unstable/automata/nfa-ep)]
This module provides a macro for non-deterministic finite automata with epsilon transitions.

View File

@ -11,10 +11,10 @@
@title[#:tag "re"]{Regular Expressions}
@defmodule[automata/re]
@(require (for-label "../re.rkt"
"../machine.rkt"))
@interaction-eval[#:eval our-eval (require automata/re)]
@defmodule[unstable/automata/re]
@(require (for-label unstable/automata/re
unstable/automata/machine))
@interaction-eval[#:eval our-eval (require unstable/automata/re)]
This module provides a macro for regular expression compilation.
@ -42,13 +42,13 @@ This module provides a macro for regular expression compilation.
if the expression is initially accepting, this delayed version is never accepting.
The compiler will use an NFA, provided @racket[complement] and @racket[dseq] are not used. Otherwise,
many NFAs connected with the machine simulation functions from @racketmodname[automata/machine] are used.
many NFAs connected with the machine simulation functions from @racketmodname[unstable/automata/machine] are used.
}
@(define-syntax-rule (defidforms (id ...) . dat)
(deftogether ((defidform id) ...) . dat))
@defidforms[(complement seq union star epsilon nullset dseq)]{
@defidforms[(complement seq union star epsilon nullset dseq rec)]{
Bindings for use in @racket[re].
}
@ -58,9 +58,9 @@ This module provides a macro for regular expression compilation.
@section[#:tag "re-ext"]{Extensions}
@defmodule[automata/re-ext]
@(require (for-label "../re-ext.rkt"))
@interaction-eval[#:eval our-eval (require automata/re-ext)]
@defmodule[unstable/automata/re-ext]
@(require (for-label unstable/automata/re-ext))
@interaction-eval[#:eval our-eval (require unstable/automata/re-ext)]
This module provides a few transformers that extend the syntax of regular expression patterns.
@ -73,7 +73,7 @@ This module provides a few transformers that extend the syntax of regular expres
@section[#:tag "re-ex"]{Examples}
@interaction-eval[#:eval our-eval (require automata/machine racket/function)]
@interaction-eval[#:eval our-eval (require unstable/automata/machine racket/function)]
@defexamples[
#:eval our-eval

View File

@ -71,6 +71,7 @@ Keep documentation and tests up to date.
Add new documentation links to the list immediately below.
}
@include-section["../automata/scribblings/automata.scrbl"]
@include-section["bytes.scrbl"]
@include-section["contract.scrbl"]
@include-section["wrapc.scrbl"]
@ -100,6 +101,7 @@ Keep documentation and tests up to date.
@include-section["string.scrbl"]
@include-section["struct.scrbl"]
@include-section["syntax.scrbl"]
@include-section["../temp-c/scribblings/temp-c.scrbl"]
@;{--------}

View File

@ -3,16 +3,16 @@
racket/stxparam
(for-syntax racket/base)
"monitor.rkt"
"../automata/machine.rkt"
"../automata/re.rkt"
"../automata/re-ext.rkt")
unstable/automata/machine
unstable/automata/re
unstable/automata/re-ext)
(provide call ret with-monitor label
re->monitor-predicate/concurrent
re->monitor-predicate/serial
(all-from-out
"monitor.rkt"
"../automata/re.rkt"
"../automata/re-ext.rkt"))
unstable/automata/re
unstable/automata/re-ext))
(define-syntax-parameter stx-monitor-id
(λ (stx) (raise-syntax-error 'label "Used outside monitor" stx)))

View File

@ -1,3 +0,0 @@
#lang setup/infotab
(define scribblings '(("scribblings/temp-c.scrbl")))

View File

@ -9,18 +9,18 @@
@(define our-eval (make-base-eval))
@title{@bold{Temporal Contracts}: Explicit Contract Monitors}
@title[#:tag "temp-c"]{@bold{Temporal Contracts}: Explicit Contract Monitors}
@author[@author+email["Jay McCarthy" "jay@racket-lang.org"]]
@defmodule[temp-c]
@defmodule[unstable/temp-c]
The contract system implies the presence of a "monitoring system" that ensures that contracts are not violated. The @racketmodname[racket/contract] system compiles this monitoring system into checks on values that cross a contracted boundary. This module provides a facility to pass contract boundary crossing information to an explicit monitor for approval. This monitor may, for example, use state to enforce temporal constraints, such as a resource is locked before it is accessed.
@section[#:tag "monitor"]{Monitors}
@defmodule[temp-c/monitor]
@(require (for-label "../monitor.rkt"))
@defmodule[unstable/temp-c/monitor]
@(require (for-label unstable/temp-c/monitor))
@deftogether[[
@defstruct*[monitor ([label symbol?]) #:transparent]
@ -91,14 +91,14 @@ used correctly.
@section[#:tag "dsl"]{Domain Specific Language}
@defmodule[temp-c/dsl]
@defmodule[unstable/temp-c/dsl]
@(require (for-label racket/match
racket/contract
"../dsl.rkt"
"../../automata/re.rkt"
"../../automata/re-ext.rkt"))
unstable/temp-c/dsl
unstable/automata/re
unstable/automata/re-ext))
Constructing explicit monitors using only @racket[monitor/c] can be a bit onerous. This module provides some helpful tools for making the definition easier. It provides everything from @racketmodname[temp-c/monitor], as well as all bindings from @racketmodname[automata/re] and @racketmodname[automata/re-ext]. The latter provide a DSL for writing "dependent" regular expression machines over arbitrary @racketmodname[racket/match] patterns.
Constructing explicit monitors using only @racket[monitor/c] can be a bit onerous. This module provides some helpful tools for making the definition easier. It provides everything from @racketmodname[unstable/temp-c/monitor], as well as all bindings from @racketmodname[unstable/automata/re] and @racketmodname[unstable/automata/re-ext]. The latter provide a DSL for writing "dependent" regular expression machines over arbitrary @racketmodname[racket/match] patterns.
First, a few @racket[match] patterns are available to avoid specify all the details of monitored events (since most of the time the detailed options are unnecessary.)