add some unit tests for reshaping tuples with initial-quot: slots

db4
Doug Coleman 2009-06-12 11:58:07 -05:00
parent 99bfeb62c4
commit 258abe31ab
1 changed files with 24 additions and 11 deletions

View File

@ -1,11 +1,12 @@
USING: definitions generic kernel kernel.private math math.constants USING: accessors arrays assocs calendar classes classes.algebra
parser sequences tools.test words assocs namespaces quotations classes.private classes.tuple classes.tuple.private columns
sequences.private classes continuations generic.single compiler.errors compiler.units continuations definitions
generic.standard effects classes.tuple classes.tuple.private arrays effects eval generic generic.single generic.standard grouping
vectors strings compiler.units accessors classes.algebra calendar io.streams.string kernel kernel.private math math.constants
prettyprint io.streams.string splitting summary columns math.order math.order namespaces parser parser.notes prettyprint
classes.private slots slots.private eval see words.symbol quotations random see sequences sequences.private slots
compiler.errors parser.notes ; slots.private splitting strings summary threads tools.test
vectors vocabs words words.symbol ;
IN: classes.tuple.tests IN: classes.tuple.tests
TUPLE: rect x y w h ; TUPLE: rect x y w h ;
@ -421,7 +422,6 @@ TUPLE: redefinition-problem-2 ;
[ t ] [ 3 redefinition-problem'? ] unit-test [ t ] [ 3 redefinition-problem'? ] unit-test
! Hardcore unit tests ! Hardcore unit tests
USE: threads
\ thread "slots" word-prop "slots" set \ thread "slots" word-prop "slots" set
@ -439,8 +439,6 @@ USE: threads
] with-compilation-unit ] with-compilation-unit
] unit-test ] unit-test
USE: vocabs
\ vocab "slots" word-prop "slots" set \ vocab "slots" word-prop "slots" set
[ ] [ [ ] [
@ -731,3 +729,18 @@ DEFER: redefine-tuple-twice
[ ] [ "IN: classes.tuple.tests TUPLE: redefine-tuple-twice ;" eval( -- ) ] unit-test [ ] [ "IN: classes.tuple.tests TUPLE: redefine-tuple-twice ;" eval( -- ) ] unit-test
[ t ] [ \ redefine-tuple-twice symbol? ] unit-test [ t ] [ \ redefine-tuple-twice symbol? ] unit-test
TUPLE: lucky-number { n initial-quot: [ 64 random-bits ] } ;
SLOT: winner?
[ f ] [ 100 [ lucky-number new ] replicate all-equal? ] unit-test
! Reshaping initial-quot:
lucky-number new dup n>> 2array "luckiest-number" set
[ t ] [ "luckiest-number" get first2 [ n>> ] dip = ] unit-test
[ ] [ "USING: accessors random ; IN: classes.tuple.tests TUPLE: lucky-number { n initial-quot: [ 64 random-bits ] } { winner? initial-quot: [ t ] } ;" eval( -- ) ] unit-test
[ t ] [ "luckiest-number" get first2 [ n>> ] dip = ] unit-test
[ t ] [ "luckiest-number" get first winner?>> ] unit-test