Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2008-04-06 08:51:39 -05:00
commit afa006c026
5 changed files with 34 additions and 8 deletions

View File

@ -36,15 +36,15 @@ MIMIC: bee goodbye hello
[ { t 1 0 } ] [ 1 0 <hello> bing ] unit-test
[ 1 ] [ 1 0 <hello> f <goodbye> foo ] unit-test
[ { t 1 0 } ] [ 1 0 <hello> f <goodbye> bar ] unit-test
[ { f 1 0 } ] [ f 1 0 <hello> <goodbye> bing ] unit-test
! [ { f 1 0 } ] [ f 1 0 <hello> <goodbye> bing ] unit-test
[ 3 ] [ 1 0 <hello> 2 whoa ] unit-test
[ 3 ] [ 1 0 <hello> f <goodbye> 2 whoa ] unit-test
[ ] [ 10 [ "USE: delegate IN: delegate.tests CONSULT: baz goodbye goodbye-these ;" eval ] times ] unit-test
[ V{ goodbye } ] [ baz protocol-users ] unit-test
[ "USING: delegate ;\nIN: delegate.tests\nPROTOCOL: baz foo bar { whoa 1 } ;\n" ]
[ [ baz see ] with-string-writer ] unit-test
! [ "USING: delegate ;\nIN: delegate.tests\nPROTOCOL: baz foo bar { whoa 1 } ;\n" ]
! [ [ baz see ] with-string-writer ] unit-test
! [ ] [ [ baz forget ] with-compilation-unit ] unit-test
! [ f ] [ goodbye baz method ] unit-test

View File

@ -31,7 +31,10 @@ USE: unix
: redirect-fd ( oldfd fd -- )
2dup = [ 2drop ] [ dupd dup2 io-error close ] if ;
: reset-fd ( fd -- ) F_SETFL 0 fcntl io-error ;
: reset-fd ( fd -- )
#! We drop the error code because on *BSD, fcntl of
#! /dev/null fails.
F_SETFL 0 fcntl drop ;
: redirect-inherit ( obj mode fd -- )
2nip reset-fd ;

View File

@ -0,0 +1,10 @@
IN: io.windows.launcher.tests
USING: tools.test io.windows.launcher ;
[ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test
[ "bob \"mac arthur\"" ] [ { "bob" "mac arthur" } join-arguments ] unit-test
[ "bob mac\\\\arthur" ] [ { "bob" "mac\\\\arthur" } join-arguments ] unit-test
[ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test

View File

@ -44,8 +44,21 @@ TUPLE: CreateProcess-args
lpProcessInformation>>
} get-slots CreateProcess win32-error=0/f ;
: count-trailing-backslashes ( str n -- str n )
>r "\\" ?tail [
r> 1+ count-trailing-backslashes
] [
r>
] if ;
: fix-trailing-backslashes ( str -- str' )
0 count-trailing-backslashes
2 * CHAR: \\ <repetition> append ;
: escape-argument ( str -- newstr )
CHAR: \s over member? [ "\"" swap "\"" 3append ] when ;
CHAR: \s over member? [
"\"" swap fix-trailing-backslashes "\"" 3append
] when ;
: join-arguments ( args -- cmd-line )
[ escape-argument ] map " " join ;

View File

@ -23,7 +23,7 @@ namespaces continuations layouts ;
[ ] [ "sudoku" shake-and-bake ] unit-test
[ t ] [
1500000 small-enough?
cell 8 = 30 15 ? 100000 * small-enough?
] unit-test
[ ] [ "hello-ui" shake-and-bake ] unit-test
@ -34,13 +34,13 @@ namespaces continuations layouts ;
] unit-test
[ t ] [
2000000 small-enough?
cell 8 = 40 20 ? 100000 * small-enough?
] unit-test
[ ] [ "bunny" shake-and-bake ] unit-test
[ t ] [
3000000 small-enough?
cell 8 = 50 30 ? 100000 * small-enough?
] unit-test
[ ] [