From 1d54bf17a5072833da2e57d8e622f2bc64c855df Mon Sep 17 00:00:00 2001 From: Blake Johnson Date: Tue, 17 Aug 2010 12:09:05 -0600 Subject: [PATCH] zo-parse debugging and read in zo-exs original commit: f27fe3d5c9941e536275d0f56cb02d6df16ac283 --- collects/compiler/zo-parse.rkt | 15 +++++++++----- collects/tests/compiler/zo-exs.rkt | 33 +++++++++++++++++------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/collects/compiler/zo-parse.rkt b/collects/compiler/zo-parse.rkt index 51b844e775..b7889fe291 100644 --- a/collects/compiler/zo-parse.rkt +++ b/collects/compiler/zo-parse.rkt @@ -709,10 +709,11 @@ (let loop ([need-car 0] [proper #f]) (begin-with-definitions (define ch (cp-getc cp)) - (define-values (cpt-start cpt-tag) (let ([x (cpt-table-lookup ch)]) - (unless x - (error 'read-compact "unknown code : ~a" ch)) - (values (car x) (cdr x)))) + (define-values (cpt-start cpt-tag) + (let ([x (cpt-table-lookup ch)]) + (unless x + (error 'read-compact "unknown code : ~a" ch)) + (values (car x) (cdr x)))) (define v (case cpt-tag [(delayed) @@ -1004,8 +1005,12 @@ (define cp (make-cport 0 shared-size port size* rst-start symtab so* (make-vector symtabsize #f) (make-hash) (make-hash))) - (for/list ([i (in-range 1 symtabsize)]) + (for ([i (in-range 1 symtabsize)]) (read-sym cp i)) + + #;(for ([i (in-naturals)] + [v (in-vector (cport-symtab cp))]) + (printf "~a: ~s~n~n" i (placeholder-get v))) (set-cport-pos! cp shared-size) (make-reader-graph (read-marshalled 'compilation-top-type cp)))) diff --git a/collects/tests/compiler/zo-exs.rkt b/collects/tests/compiler/zo-exs.rkt index 75aea4d252..8fd5d3ee47 100644 --- a/collects/tests/compiler/zo-exs.rkt +++ b/collects/tests/compiler/zo-exs.rkt @@ -3,12 +3,28 @@ compiler/zo-marshal tests/eli-tester) +(define (read-compiled-bytes bs) + (parameterize ([read-accept-compiled #t]) + (read (open-input-bytes bs)))) + (define (roundtrip ct) (define bs (zo-marshal ct)) - (test bs - (zo-parse (open-input-bytes bs)) => ct)) + (test #:failure-prefix (format "~S" ct) + (test bs + (zo-parse (open-input-bytes bs)) => ct + (read-compiled-bytes bs)))) (test + (roundtrip + (compilation-top 0 + (prefix 0 empty empty) + (current-directory))) + + (roundtrip + (compilation-top 0 + (prefix 0 empty empty) + (list (current-directory)))) + (local [(define (hash-test make-hash-placeholder) (roundtrip (compilation-top 0 @@ -19,17 +35,6 @@ (make-reader-graph ht)))))] (hash-test make-hash-placeholder) (hash-test make-hasheq-placeholder) - (hash-test make-hasheqv-placeholder)) - - - (roundtrip - (compilation-top 0 - (prefix 0 empty empty) - (current-directory))) - - (roundtrip - (compilation-top 0 - (prefix 0 empty empty) - (list (current-directory))))) + (hash-test make-hasheqv-placeholder)))