Compare commits
8 Commits
fix-div-by
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
caf2fedbd7 | ||
![]() |
e26a2d399b | ||
![]() |
83f6f11496 | ||
![]() |
2c5bf77f1c | ||
![]() |
31fd3b8b82 | ||
![]() |
0496fdb99b | ||
![]() |
97db476a66 | ||
![]() |
eaf74871ae |
|
@ -4,11 +4,6 @@ env:
|
|||
global:
|
||||
- RACKET_DIR=~/racket
|
||||
matrix:
|
||||
- RACKET_VERSION=6.1.1
|
||||
- RACKET_VERSION=6.2
|
||||
- RACKET_VERSION=6.2.1
|
||||
- RACKET_VERSION=6.3
|
||||
- RACKET_VERSION=6.4
|
||||
- RACKET_VERSION=HEAD
|
||||
|
||||
matrix:
|
||||
|
|
|
@ -187,7 +187,7 @@ Thus, In essence this module has three responsibilites:
|
|||
|
||||
;; ModulePath -> Any
|
||||
(define (run-mod to-run)
|
||||
(vprintf "running ~s in envoronment ~s" to-run (get-topic))
|
||||
(vprintf "running ~s in environment ~s" to-run (get-topic))
|
||||
(dynamic-require to-run 0)
|
||||
(vprintf "finished running ~s" to-run))
|
||||
|
||||
|
@ -224,7 +224,7 @@ Thus, In essence this module has three responsibilites:
|
|||
(not file))
|
||||
e]
|
||||
[else
|
||||
(vprintf "compiling ~s with coverage annotations in enviornment ~s"
|
||||
(vprintf "compiling ~s with coverage annotations in environment ~s"
|
||||
file
|
||||
(get-topic))
|
||||
((annotate-top file)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#lang setup/infotab
|
||||
#lang info
|
||||
|
||||
(define cover-formats
|
||||
'(("html" cover generate-html-coverage)
|
||||
|
@ -14,3 +14,5 @@
|
|||
'(("cover" (submod cover/raco main) "a code coverage tool" 30)))
|
||||
|
||||
(define scribblings '(("scribblings/cover.scrbl" (multi-page))))
|
||||
|
||||
(define pkg-authors '("spencer@florence.io"))
|
||||
|
|
|
@ -24,7 +24,10 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
(define vector-name #'cover-coverage-vector)
|
||||
(define make-log-receiver-name #'make-log-receiver)
|
||||
(define sync-name #'sync)
|
||||
(define app-name #'#%app)
|
||||
(define hash-ref-name #'hash-ref)
|
||||
(define bfs-name #'begin-for-syntax)
|
||||
(define begin-name #'begin)
|
||||
|
||||
;; symbol [Hash srcloclist index] [Hash pathstring vector]
|
||||
;; -> (pathstring -> annotator)
|
||||
|
@ -43,7 +46,9 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
(cond [(cross-phase-persist? stx)
|
||||
;; special case: cross-phase-pesistant files
|
||||
;; are not coverable, but immutable so basically always covered
|
||||
(initialize-test-coverage-point stx)
|
||||
(define loc (stx->srcloc stx))
|
||||
(when loc
|
||||
(initialize-test-coverage-point stx loc))
|
||||
(do-final-init! #t)
|
||||
stx]
|
||||
[else
|
||||
|
@ -64,8 +69,8 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
e #f
|
||||
[(begin e mod)
|
||||
(begin
|
||||
(syntax-case #'e (#%plain-app)
|
||||
[(#%plain-app vector-set vec loc #t)
|
||||
(syntax-case #'e (quote)
|
||||
[(_ #;#%app vector-set vec (quote loc) (quote #t))
|
||||
(vector-set! (hash-ref vecmapping file) (syntax-e #'loc) #t)])
|
||||
#'mod)]
|
||||
[_ e]))
|
||||
|
@ -73,21 +78,27 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
(define initialize-test-coverage-point
|
||||
(if initialized?
|
||||
void
|
||||
(lambda (stx)
|
||||
(define loc (stx->srcloc stx))
|
||||
(lambda (stx loc)
|
||||
(unless (hash-has-key? loc->vecref loc)
|
||||
(hash-set! loc->vecref loc (list file count))
|
||||
(set! count (add1 count))))))
|
||||
|
||||
(define (test-covered stx)
|
||||
(define loc (stx->srcloc stx))
|
||||
(define (test-covered stx loc)
|
||||
(with-syntax ([vector-name vector-name]
|
||||
[#%papp app-name]
|
||||
[unsafe-vector-set! unsafe-vector-set!-name]
|
||||
[vecloc (cadr (hash-ref loc->vecref loc))])
|
||||
#`(#%plain-app unsafe-vector-set! vector-name vecloc #t)))
|
||||
#`(#%papp unsafe-vector-set! vector-name 'vecloc '#t)))
|
||||
|
||||
(define (test-coverage-point body expr phase)
|
||||
(define loc (stx->srcloc expr))
|
||||
(cond [loc
|
||||
(initialize-test-coverage-point expr loc)
|
||||
#`(#,begin-name #,(test-covered expr loc) #,body)]
|
||||
[else body]))
|
||||
|
||||
;; ---- IN ----
|
||||
(define-values/invoke-unit/infer stacktrace@)
|
||||
(define-values/invoke-unit/infer stacktrace/annotator@)
|
||||
(make-cover-annotate-top annotate-top))
|
||||
|
||||
;; -------- Annotation Helpers --------------
|
||||
|
@ -157,17 +168,21 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
|
||||
;; Syntax -> Natural
|
||||
;; Maxiumum depth of begin-for-syntaxes
|
||||
(define (get-syntax-depth expr)
|
||||
(kernel-syntax-case
|
||||
(disarm expr) #f
|
||||
(define (get-syntax-depth expr [phase 0])
|
||||
(kernel-syntax-case/phase
|
||||
(disarm expr) phase
|
||||
[(module _ _ mb)
|
||||
(get-syntax-depth #'mb)]
|
||||
[(module* _ _ mb)
|
||||
(get-syntax-depth #'mb)]
|
||||
[(begin-for-syntax b ...)
|
||||
(add1 (apply max 1 (map get-syntax-depth (syntax->list #'(b ...)))))]
|
||||
(add1 (apply max 1 (for/list ([b (in-list (syntax->list #'(b ...)))])
|
||||
(get-syntax-depth b (add1 phase)))))]
|
||||
[(define-syntaxes a ...)
|
||||
2]
|
||||
[(b ...)
|
||||
(apply max 1 (map get-syntax-depth (syntax->list #'(b ...))))]
|
||||
(apply max 1 (for/list ([b (in-list (syntax->list #'(b ...)))])
|
||||
(get-syntax-depth b phase)))]
|
||||
[_ 1]))
|
||||
|
||||
;; Natural PathString Symbol -> Syntax
|
||||
|
@ -182,17 +197,32 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
[sync sync-name]
|
||||
[file file]
|
||||
[hash-ref hash-ref-name]
|
||||
[#%papp #'#%app]
|
||||
[#%papp app-name]
|
||||
[pdefine-values #'define-values]
|
||||
[pbegin #'begin]
|
||||
[pbegin begin-name]
|
||||
[prequire '#%require]
|
||||
[pbegin-for-syntax bfs-name]
|
||||
[send-name (format-symbol "~a~a" topic 'cover-internal-send-vector-mapping)]
|
||||
[req-name (format-symbol "~a~a" topic 'cover-internal-request-vector-mapping)])
|
||||
(define startup-code
|
||||
#`(pbegin
|
||||
(pdefine-values (lgr) (#%papp current-logger))
|
||||
(pdefine-values (rec) (#%papp make-log-receiver lgr 'info 'send-name))
|
||||
(pdefine-values (vector-name)
|
||||
(pbegin
|
||||
(#%papp log-message lgr 'info 'req-name '"" '#f)
|
||||
(#%papp hash-ref
|
||||
(#%papp unsafe-vector-ref
|
||||
(#%papp sync rec)
|
||||
'2)
|
||||
'file)))))
|
||||
#`(#,@(for/list ([i bfs-depth])
|
||||
#`(#%require (for-meta #,i (rename '#%kernel prequire #%require))))
|
||||
#`(#%require
|
||||
(for-meta #,i (only '#%kernel quote))
|
||||
(for-meta #,i (rename '#%kernel prequire #%require))))
|
||||
#,@(for/list ([i bfs-depth])
|
||||
#`(prequire (only '#%kernel quote)
|
||||
(for-meta #,i (rename '#%kernel log-message log-message))
|
||||
#`(prequire (for-meta #,i (rename '#%kernel log-message log-message))
|
||||
(for-meta #,i (rename '#%kernel pbegin-for-syntax begin-for-syntax))
|
||||
(for-meta #,i (rename '#%kernel current-logger current-logger))
|
||||
(for-meta #,i (rename '#%kernel make-log-receiver make-log-receiver))
|
||||
(for-meta #,i (rename '#%kernel sync sync))
|
||||
|
@ -202,16 +232,9 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
(for-meta #,i (rename '#%kernel pbegin begin))
|
||||
(for-meta #,i (rename '#%unsafe unsafe-vector-ref unsafe-vector-ref))
|
||||
(for-meta #,i (rename '#%unsafe unsafe-vector-set! unsafe-vector-set!))))
|
||||
(pdefine-values (lgr) (#%papp current-logger))
|
||||
(pdefine-values (rec) (#%papp make-log-receiver lgr 'info 'send-name))
|
||||
(pdefine-values (vector-name)
|
||||
(pbegin
|
||||
(#%papp log-message lgr 'info 'req-name "" #f)
|
||||
(#%papp hash-ref
|
||||
(#%papp unsafe-vector-ref
|
||||
(#%papp sync rec)
|
||||
2)
|
||||
file))))))
|
||||
(prequire (for-meta #,bfs-depth (rename '#%kernel pbegin begin)))
|
||||
#,(for/fold ([stx #'(pbegin)]) ([i bfs-depth])
|
||||
#`(pbegin #,startup-code (pbegin-for-syntax #,stx))))))
|
||||
|
||||
(define inspector (variable-reference->module-declaration-inspector
|
||||
(#%variable-reference)))
|
||||
|
@ -242,7 +265,6 @@ The module implements code coverage annotations as described in cover.rkt
|
|||
|
||||
;; -------- Generic `stacktrace^` Imports --------------
|
||||
(define (with-mark src dest phase) dest)
|
||||
(define test-coverage-enabled (make-parameter #t))
|
||||
(define profile-key (gensym))
|
||||
(define profiling-enabled (make-parameter #f))
|
||||
(define initialize-profile-point void)
|
||||
|
|
6
cover/tests/bfs+define-syntax.rkt
Normal file
6
cover/tests/bfs+define-syntax.rkt
Normal file
|
@ -0,0 +1,6 @@
|
|||
#lang racket/base
|
||||
|
||||
(require (for-meta 1 racket/base)
|
||||
(for-meta 2 racket/base))
|
||||
|
||||
(begin-for-syntax (define-syntax x #f))
|
|
@ -1,2 +1,46 @@
|
|||
#lang racket
|
||||
(begin-for-syntax 1)
|
||||
;; this is a comment
|
||||
(+ 1 2)
|
||||
(λ (x) 3)
|
||||
(module+ test 20)
|
||||
(λ (x) 3)
|
||||
(module+ test 20)
|
||||
(λ (x) 3)
|
||||
(module+ test 20)
|
||||
|
||||
(begin-for-syntax
|
||||
(require (for-syntax (only-in racket/base require for-syntax #%app begin-for-syntax #%datum only-in)))
|
||||
;; this is a comment
|
||||
(+ 1 2)
|
||||
(λ (x) 3)
|
||||
(module+ test1 20)
|
||||
(λ (x) 3)
|
||||
(module+ test1 20)
|
||||
(λ (x) 3)
|
||||
(module+ test1 20)
|
||||
(begin-for-syntax
|
||||
(require (only-in racket/base + λ module*))
|
||||
(require (for-syntax (only-in racket/base require for-syntax #%app begin-for-syntax #%datum only-in)))
|
||||
(+ 1 2)
|
||||
(λ (x) 3)
|
||||
(λ (x) 3)
|
||||
(λ (x) 3)
|
||||
(module* test2 racket 20)
|
||||
|
||||
(begin-for-syntax
|
||||
(require (only-in racket/base + λ module*))
|
||||
(require (for-syntax (only-in racket/base require for-syntax #%app begin-for-syntax #%datum only-in)))
|
||||
(+ 1 2)
|
||||
(λ (x) 3)
|
||||
(λ (x) 3)
|
||||
(λ (x) 3)
|
||||
(module* test3 racket 20)
|
||||
|
||||
(begin-for-syntax
|
||||
(require (only-in racket/base + λ module*))
|
||||
(require (for-syntax (only-in racket/base require for-syntax #%app begin-for-syntax #%datum only-in)))
|
||||
(+ 1 2)
|
||||
(λ (x) 3)
|
||||
(λ (x) 3)
|
||||
(λ (x) 3)
|
||||
(module* test4 racket 20)))))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
(define-runtime-path-list others
|
||||
(list "bfs+module-nolex.rkt"
|
||||
"bfs+module.rkt"
|
||||
"bfs+define-syntax.rkt"
|
||||
"lazy-require.rkt"))
|
||||
(test-case
|
||||
"begin-for-syntax with modules should be okay"
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#lang racket
|
||||
;; These tests modified from https://github.com/jackfirth/point-free
|
||||
(provide define/compose
|
||||
arg-count
|
||||
(provide arg-count
|
||||
define/arg-count)
|
||||
|
||||
(define-syntax-rule (define/compose id f ...)
|
||||
(define id (compose f ...)))
|
||||
|
||||
(define-syntax-rule (arg-count n expr)
|
||||
(lambda args
|
||||
|
|
11
info.rkt
11
info.rkt
|
@ -1,14 +1,17 @@
|
|||
#lang setup/infotab
|
||||
#lang info
|
||||
|
||||
(define name "cover")
|
||||
(define collection 'multi)
|
||||
|
||||
(define version "3.0.3")
|
||||
(define version "3.1.1")
|
||||
|
||||
(define deps '(("base" #:version "6.1.1") "errortrace-lib" "rackunit-lib"
|
||||
"syntax-color-lib" "compiler-lib" "custom-load" "data-lib"))
|
||||
(define deps '(("base" #:version "6.5.0.4") ("errortrace-lib" #:version "1.1")
|
||||
"rackunit-lib" "syntax-color-lib" "compiler-lib"
|
||||
"custom-load" "data-lib"))
|
||||
|
||||
(define build-deps
|
||||
'("racket-doc" "scribble-lib" "typed-racket-doc" "htdp-lib"
|
||||
"net-doc" "scribble-doc" "at-exp-lib" "scheme-lib" "typed-racket-lib"
|
||||
"macro-debugger"))
|
||||
|
||||
(define pkg-authors '("spencer@florence.io"))
|
||||
|
|
Loading…
Reference in New Issue
Block a user