2005-03-28 23:45:13 -05:00
|
|
|
IN: temporary
|
2004-11-28 19:07:24 -05:00
|
|
|
USE: hashtables
|
|
|
|
USE: namespaces
|
|
|
|
USE: generic
|
|
|
|
USE: test
|
2004-12-10 19:29:07 -05:00
|
|
|
USE: kernel
|
2004-12-12 16:32:47 -05:00
|
|
|
USE: math
|
|
|
|
USE: words
|
|
|
|
USE: lists
|
2004-12-23 02:14:40 -05:00
|
|
|
USE: vectors
|
2005-01-13 14:41:08 -05:00
|
|
|
USE: alien
|
2005-08-21 23:35:50 -04:00
|
|
|
USE: sequences
|
|
|
|
USE: prettyprint
|
|
|
|
USE: io
|
|
|
|
USE: parser
|
|
|
|
USE: strings
|
2004-11-28 19:07:24 -05:00
|
|
|
|
2004-12-12 16:32:47 -05:00
|
|
|
GENERIC: class-of
|
|
|
|
|
|
|
|
M: fixnum class-of drop "fixnum" ;
|
|
|
|
M: word class-of drop "word" ;
|
|
|
|
M: cons class-of drop "cons" ;
|
|
|
|
|
|
|
|
[ "fixnum" ] [ 5 class-of ] unit-test
|
|
|
|
[ "cons" ] [ [ 1 2 3 ] class-of ] unit-test
|
|
|
|
[ "word" ] [ \ class-of class-of ] unit-test
|
|
|
|
[ 3.4 class-of ] unit-test-fails
|
|
|
|
|
|
|
|
GENERIC: foobar
|
|
|
|
M: object foobar drop "Hello world" ;
|
|
|
|
M: fixnum foobar drop "Goodbye cruel world" ;
|
|
|
|
|
|
|
|
[ "Hello world" ] [ 4 foobar foobar ] unit-test
|
|
|
|
[ "Goodbye cruel world" ] [ 4 foobar ] unit-test
|
2004-12-12 16:54:29 -05:00
|
|
|
|
|
|
|
GENERIC: bool>str
|
2005-09-09 17:32:38 -04:00
|
|
|
M: general-t bool>str drop "true" ;
|
2004-12-12 16:54:29 -05:00
|
|
|
M: f bool>str drop "false" ;
|
|
|
|
|
|
|
|
: str>bool
|
|
|
|
[
|
2005-01-13 19:49:47 -05:00
|
|
|
[[ "true" t ]]
|
|
|
|
[[ "false" f ]]
|
2004-12-12 16:54:29 -05:00
|
|
|
] assoc ;
|
|
|
|
|
|
|
|
[ t ] [ t bool>str str>bool ] unit-test
|
|
|
|
[ f ] [ f bool>str str>bool ] unit-test
|
2004-12-12 23:49:44 -05:00
|
|
|
|
|
|
|
PREDICATE: cons nonempty-list list? ;
|
|
|
|
|
|
|
|
GENERIC: funny-length
|
|
|
|
M: cons funny-length drop 0 ;
|
|
|
|
M: nonempty-list funny-length length ;
|
|
|
|
|
2005-01-13 19:49:47 -05:00
|
|
|
[ 0 ] [ [[ 1 [[ 2 3 ]] ]] funny-length ] unit-test
|
2004-12-12 23:49:44 -05:00
|
|
|
[ 3 ] [ [ 1 2 3 ] funny-length ] unit-test
|
|
|
|
[ "hello" funny-length ] unit-test-fails
|
2004-12-18 23:18:32 -05:00
|
|
|
|
|
|
|
! Testing method sorting
|
|
|
|
GENERIC: sorting-test
|
|
|
|
M: fixnum sorting-test drop "fixnum" ;
|
|
|
|
M: object sorting-test drop "object" ;
|
|
|
|
[ "fixnum" ] [ 3 sorting-test ] unit-test
|
|
|
|
[ "object" ] [ f sorting-test ] unit-test
|
|
|
|
|
|
|
|
! Testing unions
|
|
|
|
UNION: funnies cons ratio complex ;
|
|
|
|
|
|
|
|
GENERIC: funny
|
|
|
|
M: funnies funny drop 2 ;
|
|
|
|
M: object funny drop 0 ;
|
|
|
|
|
|
|
|
[ 2 ] [ [ { } ] funny ] unit-test
|
|
|
|
[ 0 ] [ { } funny ] unit-test
|
|
|
|
|
|
|
|
PREDICATE: funnies very-funny number? ;
|
|
|
|
|
|
|
|
GENERIC: gooey
|
|
|
|
M: very-funny gooey sq ;
|
|
|
|
|
|
|
|
[ 1/4 ] [ 1/2 gooey ] unit-test
|
2004-12-23 02:14:40 -05:00
|
|
|
|
2004-12-23 16:37:16 -05:00
|
|
|
[ object ] [ object object class-and ] unit-test
|
|
|
|
[ fixnum ] [ fixnum object class-and ] unit-test
|
|
|
|
[ fixnum ] [ object fixnum class-and ] unit-test
|
|
|
|
[ fixnum ] [ fixnum fixnum class-and ] unit-test
|
|
|
|
[ fixnum ] [ fixnum integer class-and ] unit-test
|
|
|
|
[ fixnum ] [ integer fixnum class-and ] unit-test
|
2005-01-16 17:58:28 -05:00
|
|
|
[ null ] [ vector fixnum class-and ] unit-test
|
2004-12-23 16:37:16 -05:00
|
|
|
[ integer ] [ fixnum bignum class-or ] unit-test
|
|
|
|
[ integer ] [ fixnum integer class-or ] unit-test
|
|
|
|
[ rational ] [ ratio integer class-or ] unit-test
|
2004-12-23 18:46:21 -05:00
|
|
|
[ number ] [ number object class-and ] unit-test
|
|
|
|
[ number ] [ object number class-and ] unit-test
|
2004-12-23 23:55:22 -05:00
|
|
|
|
2004-12-27 22:58:43 -05:00
|
|
|
[ cons ] [ [ 1 2 ] class ] unit-test
|
2004-12-29 18:01:23 -05:00
|
|
|
|
2005-07-31 23:38:33 -04:00
|
|
|
[ t ] [ \ fixnum \ integer class< ] unit-test
|
|
|
|
[ t ] [ \ fixnum \ fixnum class< ] unit-test
|
|
|
|
[ f ] [ \ integer \ fixnum class< ] unit-test
|
|
|
|
[ t ] [ \ integer \ object class< ] unit-test
|
|
|
|
[ f ] [ \ integer \ null class< ] unit-test
|
|
|
|
[ t ] [ \ null \ object class< ] unit-test
|
|
|
|
[ t ] [ \ list \ general-list class< ] unit-test
|
|
|
|
[ t ] [ \ list \ object class< ] unit-test
|
|
|
|
[ t ] [ \ null \ list class< ] unit-test
|
|
|
|
|
2004-12-29 18:01:23 -05:00
|
|
|
[ t ] [ \ generic \ compound class< ] unit-test
|
|
|
|
[ f ] [ \ compound \ generic class< ] unit-test
|
2005-01-13 14:41:08 -05:00
|
|
|
|
2005-08-14 18:13:16 -04:00
|
|
|
[ f ] [ \ cons \ list class< ] unit-test
|
|
|
|
[ f ] [ \ list \ cons class< ] unit-test
|
|
|
|
|
2005-08-14 23:26:40 -04:00
|
|
|
[ f ] [ \ mirror \ slice class< ] unit-test
|
|
|
|
[ f ] [ \ slice \ mirror class< ] unit-test
|
|
|
|
|
2005-01-13 14:41:08 -05:00
|
|
|
DEFER: bah
|
|
|
|
FORGET: bah
|
|
|
|
UNION: bah fixnum alien ;
|
|
|
|
[ bah ] [ fixnum alien class-or ] unit-test
|
2005-08-03 18:47:32 -04:00
|
|
|
[ bah ] [ \ bah? "predicating" word-prop ] unit-test
|
2005-01-23 16:47:28 -05:00
|
|
|
|
|
|
|
DEFER: complement-test
|
|
|
|
FORGET: complement-test
|
|
|
|
GENERIC: complement-test
|
|
|
|
|
|
|
|
M: f complement-test drop "f" ;
|
|
|
|
M: general-t complement-test drop "general-t" ;
|
|
|
|
|
|
|
|
[ "general-t" ] [ 5 complement-test ] unit-test
|
|
|
|
[ "f" ] [ f complement-test ] unit-test
|
2005-03-01 18:55:25 -05:00
|
|
|
|
|
|
|
GENERIC: empty-method-test
|
|
|
|
M: object empty-method-test ;
|
|
|
|
TUPLE: for-arguments-sake ;
|
|
|
|
|
|
|
|
M: for-arguments-sake empty-method-test drop "Hi" ;
|
|
|
|
|
|
|
|
TUPLE: another-one ;
|
|
|
|
|
|
|
|
[ "Hi" ] [ <for-arguments-sake> empty-method-test empty-method-test ] unit-test
|
2005-03-08 22:54:59 -05:00
|
|
|
[ << another-one f >> ] [ <another-one> empty-method-test ] unit-test
|
2005-03-26 20:12:14 -05:00
|
|
|
|
|
|
|
! Test generic see and parsing
|
2005-09-01 02:15:29 -04:00
|
|
|
[ "IN: temporary\nSYMBOL: bah\nUNION: bah fixnum alien ;\n" ]
|
2005-06-19 18:53:58 -04:00
|
|
|
[ [ \ bah see ] string-out ] unit-test
|
2005-03-26 20:12:14 -05:00
|
|
|
|
|
|
|
! Weird bug
|
|
|
|
GENERIC: stack-underflow
|
|
|
|
M: object stack-underflow 2drop ;
|
|
|
|
M: word stack-underflow 2drop ;
|
2005-04-03 16:55:56 -04:00
|
|
|
|
|
|
|
GENERIC: testing
|
|
|
|
M: cons testing 2 ;
|
|
|
|
M: f testing 3 ;
|
|
|
|
M: sequence testing 4 ;
|
|
|
|
[ [ 1 2 ] 2 ] [ [ 1 2 ] testing ] unit-test
|
2005-04-10 18:58:30 -04:00
|
|
|
|
2005-04-21 00:49:19 -04:00
|
|
|
GENERIC: union-containment
|
|
|
|
M: integer union-containment drop 1 ;
|
|
|
|
M: number union-containment drop 2 ;
|
|
|
|
|
|
|
|
[ 1 ] [ 1 union-containment ] unit-test
|
|
|
|
[ 2 ] [ 1.0 union-containment ] unit-test
|
2005-04-25 19:54:21 -04:00
|
|
|
|
|
|
|
! Testing recovery from bad method definitions
|
|
|
|
"GENERIC: unhappy" eval
|
|
|
|
[ "M: vocabularies unhappy ;" eval ] unit-test-fails
|
2005-04-25 19:56:56 -04:00
|
|
|
[ ] [ "GENERIC: unhappy" eval ] unit-test
|
2005-05-14 17:18:45 -04:00
|
|
|
|
2005-08-22 15:33:18 -04:00
|
|
|
G: complex-combination [ over ] standard-combination ;
|
2005-05-14 17:18:45 -04:00
|
|
|
M: string complex-combination drop ;
|
|
|
|
M: object complex-combination nip ;
|
|
|
|
|
|
|
|
[ "hi" ] [ "hi" 3 complex-combination ] unit-test
|
|
|
|
[ "hi" ] [ 3 "hi" complex-combination ] unit-test
|
|
|
|
|
|
|
|
TUPLE: shit ;
|
|
|
|
|
|
|
|
M: shit complex-combination cons ;
|
|
|
|
[ [[ << shit f >> 5 ]] ] [ << shit f >> 5 complex-combination ] unit-test
|
2005-05-14 21:15:50 -04:00
|
|
|
|
|
|
|
[ t ] [ \ complex-combination generic? >boolean ] unit-test
|
|
|
|
|
|
|
|
! TUPLE: delegating-small-generic ;
|
|
|
|
! G: small-delegation [ over ] [ type ] ;
|
|
|
|
! M: shit small-delegation cons ;
|
|
|
|
!
|
|
|
|
! [ [[ << shit f >> 5 ]] ] [ << delegating-small-generic << shit f >> >> 5 small-delegation ] unit-test
|
|
|
|
|
|
|
|
GENERIC: big-generic-test
|
|
|
|
M: fixnum big-generic-test "fixnum" ;
|
|
|
|
M: bignum big-generic-test "bignum" ;
|
|
|
|
M: ratio big-generic-test "ratio" ;
|
|
|
|
M: string big-generic-test "string" ;
|
|
|
|
M: shit big-generic-test "shit" ;
|
|
|
|
|
|
|
|
TUPLE: delegating ;
|
|
|
|
|
|
|
|
[ << shit f >> "shit" ] [ << shit f >> big-generic-test ] unit-test
|
|
|
|
[ << shit f >> "shit" ] [ << delegating << shit f >> >> big-generic-test ] unit-test
|
2005-08-02 00:25:05 -04:00
|
|
|
|
|
|
|
[ t ] [ \ = simple-generic? ] unit-test
|
|
|
|
[ f ] [ \ each simple-generic? ] unit-test
|
|
|
|
[ f ] [ \ object simple-generic? ] unit-test
|
|
|
|
[ t ] [ \ + 2generic? ] unit-test
|