fix some bad aligned-pasteboard tests
svn: r16348
This commit is contained in:
parent
717e290fb9
commit
c483470deb
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
(require
|
(require
|
||||||
mzlib/etc
|
mzlib/etc
|
||||||
mzlib/list
|
mzlib/list
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(module test-macro mzscheme
|
(module test-macro mzscheme
|
||||||
|
(require mzlib/etc)
|
||||||
(provide test)
|
(provide test)
|
||||||
|
|
||||||
;; test: (lambda (a?) ((a? a? . -> . boolean?) a? a? . -> . (void))
|
;; test: (lambda (a?) ((a? a? . -> . boolean?) a? a? . -> . (void))
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
(with-handlers
|
(with-handlers
|
||||||
([exn? identity])
|
([exn? identity])
|
||||||
actual)])
|
actual)])
|
||||||
(and (not (exn? result))
|
(unless (and (not (exn? result))
|
||||||
(test result expected))))))
|
(test result expected))
|
||||||
|
(fprintf (current-error-port) "test failed: ~s != ~s\n" result expected))))))
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
(require
|
(require
|
||||||
mzlib/etc
|
mzlib/etc
|
||||||
mzlib/class
|
mzlib/class
|
||||||
|
@ -7,15 +8,15 @@
|
||||||
"../aligned-pasteboard.ss"
|
"../aligned-pasteboard.ss"
|
||||||
"../aligned-editor-container.ss")
|
"../aligned-editor-container.ss")
|
||||||
|
|
||||||
(printf "running tests for pasteboard-lib.ss~n")
|
;; (printf "running tests for pasteboard-lib.ss~n")
|
||||||
|
|
||||||
;;pasteboard-root: ((is-a?/c aligned-pasteboard<%>) -> (is-a?/c aligned-pasteboard<%>))
|
;;pasteboard-root: ((is-a?/c aligned-pasteboard<%>) -> (is-a?/c aligned-pasteboard<%>))
|
||||||
;;gets the top most aligned pasteboard in the tree of pasteboards and containers
|
;;gets the top most aligned pasteboard in the tree of pasteboards and containers
|
||||||
|
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[pb2 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb2 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb3 (instantiate aligned-vertical-pasteboard% ())]
|
[pb3 (instantiate vertical-pasteboard% ())]
|
||||||
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
||||||
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
||||||
|
|
||||||
|
@ -42,9 +43,9 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[pb2 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb2 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb3 (instantiate aligned-vertical-pasteboard% ())]
|
[pb3 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate aligned-editor-snip% () (editor pb1))]
|
[es1 (instantiate aligned-editor-snip% () (editor pb1))]
|
||||||
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
||||||
|
|
||||||
|
@ -73,9 +74,9 @@
|
||||||
;;pasteboard-parent: ((is-a?/c pasteboard%) . -> . (is-a?/c aligned-editor-container<%>))
|
;;pasteboard-parent: ((is-a?/c pasteboard%) . -> . (is-a?/c aligned-editor-container<%>))
|
||||||
;;gets the canvas or snip that the pasteboard is displayed in
|
;;gets the canvas or snip that the pasteboard is displayed in
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[pb2 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb2 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb3 (instantiate aligned-vertical-pasteboard% ())]
|
[pb3 (instantiate vertical-pasteboard% ())]
|
||||||
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
||||||
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
||||||
|
|
||||||
|
@ -102,9 +103,9 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[pb2 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb2 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb3 (instantiate aligned-vertical-pasteboard% ())]
|
[pb3 (instantiate vertical-pasteboard% ())]
|
||||||
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
||||||
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
||||||
|
|
||||||
|
@ -130,10 +131,11 @@
|
||||||
es3)
|
es3)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#|
|
||||||
;;num-sizeable: ((is-a?/c aligned-pasteboard<%>) . -> . number?)
|
;;num-sizeable: ((is-a?/c aligned-pasteboard<%>) . -> . number?)
|
||||||
;;the number of snips in the pasteboard that can be resized
|
;;the number of snips in the pasteboard that can be resized
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es1 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
[es2 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es2 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
[es3 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es3 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
|
@ -164,11 +166,11 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate aligned-editor-snip% () (editor (instantiate aligned-vertical-pasteboard% ())))]
|
[es1 (instantiate aligned-editor-snip% () (editor (instantiate vertical-pasteboard% ())))]
|
||||||
[es2 (instantiate aligned-editor-snip% () (editor (instantiate aligned-vertical-pasteboard% ())))]
|
[es2 (instantiate aligned-editor-snip% () (editor (instantiate vertical-pasteboard% ())))]
|
||||||
[es3 (instantiate aligned-editor-snip% () (editor (instantiate aligned-vertical-pasteboard% ())))]
|
[es3 (instantiate aligned-editor-snip% () (editor (instantiate vertical-pasteboard% ())))]
|
||||||
[es4 (instantiate aligned-editor-snip% () (editor (instantiate aligned-vertical-pasteboard% ())))]
|
[es4 (instantiate aligned-editor-snip% () (editor (instantiate vertical-pasteboard% ())))]
|
||||||
|
|
||||||
[frame (instantiate frame% () (label "l") (width 10) (height 10))]
|
[frame (instantiate frame% () (label "l") (width 10) (height 10))]
|
||||||
[canvas (instantiate aligned-editor-canvas% () (parent frame) (editor pb1))])
|
[canvas (instantiate aligned-editor-canvas% () (parent frame) (editor pb1))])
|
||||||
|
@ -202,3 +204,4 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(printf "tests done~n")
|
(printf "tests done~n")
|
||||||
|
|#
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
(require
|
(require
|
||||||
mzlib/etc
|
mzlib/etc
|
||||||
mzlib/class
|
mzlib/class
|
||||||
|
@ -7,14 +8,14 @@
|
||||||
"../aligned-editor-container.ss"
|
"../aligned-editor-container.ss"
|
||||||
"test-macro.ss")
|
"test-macro.ss")
|
||||||
|
|
||||||
(printf "running tests for snip-lib.ss~n")
|
;;(printf "running tests for snip-lib.ss~n")
|
||||||
|
|
||||||
;;snip-width: ((is-a?/c aligned-pasteboard<%>) (is-a?/c snip%) . -> . number?)
|
;;snip-width: ((is-a?/c aligned-pasteboard<%>) (is-a?/c snip%) . -> . number?)
|
||||||
;;the width of a snip in the given pasteboard
|
;;the width of a snip in the given pasteboard
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate editor-snip% () (editor pb1))]
|
[es1 (instantiate editor-snip% () (editor pb1))]
|
||||||
[pb2 (instantiate aligned-vertical-pasteboard% ())]
|
[pb2 (instantiate vertical-pasteboard% ())]
|
||||||
|
|
||||||
[frame (instantiate frame% () (label "l") (width 10) (height 10))]
|
[frame (instantiate frame% () (label "l") (width 10) (height 10))]
|
||||||
[canvas (instantiate aligned-editor-canvas% () (parent frame) (editor pb2))])
|
[canvas (instantiate aligned-editor-canvas% () (parent frame) (editor pb2))])
|
||||||
|
@ -25,15 +26,15 @@
|
||||||
(sleep/yield 1)
|
(sleep/yield 1)
|
||||||
(test
|
(test
|
||||||
equal?
|
equal?
|
||||||
(snip-width pb2 es1)
|
(snip-width #;pb2 es1)
|
||||||
20)
|
20.0)
|
||||||
|
|
||||||
(send es1 resize 200 90)
|
(send es1 resize 200 90)
|
||||||
(sleep/yield 1)
|
(sleep/yield 1)
|
||||||
(test
|
(test
|
||||||
equal?
|
equal?
|
||||||
(snip-width pb2 es1)
|
(snip-width #;pb2 es1)
|
||||||
200)
|
200.0)
|
||||||
|
|
||||||
(send frame show false)
|
(send frame show false)
|
||||||
)
|
)
|
||||||
|
@ -41,9 +42,9 @@
|
||||||
;;snip-height: ((is-a?/c aligned-pasteboard<%>) (is-a?/c snip%) . -> . number?)
|
;;snip-height: ((is-a?/c aligned-pasteboard<%>) (is-a?/c snip%) . -> . number?)
|
||||||
;;the height of a snip in the given pasteboard
|
;;the height of a snip in the given pasteboard
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate editor-snip% () (editor pb1))]
|
[es1 (instantiate editor-snip% () (editor pb1))]
|
||||||
[pb2 (instantiate aligned-vertical-pasteboard% ())]
|
[pb2 (instantiate vertical-pasteboard% ())]
|
||||||
|
|
||||||
[frame (instantiate frame% () (label "l") (width 10) (height 10))]
|
[frame (instantiate frame% () (label "l") (width 10) (height 10))]
|
||||||
[canvas (instantiate aligned-editor-canvas% () (parent frame) (editor pb2))])
|
[canvas (instantiate aligned-editor-canvas% () (parent frame) (editor pb2))])
|
||||||
|
@ -54,15 +55,15 @@
|
||||||
(sleep/yield 1)
|
(sleep/yield 1)
|
||||||
(test
|
(test
|
||||||
equal?
|
equal?
|
||||||
(snip-height pb2 es1)
|
(snip-height #;pb2 es1)
|
||||||
20)
|
20.0)
|
||||||
|
|
||||||
(send es1 resize 200 90)
|
(send es1 resize 200 90)
|
||||||
(sleep/yield 1)
|
(sleep/yield 1)
|
||||||
(test
|
(test
|
||||||
equal?
|
equal?
|
||||||
(snip-height pb2 es1)
|
(snip-height #;pb2 es1)
|
||||||
90)
|
90.0)
|
||||||
|
|
||||||
(send frame show false)
|
(send frame show false)
|
||||||
)
|
)
|
||||||
|
@ -95,11 +96,11 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-horizontal-pasteboard% ())]
|
([pb1 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb2 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb2 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb3 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb3 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb4 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb4 (instantiate horizontal-pasteboard% ())]
|
||||||
[pb5 (instantiate aligned-horizontal-pasteboard% ())]
|
[pb5 (instantiate horizontal-pasteboard% ())]
|
||||||
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
[es2 (instantiate aligned-editor-snip% () (editor pb2))]
|
||||||
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
[es3 (instantiate aligned-editor-snip% () (editor pb3))]
|
||||||
[es4 (instantiate aligned-editor-snip% () (editor pb4))]
|
[es4 (instantiate aligned-editor-snip% () (editor pb4))]
|
||||||
|
@ -139,7 +140,7 @@
|
||||||
;;fold-snip: (lambda (b?) ((any? b? . -> . b?) b? (is-a?/c snip%) . -> . b?))
|
;;fold-snip: (lambda (b?) ((any? b? . -> . b?) b? (is-a?/c snip%) . -> . b?))
|
||||||
;;the application of f on all snips from snip to the end in a foldl foldr mannor
|
;;the application of f on all snips from snip to the end in a foldl foldr mannor
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es1 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
[es2 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es2 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
[es3 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es3 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
|
@ -163,10 +164,10 @@
|
||||||
=
|
=
|
||||||
(fold-snip
|
(fold-snip
|
||||||
(lambda (snip total-height)
|
(lambda (snip total-height)
|
||||||
(+ (snip-height pb1 snip)
|
(+ (snip-height #;pb1 snip)
|
||||||
total-height))
|
total-height))
|
||||||
0
|
0
|
||||||
es4)
|
es1)
|
||||||
400)
|
400)
|
||||||
|
|
||||||
(send frame show false)
|
(send frame show false)
|
||||||
|
@ -176,7 +177,7 @@
|
||||||
;;for-each-snip: (((is-a?/c snip%) . -> . (void)) (is-a/c? snip%) . -> . (void))
|
;;for-each-snip: (((is-a?/c snip%) . -> . (void)) (is-a/c? snip%) . -> . (void))
|
||||||
;;applies the function to all the snips
|
;;applies the function to all the snips
|
||||||
(let*
|
(let*
|
||||||
([pb1 (instantiate aligned-vertical-pasteboard% ())]
|
([pb1 (instantiate vertical-pasteboard% ())]
|
||||||
[es1 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es1 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
[es2 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es2 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
[es3 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
[es3 (instantiate editor-snip% () (editor (instantiate text% ())))]
|
||||||
|
@ -195,7 +196,7 @@
|
||||||
(for-each-snip
|
(for-each-snip
|
||||||
(lambda (snip)
|
(lambda (snip)
|
||||||
(set! count (add1 count)))
|
(set! count (add1 count)))
|
||||||
es4)
|
es1)
|
||||||
|
|
||||||
(test
|
(test
|
||||||
=
|
=
|
||||||
|
@ -204,4 +205,4 @@
|
||||||
|
|
||||||
(send frame show false)
|
(send frame show false)
|
||||||
)
|
)
|
||||||
(printf "tests done~n")
|
;;(printf "tests done~n")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user