Skip to content

Commit

Permalink
factor: second stab at [ ] [ ] unit-test -> { } [ ] unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
erg committed Jul 3, 2015
1 parent 9e8ceb8 commit 892c62e
Show file tree
Hide file tree
Showing 579 changed files with 7,256 additions and 7,256 deletions.
14 changes: 7 additions & 7 deletions basis/alien/parser/parser-tests.factor
Expand Up @@ -38,32 +38,32 @@ CONSTANT: eleven 11

FUNCTION: void* alien-parser-function-effect-test ( int *arg1, float arg2 ) ;

[ ( arg1 arg2 -- void* ) ] [
{ ( arg1 arg2 -- void* ) } [
\ alien-parser-function-effect-test "declared-effect" word-prop
] unit-test

[ t ] [ \ alien-parser-function-effect-test inline? ] unit-test
{ t } [ \ alien-parser-function-effect-test inline? ] unit-test

FUNCTION-ALIAS: (alien-parser-function-effect-test) void* alien-parser-function-effect-test ( int *arg1, float arg2 ) ;

[ ( arg1 arg2 -- void* ) ] [
{ ( arg1 arg2 -- void* ) } [
\ (alien-parser-function-effect-test) "declared-effect" word-prop
] unit-test

[ t ] [ \ (alien-parser-function-effect-test) inline? ] unit-test
{ t } [ \ (alien-parser-function-effect-test) inline? ] unit-test

CALLBACK: void* alien-parser-callback-effect-test ( int *arg1 float arg2 ) ;

[ ( arg1 arg2 -- void* ) ] [
{ ( arg1 arg2 -- void* ) } [
\ alien-parser-callback-effect-test "callback-effect" word-prop
] unit-test

[ t ] [ \ alien-parser-callback-effect-test inline? ] unit-test
{ t } [ \ alien-parser-callback-effect-test inline? ] unit-test

! Reported by mnestic
TYPEDEF: int alien-parser-test-int ! reasonably unique name...

[ "OK!" ] [
{ "OK!" } [
[
"USE: specialized-arrays SPECIALIZED-ARRAY: alien-parser-test-int" eval( -- )
! after restart, we end up here
Expand Down
30 changes: 15 additions & 15 deletions basis/alien/prettyprint/prettyprint-tests.factor
Expand Up @@ -7,67 +7,67 @@ CONSTANT: FOO 10

FUNCTION: int function_test ( float x, int[4][FOO] y, char* z, ushort *w ) ;

[ "USING: alien.c-types alien.syntax ;
{ "USING: alien.c-types alien.syntax ;
IN: alien.prettyprint.tests
FUNCTION: int function_test
( float x, int[4][FOO] y, char* z, ushort* w ) ; inline
" ] [
" } [
[ \ function_test see ] with-string-writer
] unit-test

FUNCTION-ALIAS: function-test int function_test
( float x, int[4][FOO] y, char* z, ushort *w ) ;

[ "USING: alien.c-types alien.syntax ;
{ "USING: alien.c-types alien.syntax ;
IN: alien.prettyprint.tests
FUNCTION-ALIAS: function-test int function_test
( float x, int[4][FOO] y, char* z, ushort* w ) ; inline
" ] [
" } [
[ \ function-test see ] with-string-writer
] unit-test

TYPEDEF: c-string[ascii] string-typedef
TYPEDEF: char[1][2][3] array-typedef

[ "USING: alien.c-types alien.syntax ;
{ "USING: alien.c-types alien.syntax ;
IN: alien.prettyprint.tests
TYPEDEF: c-string[ascii] string-typedef
" ] [
" } [
[ \ string-typedef see ] with-string-writer
] unit-test

[ "USING: alien.c-types alien.syntax ;
{ "USING: alien.c-types alien.syntax ;
IN: alien.prettyprint.tests
TYPEDEF: char[1][2][3] array-typedef
" ] [
" } [
[ \ array-typedef see ] with-string-writer
] unit-test

C-TYPE: opaque-c-type

[ "USING: alien.syntax ;
{ "USING: alien.syntax ;
IN: alien.prettyprint.tests
C-TYPE: opaque-c-type
" ] [
" } [
[ \ opaque-c-type see ] with-string-writer
] unit-test

TYPEDEF: pointer: int pint

[ "USING: alien.c-types alien.syntax ;
{ "USING: alien.c-types alien.syntax ;
IN: alien.prettyprint.tests
TYPEDEF: int* pint
" ] [
" } [
[ \ pint see ] with-string-writer
] unit-test

[ "pointer: int" ] [ pointer: int unparse ] unit-test
{ "pointer: int" } [ pointer: int unparse ] unit-test

CALLBACK: void callback-test ( int x, float[4] y ) ;

[ "USING: alien.c-types alien.syntax ;
{ "USING: alien.c-types alien.syntax ;
IN: alien.prettyprint.tests
CALLBACK: void callback-test ( int x, float[4] y ) ;
" ] [
" } [
[ \ callback-test see ] with-string-writer
] unit-test
16 changes: 8 additions & 8 deletions basis/bootstrap/image/image-tests.factor
Expand Up @@ -2,18 +2,18 @@ USING: bootstrap.image bootstrap.image.private tools.test
kernel math ;
IN: bootstrap.image.tests

[ f ] [ { 1 2 3 } [ 1 2 3 ] eql? ] unit-test
{ f } [ { 1 2 3 } [ 1 2 3 ] eql? ] unit-test

[ t ] [ [ 1 2 3 ] [ 1 2 3 ] eql? ] unit-test
{ t } [ [ 1 2 3 ] [ 1 2 3 ] eql? ] unit-test

[ f ] [ [ 2drop 0 ] [ 2drop 0.0 ] eql? ] unit-test
{ f } [ [ 2drop 0 ] [ 2drop 0.0 ] eql? ] unit-test

[ t ] [ [ 2drop 0 ] [ 2drop 0 ] eql? ] unit-test
{ t } [ [ 2drop 0 ] [ 2drop 0 ] eql? ] unit-test

[ f ] [ \ + [ 2drop 0 ] eql? ] unit-test
{ f } [ \ + [ 2drop 0 ] eql? ] unit-test

[ f ] [ 3 [ 0 1 2 ] eql? ] unit-test
{ f } [ 3 [ 0 1 2 ] eql? ] unit-test

[ f ] [ 3 3.0 eql? ] unit-test
{ f } [ 3 3.0 eql? ] unit-test

[ t ] [ 4.0 4.0 eql? ] unit-test
{ t } [ 4.0 4.0 eql? ] unit-test
4 changes: 2 additions & 2 deletions basis/byte-arrays/hex/hex-tests.factor
Expand Up @@ -3,8 +3,8 @@
USING: tools.test byte-arrays.hex eval ;
IN: byte-arrays.hex.tests

[ B{ 16 0 8 0 } ] [ HEX{ 10 00 08 00 } ] unit-test
[ B{ 255 255 15 255 255 255 } ] [ HEX{ ffff 0fff ffff } ] unit-test
{ B{ 16 0 8 0 } } [ HEX{ 10 00 08 00 } ] unit-test
{ B{ 255 255 15 255 255 255 } } [ HEX{ ffff 0fff ffff } ] unit-test

[ "HEX{ ffff fff ffff }" parse-string ] must-fail
[ "HEX{ 10 00 08 0 }" parse-string ] must-fail
Expand Down
52 changes: 26 additions & 26 deletions basis/calendar/format/format-tests.factor
Expand Up @@ -2,61 +2,61 @@ USING: calendar.format calendar kernel math tools.test
io.streams.string accessors io math.order sequences ;
IN: calendar.format.tests

[ 0 ] [
{ 0 } [
"Z" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours
] unit-test

[ 1 ] [
{ 1 } [
"+01" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours
] unit-test

[ -1 ] [
{ -1 } [
"-01" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours
] unit-test

[ -1-1/2 ] [
{ -1-1/2 } [
"-01:30" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours
] unit-test

[ 1+1/2 ] [
{ 1+1/2 } [
"+01:30" [ read1 read-rfc3339-gmt-offset ] with-string-reader duration>hours
] unit-test

[ ] [ now timestamp>rfc3339 drop ] unit-test
[ ] [ now timestamp>rfc822 drop ] unit-test
{ } [ now timestamp>rfc3339 drop ] unit-test
{ } [ now timestamp>rfc822 drop ] unit-test

[ 8/1000 -4 ] [
{ 8/1000 -4 } [
"2008-04-19T04:56:00.008-04:00" rfc3339>timestamp
[ second>> ] [ gmt-offset>> hour>> ] bi
] unit-test

[ T{ duration f 0 0 0 0 0 0 } ] [
{ T{ duration f 0 0 0 0 0 0 } } [
"GMT" parse-rfc822-gmt-offset
] unit-test

[ T{ duration f 0 0 0 -5 0 0 } ] [
{ T{ duration f 0 0 0 -5 0 0 } } [
"-0500" parse-rfc822-gmt-offset
] unit-test

[ T{ timestamp f 2008 4 22 14 36 12 T{ duration f 0 0 0 0 0 0 } } ] [
{ T{ timestamp f 2008 4 22 14 36 12 T{ duration f 0 0 0 0 0 0 } } } [
"Tue, 22 Apr 2008 14:36:12 GMT" rfc822>timestamp
] unit-test

[ t ] [ now dup timestamp>rfc822 rfc822>timestamp time- 1 seconds before? ] unit-test
{ t } [ now dup timestamp>rfc822 rfc822>timestamp time- 1 seconds before? ] unit-test

[ t ] [ now dup timestamp>cookie-string cookie-string>timestamp time- 1 seconds before? ] unit-test
{ t } [ now dup timestamp>cookie-string cookie-string>timestamp time- 1 seconds before? ] unit-test

[ "Sun, 4 May 2008 07:00:00" ] [
{ "Sun, 4 May 2008 07:00:00" } [
"Sun May 04 07:00:00 2008 GMT" cookie-string>timestamp
timestamp>string
] unit-test

[ "20080504070000" ] [
{ "20080504070000" } [
"Sun May 04 07:00:00 2008 GMT" cookie-string>timestamp
timestamp>mdtm
] unit-test

[
{
T{ timestamp f
2008
5
Expand All @@ -66,9 +66,9 @@ IN: calendar.format.tests
42+2469/20000
T{ duration f 0 0 0 -5 0 0 }
}
] [ "2008-05-26T00:37:42.12345-05:00" rfc3339>timestamp ] unit-test
} [ "2008-05-26T00:37:42.12345-05:00" rfc3339>timestamp ] unit-test

[
{
T{ timestamp
{ year 2008 }
{ month 10 }
Expand All @@ -78,13 +78,13 @@ IN: calendar.format.tests
{ second 59 }
{ gmt-offset T{ duration f 0 0 0 0 0 0 } }
}
] [ "Thursday, 02-Oct-2008 23:59:59 GMT" cookie-string>timestamp ] unit-test
} [ "Thursday, 02-Oct-2008 23:59:59 GMT" cookie-string>timestamp ] unit-test


[ ]
{ }
[ { 2008 2009 } [ year. ] each ] unit-test

[
{
T{ timestamp
{ year 2013 }
{ month 4 }
Expand All @@ -93,11 +93,11 @@ IN: calendar.format.tests
{ minute 50 }
{ second 24 }
}
] [ "2013-04-23T13:50:24" rfc3339>timestamp ] unit-test
} [ "2013-04-23T13:50:24" rfc3339>timestamp ] unit-test

{ "2001-12-14T21:59:43.100000-05:00" } [ "2001-12-14T21:59:43.1-05:00" rfc3339>timestamp timestamp>rfc3339 ] unit-test

[
{
T{ timestamp
{ year 2001 }
{ month 12 }
Expand All @@ -106,9 +106,9 @@ IN: calendar.format.tests
{ minute 59 }
{ second 43+1/10 }
}
] [ "2001-12-15 02:59:43.1Z" rfc3339>timestamp ] unit-test
} [ "2001-12-15 02:59:43.1Z" rfc3339>timestamp ] unit-test

[
{
T{ timestamp
{ year 2001 }
{ month 12 }
Expand All @@ -117,4 +117,4 @@ IN: calendar.format.tests
{ minute 59 }
{ second 43+1/10 }
}
] [ "2001-12-15 02:59:43.1Z" rfc3339>timestamp ] unit-test
} [ "2001-12-15 02:59:43.1Z" rfc3339>timestamp ] unit-test
6 changes: 3 additions & 3 deletions basis/calendar/format/macros/macros-tests.factor
@@ -1,9 +1,9 @@
USING: tools.test kernel accessors ;
IN: calendar.format.macros

[ 2 ] [ { [ 2 ] } attempt-all-quots ] unit-test
{ 2 } [ { [ 2 ] } attempt-all-quots ] unit-test

[ 2 ] [ { [ 1 throw ] [ 2 ] } attempt-all-quots ] unit-test
{ 2 } [ { [ 1 throw ] [ 2 ] } attempt-all-quots ] unit-test

[ { [ 1 throw ] } attempt-all-quots ] [ 1 = ] must-fail-with

Expand All @@ -12,4 +12,4 @@ IN: calendar.format.macros

\ compiled-test-1 def>> must-infer

[ 2 ] [ compiled-test-1 ] unit-test
{ 2 } [ compiled-test-1 ] unit-test
4 changes: 2 additions & 2 deletions basis/checksums/adler-32/adler-32-tests.factor
@@ -1,5 +1,5 @@
USING: checksums.adler-32 checksums strings tools.test ;
IN: checksums.adler-32.tests

[ 300286872 ] [ "Wikipedia" adler-32 checksum-bytes ] unit-test
[ 2679885283 ] [ 10000 CHAR: a <string> adler-32 checksum-bytes ] unit-test
{ 300286872 } [ "Wikipedia" adler-32 checksum-bytes ] unit-test
{ 2679885283 } [ 10000 CHAR: a <string> adler-32 checksum-bytes ] unit-test
56 changes: 28 additions & 28 deletions basis/checksums/fnv1/fnv1-tests.factor
Expand Up @@ -3,39 +3,39 @@ IN: checksums.fnv1.tests

! A few test vectors taken from http://www.isthe.com/chongo/src/fnv/test_fnv.c

[ 0x811c9dc5 ] [ "" fnv1-32 checksum-bytes ] unit-test
[ 0x811c9dc5 ] [ "" fnv1a-32 checksum-bytes ] unit-test
[ 0xcbf29ce484222325 ] [ "" fnv1-64 checksum-bytes ] unit-test
[ 0xcbf29ce484222325 ] [ "" fnv1a-64 checksum-bytes ] unit-test
{ 0x811c9dc5 } [ "" fnv1-32 checksum-bytes ] unit-test
{ 0x811c9dc5 } [ "" fnv1a-32 checksum-bytes ] unit-test
{ 0xcbf29ce484222325 } [ "" fnv1-64 checksum-bytes ] unit-test
{ 0xcbf29ce484222325 } [ "" fnv1a-64 checksum-bytes ] unit-test

[ 0x050c5d7e ] [ "a" fnv1-32 checksum-bytes ] unit-test
[ 0xe40c292c ] [ "a" fnv1a-32 checksum-bytes ] unit-test
[ 0xaf63bd4c8601b7be ] [ "a" fnv1-64 checksum-bytes ] unit-test
[ 0xaf63dc4c8601ec8c ] [ "a" fnv1a-64 checksum-bytes ] unit-test
{ 0x050c5d7e } [ "a" fnv1-32 checksum-bytes ] unit-test
{ 0xe40c292c } [ "a" fnv1a-32 checksum-bytes ] unit-test
{ 0xaf63bd4c8601b7be } [ "a" fnv1-64 checksum-bytes ] unit-test
{ 0xaf63dc4c8601ec8c } [ "a" fnv1a-64 checksum-bytes ] unit-test

[ 0x050c5d7d ] [ "b" fnv1-32 checksum-bytes ] unit-test
[ 0xe70c2de5 ] [ "b" fnv1a-32 checksum-bytes ] unit-test
[ 0xaf63bd4c8601b7bd ] [ "b" fnv1-64 checksum-bytes ] unit-test
[ 0xaf63df4c8601f1a5 ] [ "b" fnv1a-64 checksum-bytes ] unit-test
{ 0x050c5d7d } [ "b" fnv1-32 checksum-bytes ] unit-test
{ 0xe70c2de5 } [ "b" fnv1a-32 checksum-bytes ] unit-test
{ 0xaf63bd4c8601b7bd } [ "b" fnv1-64 checksum-bytes ] unit-test
{ 0xaf63df4c8601f1a5 } [ "b" fnv1a-64 checksum-bytes ] unit-test

[ 0x31f0b262 ] [ "foobar" fnv1-32 checksum-bytes ] unit-test
[ 0xbf9cf968 ] [ "foobar" fnv1a-32 checksum-bytes ] unit-test
[ 0x340d8765a4dda9c2 ] [ "foobar" fnv1-64 checksum-bytes ] unit-test
[ 0x85944171f73967e8 ] [ "foobar" fnv1a-64 checksum-bytes ] unit-test
{ 0x31f0b262 } [ "foobar" fnv1-32 checksum-bytes ] unit-test
{ 0xbf9cf968 } [ "foobar" fnv1a-32 checksum-bytes ] unit-test
{ 0x340d8765a4dda9c2 } [ "foobar" fnv1-64 checksum-bytes ] unit-test
{ 0x85944171f73967e8 } [ "foobar" fnv1a-64 checksum-bytes ] unit-test

! I couldn't find any test vectors for 128, 256, 512, or 1024 versions of FNV1 hashes.
! So, just to check that your maths works the same as my maths, here's a few samples computed on my laptop.
! So they may be right or wrong, but either way, them failing is cause for concern somewhere...

[ 3897470310 ] [ "Hello, world!" fnv1-32 checksum-bytes ] unit-test
[ 3985698964 ] [ "Hello, world!" fnv1a-32 checksum-bytes ] unit-test
[ 7285062107457560934 ] [ "Hello, world!" fnv1-64 checksum-bytes ] unit-test
[ 4094109891673226228 ] [ "Hello, world!" fnv1a-64 checksum-bytes ] unit-test
[ 281580511747867177735318995358496831158 ] [ "Hello, world!" fnv1-128 checksum-bytes ] unit-test
[ 303126633380056630368940439484674414572 ] [ "Hello, world!" fnv1a-128 checksum-bytes ] unit-test
[ 104295939182568077644846978685759236849634734810631820736486253421270219742822 ] [ "Hello, world!" fnv1-256 checksum-bytes ] unit-test
[ 9495445728692795332446740615588417456874414534608540692485745371050033741380 ] [ "Hello, world!" fnv1a-256 checksum-bytes ] unit-test
[ 3577308325596719252093726711895047340166329831006673109476042102918876665433235513101496175651226507162015890004121912850661561110326527625579463564626958 ] [ "Hello, world!" fnv1-512 checksum-bytes ] unit-test
[ 3577308325596719162840652138474318309664256091923081930027929425092517582111473988451078821416039944023089883981242376700859598441397004715365740906054208 ] [ "Hello, world!" fnv1a-512 checksum-bytes ] unit-test
[ 52692754922840008511959888105094366091401994235075816792707658326855733053286986999719949898492311786648795846192078757217437117165934438286601534984230194601365788544275827382423366672856972872132009691615382991251544423521887009322211754219117294019951276080952271766377222613325328591830596794468813260226 ] [ "Hello, world!" fnv1-1024 checksum-bytes ] unit-test
[ 52692754922840008511959888105094366091401994235075816792707658326855804920671100511873485674717442819607149127986090276849364757610838433887624184145636764448608707614141109841761957788887305179569455221243999538336208648824673027111352338809582124430199044921035232455717748500524777795242051756321605065326 ] [ "Hello, world!" fnv1a-1024 checksum-bytes ] unit-test
{ 3897470310 } [ "Hello, world!" fnv1-32 checksum-bytes ] unit-test
{ 3985698964 } [ "Hello, world!" fnv1a-32 checksum-bytes ] unit-test
{ 7285062107457560934 } [ "Hello, world!" fnv1-64 checksum-bytes ] unit-test
{ 4094109891673226228 } [ "Hello, world!" fnv1a-64 checksum-bytes ] unit-test
{ 281580511747867177735318995358496831158 } [ "Hello, world!" fnv1-128 checksum-bytes ] unit-test
{ 303126633380056630368940439484674414572 } [ "Hello, world!" fnv1a-128 checksum-bytes ] unit-test
{ 104295939182568077644846978685759236849634734810631820736486253421270219742822 } [ "Hello, world!" fnv1-256 checksum-bytes ] unit-test
{ 9495445728692795332446740615588417456874414534608540692485745371050033741380 } [ "Hello, world!" fnv1a-256 checksum-bytes ] unit-test
{ 3577308325596719252093726711895047340166329831006673109476042102918876665433235513101496175651226507162015890004121912850661561110326527625579463564626958 } [ "Hello, world!" fnv1-512 checksum-bytes ] unit-test
{ 3577308325596719162840652138474318309664256091923081930027929425092517582111473988451078821416039944023089883981242376700859598441397004715365740906054208 } [ "Hello, world!" fnv1a-512 checksum-bytes ] unit-test
{ 52692754922840008511959888105094366091401994235075816792707658326855733053286986999719949898492311786648795846192078757217437117165934438286601534984230194601365788544275827382423366672856972872132009691615382991251544423521887009322211754219117294019951276080952271766377222613325328591830596794468813260226 } [ "Hello, world!" fnv1-1024 checksum-bytes ] unit-test
{ 52692754922840008511959888105094366091401994235075816792707658326855804920671100511873485674717442819607149127986090276849364757610838433887624184145636764448608707614141109841761957788887305179569455221243999538336208648824673027111352338809582124430199044921035232455717748500524777795242051756321605065326 } [ "Hello, world!" fnv1a-1024 checksum-bytes ] unit-test

0 comments on commit 892c62e

Please sign in to comment.