<div dir="ltr">Please, rebase instead of merging. Thank you.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 11:42 AM, <span dir="ltr"><<a href="mailto:sbloch@racket-lang.org" target="_blank">sbloch@racket-lang.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sbloch has updated `master' from 85eab5610f to 7a33712603.<br>
<a href="http://git.racket-lang.org/plt/85eab5610f..7a33712603" target="_blank">http://git.racket-lang.org/plt/85eab5610f..7a33712603</a><br>
<br>
=====[ 2 Commits ]======================================================<br>
Directory summary:<br>
100.0% collects/picturing-programs/private/<br>
<br>
~~~~~~~~~~<br>
<br>
6740ab5 Stephen Bloch <<a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a>> 2013-04-18 12:40<br>
:<br>
| Corrected a variety of wrong-arg-type error messages for map-image,<br>
| build-image, et al.<br>
|<br>
| Please merge to release branch.<br>
:<br>
M collects/picturing-programs/private/map-image.rkt | 72 +++++++++++++++-----<br>
<br>
~~~~~~~~~~<br>
<br>
7a33712 Stephen Bloch <<a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a>> 2013-04-18 12:41<br>
:<br>
| Merge branch 'master' of pltgit:plt<br>
| I'm not sure why this is non-fast-forwardable, but it apparently is.<br>
:<br>
: *** Trivial merge (omitting list) ***<br>
:<br>
<br>
=====[ Overall Diff ]===================================================<br>
<br>
collects/picturing-programs/private/map-image.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/collects/picturing-programs/private/map-image.rkt<br>
+++ NEW/collects/picturing-programs/private/map-image.rkt<br>
@@ -276,9 +276,9 @@<br>
(unless (natural? h)<br>
(error 'build3-image<br>
(format "Expected a natural number as second argument, but received ~v" h)))<br>
- (check-procedure-arity rfunc 2 'build3-image "Expected a function with contract num(x) num(y) -> color as third argument")<br>
- (check-procedure-arity gfunc 2 'build3-image "Expected a function with contract num(x) num(y) -> color as fourth argument")<br>
- (check-procedure-arity bfunc 2 'build3-image "Expected a function with contract num(x) num(y) -> color as fifth argument")<br>
+ (check-procedure-arity rfunc 2 'build3-image "Expected a function with contract num(x) num(y) -> [0-255] as third argument")<br>
+ (check-procedure-arity gfunc 2 'build3-image "Expected a function with contract num(x) num(y) -> [0-255] as fourth argument")<br>
+ (check-procedure-arity bfunc 2 'build3-image "Expected a function with contract num(x) num(y) -> [0-255] as fifth argument")<br>
(build-image-internal w h<br>
(lambda (x y)<br>
(make-color (rfunc x y) (gfunc x y) (bfunc x y)))))<br>
@@ -292,10 +292,10 @@<br>
(unless (natural? h)<br>
(error 'build4-image<br>
(format "Expected a natural number as second argument, but received ~v" h)))<br>
- (check-procedure-arity rfunc 2 'build-image "Expected a function with contract num(x) num(y) -> color as third argument")<br>
- (check-procedure-arity gfunc 2 'build-image "Expected a function with contract num(x) num(y) -> color as fourth argument")<br>
- (check-procedure-arity bfunc 2 'build-image "Expected a function with contract num(x) num(y) -> color as fifth argument")<br>
- (check-procedure-arity afunc 2 'build-image "Expected a function with contract num(x) num(y) -> color as sixth argument")<br>
+ (check-procedure-arity rfunc 2 'build4-image "Expected a function with contract num(x) num(y) -> [0-255] as third argument")<br>
+ (check-procedure-arity gfunc 2 'build4-image "Expected a function with contract num(x) num(y) -> [0-255] as fourth argument")<br>
+ (check-procedure-arity bfunc 2 'build4-image "Expected a function with contract num(x) num(y) -> [0-255] as fifth argument")<br>
+ (check-procedure-arity afunc 2 'build4-image "Expected a function with contract num(x) num(y) -> [0-255] as sixth argument")<br>
(build-image-internal w h<br>
(lambda (x y)<br>
(make-color (rfunc x y) (gfunc x y) (bfunc x y) (afunc x y)))))<br>
@@ -327,7 +327,7 @@<br>
(map-image-internal (colorize-func f) img)]<br>
[(procedure-arity-includes? f 1) ; allow f : color->color as a simple case<br>
(map-image-internal (colorize-func (lambda (x y c) (f c))) img)]<br>
- [else (error 'map-image "Expected a function of one or three parameters as first argument")]))<br>
+ [else (error 'map-image "Expected a function of one or three parameters, returning a color, as first argument")]))<br>
<br>
; map-image/extra : (nat nat color X -> broad-color) image X -> image<br>
; Like map-image, but passes a fixed extra argument to every call of the function.<br>
@@ -340,7 +340,7 @@<br>
(map-image-internal (colorize-func (lambda (x y c) (f x y c extra))) img)]<br>
[(procedure-arity-includes? f 2)<br>
(map-image-internal (colorize-func (lambda (x y c) (f c extra))) img)]<br>
- [else (error 'map-image/extra "Expected a function taking two or four parameters as first argument")]))<br>
+ [else (error 'map-image/extra "Expected a function taking two or four parameters, returning a color, as first argument")]))<br>
<br>
<br>
<br>
@@ -353,9 +353,9 @@<br>
; image -> image<br>
; Note: by default, preserves alpha values from old image.<br>
(define (map3-image rfunc gfunc bfunc pic)<br>
- (check-procedure-arity rfunc 5 'map3-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> num(r) as first argument")<br>
- (check-procedure-arity gfunc 5 'map3-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> num(g) as second argument")<br>
- (check-procedure-arity bfunc 5 'map3-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> num(b) as third argument")<br>
+ (check-procedure-arity rfunc 5 'map3-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> [0-255] as first argument")<br>
+ (check-procedure-arity gfunc 5 'map3-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> [0-255] as second argument")<br>
+ (check-procedure-arity bfunc 5 'map3-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> [0-255] as third argument")<br>
(unless (image? pic)<br>
(error 'map3-image<br>
(format "Expected an image as fourth argument, but received ~v" pic)))<br>
@@ -374,10 +374,10 @@<br>
; (int(x) int(y) int(r) int(g) int(b) int(a) -> int(a))<br>
; image -> image<br>
(define (map4-image rfunc gfunc bfunc afunc pic)<br>
- (check-procedure-arity rfunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(alpha) -> num(r) as first argument")<br>
- (check-procedure-arity gfunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(alpha) -> num(g) as second argument")<br>
- (check-procedure-arity bfunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(alpha) -> num(b) as third argument")<br>
- (check-procedure-arity afunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(alpha) -> num(alpha) as fourth argument")<br>
+ (check-procedure-arity rfunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as first argument")<br>
+ (check-procedure-arity gfunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as second argument")<br>
+ (check-procedure-arity bfunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as third argument")<br>
+ (check-procedure-arity afunc 6 'map4-image "Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as fourth argument")<br>
(unless (image? pic)<br>
(error 'map4-image<br>
"Expected an image as fifth argument, but received ~v" pic))<br>
@@ -428,3 +428,43 @@<br>
[else (error 'fold-image/extra "Expected a function taking three or five parameters as first argument")]<br>
))<br>
<br>
+ (module+ test<br>
+ (require "book-pictures.rkt")<br>
+(require test-engine/racket-tests)<br>
+(check-error (build-image 100 100 add1)<br>
+"build-image: Expected a function with contract num(x) num(y) -> color as third argument")<br>
+(check-error (build-image/extra 100 100 add1 4)<br>
+"build-image/extra: Expected a function with contract num(x) num(y) any -> color as third argument")<br>
+(check-error (build3-image 100 100 add1 + +)<br>
+"build3-image: Expected a function with contract num(x) num(y) -> [0-255] as third argument")<br>
+(check-error (build3-image 100 100 + add1 +)<br>
+"build3-image: Expected a function with contract num(x) num(y) -> [0-255] as fourth argument")<br>
+(check-error (build3-image 100 100 + + add1)<br>
+"build3-image: Expected a function with contract num(x) num(y) -> [0-255] as fifth argument")<br>
+(check-error (build4-image 100 100 add1 + + +)<br>
+"build4-image: Expected a function with contract num(x) num(y) -> [0-255] as third argument")<br>
+(check-error (build4-image 100 100 + add1 + +)<br>
+"build4-image: Expected a function with contract num(x) num(y) -> [0-255] as fourth argument")<br>
+(check-error (build4-image 100 100 + + add1 +)<br>
+"build4-image: Expected a function with contract num(x) num(y) -> [0-255] as fifth argument")<br>
+(check-error (build4-image 100 100 + + + add1)<br>
+"build4-image: Expected a function with contract num(x) num(y) -> [0-255] as sixth argument")<br>
+(check-error (map3-image add1 + + pic:bloch)<br>
+"map3-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> [0-255] as first argument")<br>
+(check-error (map3-image + add1 + pic:bloch)<br>
+"map3-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> [0-255] as second argument")<br>
+(check-error (map3-image + + add1 pic:bloch)<br>
+"map3-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) -> [0-255] as third argument")<br>
+(check-error (map4-image add1 + + + pic:bloch)<br>
+"map4-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as first argument")<br>
+(check-error (map4-image + add1 + + pic:bloch)<br>
+"map4-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as second argument")<br>
+(check-error (map4-image + + add1 + pic:bloch)<br>
+"map4-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as third argument")<br>
+(check-error (map4-image + + + add1 pic:bloch)<br>
+"map4-image: Expected a function with contract num(x) num(y) num(r) num(g) num(b) num(a) -> [0-255] as fourth argument")<br>
+; more checks<br>
+;(check-error (map-image (lambda (c) c) pic:bloch)<br>
+; "No, this should NOT produce an error.")<br>
+(test)<br>
+) ; end of test module<br>
</blockquote></div><br></div>