From 36323cf3be7711a4704333effffdd3b2538d2ccc Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 25 Feb 2012 21:41:55 -0600 Subject: [PATCH] added a pict-snip test case --- collects/drracket/private/pict-snip.rkt | 20 +- collects/tests/drracket/snip/pict-snip.rkt | 285 +++++++++++++++++++++ 2 files changed, 295 insertions(+), 10 deletions(-) create mode 100644 collects/tests/drracket/snip/pict-snip.rkt diff --git a/collects/drracket/private/pict-snip.rkt b/collects/drracket/private/pict-snip.rkt index 9b65e456a7..8816067088 100644 --- a/collects/drracket/private/pict-snip.rkt +++ b/collects/drracket/private/pict-snip.rkt @@ -6,7 +6,7 @@ wxme (prefix-in r: racket/base)) -(provide pict-snip% snip-class) +(provide pict-snip% snip-class reader) ;; this snip is created on the user's space, ;; but its callbacks are invoked on DrRacket's. @@ -61,15 +61,15 @@ (send (get-the-snip-class-list) add snip-class) (define reader - (class* object% (snip-reader<%>) - (define/public (read-header version stream) (void)) - (define/public (read-snip text-only? version stream) - (define bytes (send stream read-raw-bytes 'pict-snip)) - (if text-only? - #"#" - (or (parse-pict-snip-from-bytes bytes) - (error 'pict-snip.rkt "could not read pict-snip from stream")))) - (super-new))) + (new (class* object% (snip-reader<%>) + (define/public (read-header version stream) (void)) + (define/public (read-snip text-only? version stream) + (define bytes (send stream read-raw-bytes 'pict-snip)) + (if text-only? + #"#" + (or (parse-pict-snip-from-bytes bytes) + (error 'pict-snip.rkt "could not read pict-snip from stream")))) + (super-new)))) ;; parse-pict-snip-from-bytes : bytes -> (or/c (is-a?/c pict-snip%) #f) (define (parse-pict-snip-from-bytes bytes) diff --git a/collects/tests/drracket/snip/pict-snip.rkt b/collects/tests/drracket/snip/pict-snip.rkt new file mode 100644 index 0000000000..5c4b3145c5 --- /dev/null +++ b/collects/tests/drracket/snip/pict-snip.rkt @@ -0,0 +1,285 @@ +#reader(lib"read.ss""wxme")WXME0108 ## +#| + This file uses the GRacket editor format. + Open this file in DrRacket version 5.2.1.6 or later to read it. + + Most likely, it was created by saving a program in DrRacket, + and it probably contains a program with non-text elements + (such as images or comment boxes). + + http://racket-lang.org/ +|# + 30 7 #"wxtext\0" +3 1 6 #"wxtab\0" +1 1 8 #"wximage\0" +2 0 8 #"wxmedia\0" +4 1 34 #"(lib \"syntax-browser.ss\" \"mrlib\")\0" +1 0 16 #"drscheme:number\0" +3 0 44 #"(lib \"number-snip.ss\" \"drscheme\" \"private\")\0" +1 0 36 #"(lib \"comment-snip.ss\" \"framework\")\0" +1 0 93 +( + #"((lib \"collapsed-snipclass.ss\" \"framework\") (lib \"collapsed-sni" + #"pclass-wxme.ss\" \"framework\"))\0" +) 0 0 43 #"(lib \"collapsed-snipclass.ss\" \"framework\")\0" +0 0 19 #"drscheme:sexp-snip\0" +0 0 36 #"(lib \"cache-image-snip.ss\" \"mrlib\")\0" +1 0 68 +( + #"((lib \"image-core.ss\" \"mrlib\") (lib \"image-core-wxme.rkt\" \"mr" + #"lib\"))\0" +) 1 0 33 #"(lib \"bullet-snip.ss\" \"browser\")\0" +0 0 88 +( + #"((lib \"pict-snip.rkt\" \"drracket\" \"private\") (lib \"pict-snip.r" + #"kt\" \"drracket\" \"private\"))\0" +) 0 0 29 #"drscheme:bindings-snipclass%\0" +1 0 25 #"(lib \"matrix.ss\" \"htdp\")\0" +1 0 22 #"drscheme:lambda-snip%\0" +1 0 57 +#"(lib \"hrule-snip.rkt\" \"macro-debugger\" \"syntax-browser\")\0" +1 0 45 #"(lib \"image-snipr.ss\" \"slideshow\" \"private\")\0" +1 0 26 #"drscheme:pict-value-snip%\0" +0 0 38 #"(lib \"pict-snipclass.ss\" \"slideshow\")\0" +2 0 55 #"(lib \"vertical-separator-snip.ss\" \"stepper\" \"private\")\0" +1 0 18 #"drscheme:xml-snip\0" +1 0 31 #"(lib \"xml-snipclass.ss\" \"xml\")\0" +1 0 21 #"drscheme:scheme-snip\0" +2 0 34 #"(lib \"scheme-snipclass.ss\" \"xml\")\0" +1 0 10 #"text-box%\0" +1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0" +1 0 15 #"test-case-box%\0" +2 0 1 6 #"wxloc\0" + 0 0 57 0 1 #"\0" +0 75 1 #"\0" +0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9 +#"Standard\0" +0 75 7 #"Monaco\0" +0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24 +#"framework:default-color\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 15 +#"text:ports out\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 192 46 214 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1 +-1 2 15 #"text:ports err\0" +0 -1 1 #"\0" +1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1 +-1 2 1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 17 +#"text:ports value\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 57 89 216 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1 +-1 2 27 #"Matching Parenthesis Style\0" +0 -1 1 #"\0" +1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1 +-1 2 1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 102 102 255 0 0 0 -1 -1 2 +37 #"framework:syntax-color:scheme:symbol\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 102 102 255 0 0 0 -1 -1 2 +38 #"framework:syntax-color:scheme:keyword\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 102 102 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 249 148 40 0 0 0 -1 -1 2 +38 #"framework:syntax-color:scheme:comment\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 249 148 40 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 51 174 51 0 0 0 -1 -1 2 37 +#"framework:syntax-color:scheme:string\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 51 174 51 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 60 194 57 0 0 0 -1 -1 2 39 +#"framework:syntax-color:scheme:constant\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 60 194 57 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 151 69 43 0 0 0 -1 -1 2 42 +#"framework:syntax-color:scheme:parenthesis\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 151 69 43 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 36 +#"framework:syntax-color:scheme:error\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +36 #"framework:syntax-color:scheme:other\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 50 163 255 0 0 0 -1 -1 2 +38 #"drracket:check-syntax:lexically-bound\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 50 163 255 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 192 203 0 0 0 -1 -1 2 +28 #"drracket:check-syntax:set!d\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 192 203 0 0 0 -1 -1 2 +37 #"drracket:check-syntax:unused-require\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 192 203 0 0 0 -1 -1 2 +36 #"drracket:check-syntax:free-variable\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 192 203 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 166 0 255 0 0 0 -1 -1 2 31 +#"drracket:check-syntax:imported\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 166 0 255 0 0 0 -1 -1 2 47 +#"drracket:check-syntax:my-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 192 203 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 50 205 50 0 0 0 -1 -1 2 50 +#"drracket:check-syntax:their-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 50 205 50 0 0 0 -1 -1 2 48 +#"drracket:check-syntax:unk-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 240 230 140 0 0 0 -1 -1 2 +49 #"drracket:check-syntax:both-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 240 230 140 0 0 0 -1 -1 2 +26 #"plt:htdp:test-coverage-on\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 205 92 92 0 0 0 -1 -1 2 27 +#"plt:htdp:test-coverage-off\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 205 92 92 0 0 0 -1 -1 4 1 +#"\0" +0 70 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 4 4 #"XML\0" +0 70 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 2 1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 34 139 34 0 0 0 -1 -1 2 37 +#"plt:module-language:test-coverage-on\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 34 139 34 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 176 48 96 0 0 0 -1 -1 2 38 +#"plt:module-language:test-coverage-off\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 176 48 96 0 0 0 -1 -1 4 1 +#"\0" +0 71 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 4 1 #"\0" +0 -1 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 0 255 0 0 0 -1 +-1 4 1 #"\0" +0 71 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 0 255 0 0 0 -1 +-1 4 1 #"\0" +0 71 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 100 0 0 0 0 -1 +-1 4 1 #"\0" +0 -1 1 #"\0" +1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 255 255 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 0 0 0 0 0 -1 -1 + 0 5 0 27 3 17 #"#lang racket/base" +0 0 4 29 1 #"\n" +0 14 4 4 3820 +( + #"(516.0 114.2421875 14.0 43.12109375 ((do-set-pen! ((0 0 0 1.0) 1 sol" + #"id round round #f)) (do-set-brush! ((255 255 255 1.0) solid #f #f #f" + #")) (set-font (12 #f default normal normal #f default #f)) (set-smoot" + #"hing unsmoothed) (set-text-mode transparent) (set-alpha 1.0) (set-cl" + #"ipping-region #f) (set-scale 4.0 4.0) (set-font (14 #f roman italic " + #"normal #f default #t)) (draw-text \"e\" 0.0 0.2802734375 #t 0 0.0) (" + #"set-font (12 #f default normal normal #f default #f)) (set-font (14 " + #"#f roman normal normal #f default #t)) (draw-text \" ::= \" 6.0 0.28" + #"02734375 #t 0 0.0) (set-font (12 #f default normal normal #f default" + #" #f)) (set-font (14 #f roman normal normal #f default #t)) (draw-tex" + #"t \"(\" 29.0 0.2802734375 #t 0 0.0) (set-font (12 #f default normal " + #"normal #f default #f)) (set-font (14 #f roman italic normal #f defau" + #"lt #t)) (draw-text \"e\" 34.0 0.2802734375 #t 0 0.0) (set-font (12 #" + #"f default normal normal #f default #f)) (set-font (14 #f roman norma" + #"l normal #f default #t)) (draw-text \" \" 40.0 0.2802734375 #t 0 0.0" + #") (set-font (12 #f default normal normal #f default #f)) (set-font (" + #"14 #f roman italic normal #f default #t)) (draw-text \"e\" 44.0 0.28" + #"02734375 #t 0 0.0) (set-font (12 #f default normal normal #f default" + #" #f)) (set-font (14 #f roman normal normal #f default #t)) (draw-tex" + #"t \")\" 50.0 0.2802734375 #t 0 0.0) (set-font (12 #f default normal " + #"normal #f default #f)) (set-font (14 #f roman normal normal #f defau" + #"lt #t)) (draw-text \" | \" 55.0 0.2802734375 #t 0 0.0) (set-font (12" + #" #f default normal normal #f default #f)) (set-font (14 #f roman ita" + #"lic normal #f default #t)) (draw-text \"x\" 65.0 0.2802734375 #t 0 0" + #".0) (set-font (12 #f default normal normal #f default #f)) (set-font" + #" (14 #f roman normal normal #f default #t)) (draw-text \" | \" 71.0 " + #"0.2802734375 #t 0 0.0) (set-font (12 #f default normal normal #f def" + #"ault #f)) (set-font (14 #f roman normal normal #f default #t)) (draw" + #"-text \"(\" 81.0 0.2802734375 #t 0 0.0) (set-font (12 #f default nor" + #"mal normal #f default #f)) (set-font (14 #f swiss normal normal #f d" + #"efault #t)) (draw-text \"\316\273\" 86.0 0.0 #t 0 0.0) (set-font (12" + #" #f default normal normal #f default #f)) (set-font (14 #f roman nor" + #"mal normal #f default #t)) (draw-text \" \" 94.0 0.2802734375 #t 0 0" + #".0) (set-font (12 #f default normal normal #f default #f)) (set-font" + #" (14 #f roman normal normal #f default #t)) (draw-text \"(\" 98.0 0." + #"2802734375 #t 0 0.0) (set-font (12 #f default normal normal #f defau" + #"lt #f)) (set-font (14 #f roman italic normal #f default #t)) (draw-t" + #"ext \"x\" 103.0 0.2802734375 #t 0 0.0) (set-font (12 #f default norm" + #"al normal #f default #f)) (set-font (14 #f roman normal normal #f de" + #"fault #t)) (draw-text \")\" 109.0 0.2802734375 #t 0 0.0) (set-font (" + #"12 #f default normal normal #f default #f)) (set-font (14 #f roman n" + #"ormal normal #f default #t)) (draw-text \" \" 114.0 0.2802734375 #t " + #"0 0.0) (set-font (12 #f default normal normal #f default #f)) (set-f" + #"ont (14 #f roman italic normal #f default #t)) (draw-text \"e\" 118." + #"0 0.2802734375 #t 0 0.0) (set-font (12 #f default normal normal #f d" + #"efault #f)) (set-font (14 #f roman normal normal #f default #t)) (dr" + #"aw-text \")\" 124.0 0.2802734375 #t 0 0.0) (set-font (12 #f default " + #"normal normal #f default #f)) (set-font (14 #f roman normal normal #" + #"f default #t)) (draw-text \" | \" 19.0 14.560546875 #t 0 0.0) (set-f" + #"ont (12 #f default normal normal #f default #f)) (set-font (14 #f ro" + #"man italic normal #f default #t)) (draw-text \"number\" 29.0 14.5605" + #"46875 #t 0 0.0) (set-font (12 #f default normal normal #f default #f" + #")) (set-font (14 #f roman normal n" + #"ormal #f default #t)) (draw-text \" | \" 72.0 14.560546875 #t 0 0.0)" + #" (set-font (12 #f default normal normal #f default #f)) (set-font (1" + #"4 #f swiss normal normal #f default #t)) (draw-text \"add1\" 82.0 14" + #".2802734375 #t 0 0.0) (set-font (12 #f default normal normal #f defa" + #"ult #f)) (set-scale 1.0 1.0)))" +) 0 0 4 29 1 #"\n" +0 0 4 29 1 #"\n" +0 0