2009-09-30 13:33:10 -04:00
|
|
|
! Copyright (C) 2009 Keith Lazuka.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-10-08 06:23:17 -04:00
|
|
|
USING: fry images.loader images.normalization io
|
|
|
|
|
io.encodings.binary io.files io.pathnames io.streams.byte-array
|
|
|
|
|
kernel locals namespaces quotations sequences serialize
|
|
|
|
|
tools.test ;
|
2009-09-30 13:33:10 -04:00
|
|
|
IN: images.testing
|
|
|
|
|
|
2009-09-30 16:35:51 -04:00
|
|
|
<PRIVATE
|
|
|
|
|
|
2009-10-08 06:23:17 -04:00
|
|
|
: fig-name ( path -- newpath )
|
2009-09-30 16:35:51 -04:00
|
|
|
[ parent-directory canonicalize-path ]
|
2009-10-08 06:23:17 -04:00
|
|
|
[ file-stem ".fig" append ] bi
|
2009-09-30 16:35:51 -04:00
|
|
|
append-path ;
|
|
|
|
|
|
2009-10-08 06:23:17 -04:00
|
|
|
PRIVATE>
|
|
|
|
|
|
2009-09-30 16:35:51 -04:00
|
|
|
: save-as-reference-image ( path -- )
|
2009-10-08 06:23:17 -04:00
|
|
|
[ load-image ] [ fig-name ] bi
|
|
|
|
|
binary [ serialize ] with-file-writer ;
|
2009-09-30 16:35:51 -04:00
|
|
|
|
2009-10-08 06:23:17 -04:00
|
|
|
: load-reference-image ( path -- image )
|
|
|
|
|
fig-name binary [ deserialize ] with-file-reader ;
|
|
|
|
|
|
|
|
|
|
:: encode-test ( path image-class -- )
|
|
|
|
|
f verbose-tests? [
|
|
|
|
|
path load-image dup clone normalize-image 1quotation swap
|
|
|
|
|
'[
|
|
|
|
|
binary [ _ image-class image>stream ] with-byte-writer
|
|
|
|
|
image-class load-image* normalize-image
|
|
|
|
|
] unit-test
|
|
|
|
|
] with-variable ;
|
2009-09-30 16:35:51 -04:00
|
|
|
|
|
|
|
|
: decode-test ( path -- )
|
2009-10-02 17:20:33 -04:00
|
|
|
f verbose-tests? [
|
|
|
|
|
[ load-image 1quotation ]
|
2009-10-08 06:23:17 -04:00
|
|
|
[ '[ _ load-reference-image ] ] bi
|
2009-10-02 17:20:33 -04:00
|
|
|
unit-test
|
|
|
|
|
] with-variable ;
|