factor/library/test/init.factor

40 lines
1.1 KiB
Factor
Raw Normal View History

IN: temporary
2004-10-03 16:39:32 -04:00
USE: namespaces
USE: test
2004-12-24 02:52:02 -05:00
USE: kernel
USE: hashtables
USE: lists
2004-10-03 16:39:32 -04:00
[
[ f ] [ "-no-user-init" cli-arg ] unit-test
[ f ] [ "user-init" get ] unit-test
[ f ] [ "-user-init" cli-arg ] unit-test
[ t ] [ "user-init" get ] unit-test
[ "sdl.factor" ] [ "sdl.factor" cli-arg ] unit-test
] with-scope
2004-12-24 02:52:02 -05:00
: traverse-path ( name object -- object )
2005-09-24 15:21:17 -04:00
dup hashtable? [ hash ] [ 2drop f ] if ;
2004-12-24 02:52:02 -05:00
: (object-path) ( object list -- object )
[ uncons >r swap traverse-path r> (object-path) ] when* ;
: object-path ( list -- object )
#! An object path is a list of strings. Each string is a
#! variable name in the object namespace at that level.
#! Returns f if any of the objects are not set.
namespace swap (object-path) ;
[
5 [ "test" "object" "path" ] set-path
[ 5 ] [ [ "test" "object" "path" ] object-path ] unit-test
7 [ "test" "object" "pathe" ] set-path
[ 7 ] [ [ "test" "object" "pathe" ] object-path ] unit-test
9 [ "teste" "object" "pathe" ] set-path
[ 9 ] [ [ "teste" "object" "pathe" ] object-path ] unit-test
] with-scope