Get core unit tests to pass without number tower

release
U-SLAVA-FB3999113\Slava 2007-10-14 21:13:42 -04:00
parent 047c8fe708
commit 8b54248c50
17 changed files with 53 additions and 77 deletions

4
core/compiler/test/curry.factor Normal file → Executable file
View File

@ -7,8 +7,8 @@ IN: temporary
[ 3 ] [ [ 5 2 [ - ] 2curry call ] compile-1 ] unit-test
[ 3 ] [ 5 [ 2 [ - ] 2curry call ] compile-1 ] unit-test
[ 3 ] [ 5 2 [ [ - ] 2curry call ] compile-1 ] unit-test
[ 1/3 ] [ 5 2 [ [ - ] 2curry 1 swap call / ] compile-1 ] unit-test
[ 1/3 ] [ 5 2 [ [ - ] 2curry >r 1 r> call / ] compile-1 ] unit-test
[ 3 ] [ 5 2 [ [ - ] 2curry 9 swap call /i ] compile-1 ] unit-test
[ 3 ] [ 5 2 [ [ - ] 2curry >r 9 r> call /i ] compile-1 ] unit-test
[ -10 -20 ] [ 10 20 -1 [ [ * ] curry 2apply ] compile-1 ] unit-test

4
core/compiler/test/ifte.factor Normal file → Executable file
View File

@ -33,12 +33,12 @@ math.private combinators ;
: dead-code-rec
t [
C{ 3 2 }
3.2
] [
dead-code-rec
] if ;
[ C{ 3 2 } ] [ dead-code-rec ] unit-test
[ 3.2 ] [ dead-code-rec ] unit-test
: one-rec [ f one-rec ] [ "hi" ] if ;

View File

@ -1,10 +1,10 @@
IN: temporary
USING: arrays compiler kernel kernel.private math
math.private sequences strings tools.test words continuations
sequences.private hashtables.private byte-arrays
strings.private system random layouts
vectors.private sbufs.private strings.private slots.private
alien alien.c-types alien.syntax namespaces libc ;
math.constants math.private sequences strings tools.test words
continuations sequences.private hashtables.private byte-arrays
strings.private system random layouts vectors.private
sbufs.private strings.private slots.private alien alien.c-types
alien.syntax namespaces libc ;
! Make sure that intrinsic ops compile to correct code.
[ ] [ 1 [ drop ] compile-1 ] unit-test
@ -326,9 +326,13 @@ cell 8 = [
[ 500 <byte-array> length ] compile-1
] unit-test
[ C{ 1 2 } ] [ 1 2 [ <complex> ] compile-1 ] unit-test
[ 1 2 ] [
1 2 [ <complex> ] compile-1 dup real swap imaginary
] unit-test
[ 1/2 ] [ 1 2 [ <ratio> ] compile-1 ] unit-test
[ 1 2 ] [
1 2 [ <ratio> ] compile-1 dup numerator swap denominator
] unit-test
[ \ + ] [ \ + [ <wrapper> ] compile-1 ] unit-test
@ -411,8 +415,8 @@ cell 8 = [
[ t ] [ pi <double> [ { byte-array } declare *double ] compile-1 pi = ] unit-test
! Silly
[ t ] [ pi 4 <byte-array> [ [ { float byte-array } declare 0 set-alien-float ] compile-1 ] keep *float pi - abs 0.001 < ] unit-test
[ t ] [ pi <float> [ { byte-array } declare *float ] compile-1 pi - abs 0.001 < ] unit-test
[ t ] [ pi 4 <byte-array> [ [ { float byte-array } declare 0 set-alien-float ] compile-1 ] keep *float pi - -0.001 0.001 between? ] unit-test
[ t ] [ pi <float> [ { byte-array } declare *float ] compile-1 pi - -0.001 0.001 between? ] unit-test
[ t ] [ pi 8 <byte-array> [ [ { float byte-array } declare 0 set-alien-double ] compile-1 ] keep *double pi = ] unit-test

16
core/compiler/test/optimizer.factor Normal file → Executable file
View File

@ -208,10 +208,6 @@ M: slice foozul ;
[ -5 ] [ 5 [ -1 * ] compile-1 ] unit-test
[ -5 ] [ 5 [ -1 swap * ] compile-1 ] unit-test
[ 5 ] [ 5 [ 1 / ] compile-1 ] unit-test
[ 1/5 ] [ 5 [ 1 swap / ] compile-1 ] unit-test
[ -5 ] [ 5 [ -1 / ] compile-1 ] unit-test
[ 0 ] [ 5 [ 1 mod ] compile-1 ] unit-test
[ 0 ] [ 5 [ 1 rem ] compile-1 ] unit-test
@ -246,8 +242,6 @@ M: slice foozul ;
[ t ] [ 5 [ dup number= ] compile-1 ] unit-test
[ t ] [ \ vector [ \ vector = ] compile-1 ] unit-test
[ 3 ] [ 10/3 [ { ratio } declare 1 /i ] compile-1 ] unit-test
GENERIC: detect-number ( obj -- obj )
M: number detect-number ;
@ -275,7 +269,11 @@ USE: sorting.private
] unit-test
! Regression
[ 1 2 { real imaginary } ] [
C{ 1 2 }
[ { real imaginary } [ get-slots ] keep ] compile-1
TUPLE: silly-tuple a b ;
[ 1 2 { silly-tuple-a silly-tuple-b } ] [
T{ silly-tuple f 1 2 }
[
{ silly-tuple-a silly-tuple-b } [ get-slots ] keep
] compile-1
] unit-test

4
core/compiler/test/stack-trace.factor Normal file → Executable file
View File

@ -27,8 +27,8 @@ words splitting ;
[ { 1 "hi" } bleh ] catch drop \ + stack-trace-contains?
] unit-test
[ f t ] [
[ { C{ 1 2 } } bleh ] catch drop
[ t f ] [
[ { "hi" } bleh ] catch drop
\ + stack-trace-contains?
\ > stack-trace-contains?
] unit-test

39
core/compiler/test/templates.factor Normal file → Executable file
View File

@ -1,9 +1,9 @@
! Black box testing of templating optimization
USING: arrays compiler kernel kernel.private math
hashtables.private math.private math.ratios.private namespaces
sequences sequences.private tools.test namespaces.private
slots.private combinators.private byte-arrays alien layouts ;
hashtables.private math.private namespaces sequences
sequences.private tools.test namespaces.private slots.private
combinators.private byte-arrays alien layouts ;
IN: temporary
! Oops!
@ -37,41 +37,14 @@ unit-test
: foo ;
[ 4 4 ]
[ 1/2 [ tag [ foo ] keep ] compile-1 ]
[ 5 5 ]
[ 1.2 [ tag [ foo ] keep ] compile-1 ]
unit-test
[ 1 2 2 ]
[ 1/2 [ dup 1 slot swap 2 slot [ foo ] keep ] compile-1 ]
[ { 1 2 } [ dup 2 slot swap 3 slot [ foo ] keep ] compile-1 ]
unit-test
[ 41 5 4 ] [
5/4 4/5 [
dup ratio? [
over ratio? [
2dup 2>fraction >r * swap r> * swap
+ -rot denominator swap denominator
] [
2drop f f f
] if
] [
2drop f f f
] if
] compile-1
] unit-test
: jxyz
over bignum? [
dup ratio? [
[ >fraction ] 2apply swapd
>r 2array swap r> 2array swap
] when
] when ;
\ jxyz compile
[ { 1 2 } { 1 1 } ] [ 1 >bignum 1/2 jxyz ] unit-test
[ 3 ]
[
global [ 3 \ foo set ] bind

4
core/generic/generic-tests.factor Normal file → Executable file
View File

@ -34,7 +34,7 @@ M: f bool>str drop "false" ;
[ f ] [ f bool>str str>bool ] unit-test
! Testing unions
UNION: funnies quotation ratio complex ;
UNION: funnies quotation float complex ;
GENERIC: funny ( x -- y )
M: funnies funny drop 2 ;
@ -48,7 +48,7 @@ PREDICATE: funnies very-funny number? ;
GENERIC: gooey ( x -- y )
M: very-funny gooey sq ;
[ 1/4 ] [ 1/2 gooey ] unit-test
[ 0.25 ] [ 0.5 gooey ] unit-test
DEFER: complement-test
FORGET: complement-test

2
core/generic/generic.factor Normal file → Executable file
View File

@ -21,7 +21,7 @@ M: object perform-combination
#! method combination, and a method on the generic, and the
#! method combination is forgotten first, then forgetting
#! the method will throw an error. We don't want that.
nip [ "Invalid method combination" throw ] curry ;
nip [ "Invalid method combination" throw ] curry [ ] like ;
: make-generic ( word -- )
dup

2
core/growable/growable-tests.factor Normal file → Executable file
View File

@ -22,5 +22,5 @@ unit-test-fails
[ ] [
10 V{ } [ set-length ] keep
1/2 swap set-length
0.5 swap set-length
] unit-test

6
core/hashtables/hashtables-tests.factor Normal file → Executable file
View File

@ -34,11 +34,11 @@ unit-test
16 <hashtable> "testhash" set
t C{ 2 3 } "testhash" get set-at
t { 2 3 } "testhash" get set-at
f 100000000000000000000000000 "testhash" get set-at
{ } { [ { } ] } "testhash" get set-at
[ t ] [ C{ 2 3 } "testhash" get at ] unit-test
[ t ] [ { 2 3 } "testhash" get at ] unit-test
[ f ] [ 100000000000000000000000000 "testhash" get at* drop ] unit-test
[ { } ] [ { [ { } ] } clone "testhash" get at* drop ] unit-test
@ -122,7 +122,7 @@ H{ } "x" set
100 [ drop "x" get clear-assoc ] each
! Crash discovered by erg
[ t ] [ 3/4 <hashtable> dup clone = ] unit-test
[ t ] [ 0.75 <hashtable> dup clone = ] unit-test
! Another crash discovered by erg
[ ] [

4
core/inference/inference-tests.factor Normal file → Executable file
View File

@ -230,8 +230,8 @@ DEFER: do-crap*
! Error reporting is wrong
MATH: xyz
M: fixnum xyz 2array ;
M: ratio xyz
[ >fraction ] 2apply swapd >r 2array swap r> 2array swap ;
M: float xyz
[ 3 ] 2apply swapd >r 2array swap r> 2array swap ;
[ t ] [ [ [ xyz ] infer short-effect ] catch inference-error? ] unit-test

View File

@ -98,7 +98,6 @@ unit-test
[ 16 ] [ 13 next-power-of-2 ] unit-test
[ 16 ] [ 16 next-power-of-2 ] unit-test
[ 268435456 ] [ -268435456 >fixnum -1 / ] unit-test
[ 268435456 ] [ -268435456 >fixnum -1 /i ] unit-test
[ 268435456 0 ] [ -268435456 >fixnum -1 /mod ] unit-test
[ 0 ] [ -1 -268435456 >fixnum /i ] unit-test

View File

@ -1,5 +1,5 @@
USING: math.intervals kernel sequences words math arrays
prettyprint tools.test random ;
prettyprint tools.test random vocabs ;
IN: temporary
[ T{ interval f { 1 t } { 2 t } } ] [ 1 2 [a,b] ] unit-test
@ -88,9 +88,11 @@ IN: temporary
[ f ] [ -1 1 (a,b) 0 1 (a,b) interval/ ] unit-test
[ t ] [
-1 1 (a,b) 0.5 1 (a,b) interval/ -2 2 (a,b) =
] unit-test
"math.ratios.private" vocab [
[ t ] [
-1 1 (a,b) 0.5 1 (a,b) interval/ -2 2 (a,b) =
] unit-test
] when
[ t ] [ 0 5 [a,b] 5 interval<= ] unit-test

0
core/parser/parser-docs.factor Normal file → Executable file
View File

10
core/sequences/sequences-tests.factor Normal file → Executable file
View File

@ -43,9 +43,9 @@ IN: temporary
[ f ] [ CHAR: a 0 "tuvwxyz" >vector index* ] unit-test
[ f ] [ [ "Hello" { } 4/3 ] [ string? ] all? ] unit-test
[ f ] [ [ "Hello" { } 0.75 ] [ string? ] all? ] unit-test
[ t ] [ [ ] [ ] all? ] unit-test
[ t ] [ [ "hi" t 1/2 ] [ ] all? ] unit-test
[ t ] [ [ "hi" t 0.5 ] [ ] all? ] unit-test
[ [ 1 2 3 ] ] [ [ 1 4 2 5 3 6 ] [ 4 < ] subset ] unit-test
[ { 4 2 6 } ] [ { 1 4 2 5 3 6 } [ 2 mod 0 = ] subset ] unit-test
@ -68,8 +68,8 @@ unit-test
[ f ] [ [ { } { } "Hello" ] all-equal? ] unit-test
[ f ] [ [ { 2 } { } { } ] all-equal? ] unit-test
[ t ] [ [ ] all-equal? ] unit-test
[ t ] [ [ 1/2 ] all-equal? ] unit-test
[ t ] [ [ 1.0 10/10 1 ] all-equal? ] unit-test
[ t ] [ [ 1234 ] all-equal? ] unit-test
[ t ] [ [ 1.0 1 1 ] all-equal? ] unit-test
[ t ] [ { 1 2 3 4 } [ < ] monotonic? ] unit-test
[ f ] [ { 1 2 3 4 } [ > ] monotonic? ] unit-test
[ [ 2 3 4 ] ] [ [ 1 2 3 ] 1 [ + ] curry map ] unit-test
@ -190,7 +190,7 @@ unit-test
"cache-test" get
] unit-test
[ 1 ] [ 1/2 { 1 2 3 } nth ] unit-test
[ 1 ] [ 0.5 { 1 2 3 } nth ] unit-test
! Pathological case
[ "ihbye" ] [ "hi" <reversed> "bye" append ] unit-test

View File

@ -8,6 +8,5 @@ IN: temporary
[ ] [ [ "Errors, errors" throw ] in-thread ] unit-test
yield
[ ] [ 1 2 / sleep ] unit-test
[ ] [ 0.3 sleep ] unit-test
[ "hey" sleep ] unit-test-fails

View File

@ -84,6 +84,7 @@ unit-test
[ 1 ] [ 1/2 0.5 + ] unit-test
[ 1/268435456 ] [ -1 -268435456 >fixnum / ] unit-test
[ 268435456 ] [ -268435456 >fixnum -1 / ] unit-test
[ 5 ]
[ "10/2" string>number ]