2009-05-16 01:29:21 -04:00
|
|
|
USING: generalizations accessors arrays compiler kernel kernel.private
|
|
|
|
math hashtables.private math.private namespaces sequences tools.test
|
|
|
|
namespaces.private slots.private sequences.private byte-arrays alien
|
2008-10-19 04:51:01 -04:00
|
|
|
alien.accessors layouts words definitions compiler.units io
|
2009-08-02 04:49:54 -04:00
|
|
|
combinators vectors grouping make alien.c-types combinators.short-circuit
|
2009-09-23 03:47:56 -04:00
|
|
|
math.order math.libm math.parser alien.c-types ;
|
2009-09-16 10:20:47 -04:00
|
|
|
FROM: math => float ;
|
2009-05-16 01:29:21 -04:00
|
|
|
QUALIFIED: namespaces.private
|
2009-04-26 01:51:47 -04:00
|
|
|
IN: compiler.tests.codegen
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-10-19 04:51:01 -04:00
|
|
|
! Originally, this file did black box testing of templating
|
|
|
|
! optimization. We now have a different codegen, but the tests
|
|
|
|
! in here are still useful.
|
|
|
|
|
2007-09-20 18:09:08 -04:00
|
|
|
! Oops!
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 5000 ] [ [ 5000 ] compile-call ] unit-test
|
|
|
|
[ "hi" ] [ [ "hi" ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 1 2 3 4 ] [ [ 1 2 3 4 ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 1 1 ] [ 1 [ dup ] compile-call ] unit-test
|
|
|
|
[ 0 ] [ 3 [ tag ] compile-call ] unit-test
|
|
|
|
[ 0 3 ] [ 3 [ [ tag ] keep ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 2 3 ] [ 3 [ 2 swap ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 2 1 3 4 ] [ 1 2 [ swap 3 4 ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 2 3 4 ] [ 3 [ 2 swap 4 ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-04-30 01:38:55 -04:00
|
|
|
[ { 1 2 3 } { 1 4 3 } 2 2 ]
|
2007-12-24 21:54:45 -05:00
|
|
|
[ { 1 2 3 } { 1 4 3 } [ over tag over tag ] compile-call ]
|
2007-09-20 18:09:08 -04:00
|
|
|
unit-test
|
|
|
|
|
|
|
|
! Test literals in either side of a shuffle
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 4 1 ] [ 1 [ [ 3 fixnum+ ] keep ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 2 ] [ 1 2 [ swap fixnum/i ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-06-08 16:32:55 -04:00
|
|
|
: foo ( -- ) ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-04-28 22:43:30 -04:00
|
|
|
[ 3 3 ]
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 1.2 [ tag [ foo ] keep ] compile-call ]
|
2007-09-20 18:09:08 -04:00
|
|
|
unit-test
|
|
|
|
|
|
|
|
[ 1 2 2 ]
|
2007-12-24 21:54:45 -05:00
|
|
|
[ { 1 2 } [ dup 2 slot swap 3 slot [ foo ] keep ] compile-call ]
|
2007-09-20 18:09:08 -04:00
|
|
|
unit-test
|
|
|
|
|
|
|
|
[ 3 ]
|
|
|
|
[
|
|
|
|
global [ 3 \ foo set ] bind
|
2009-05-16 01:29:21 -04:00
|
|
|
\ foo [ global >n get namespaces.private:ndrop ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
2009-02-23 21:27:05 -05:00
|
|
|
: blech ( x -- ) drop ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
[ 3 ]
|
|
|
|
[
|
|
|
|
global [ 3 \ foo set ] bind
|
2007-12-24 21:54:45 -05:00
|
|
|
\ foo [ global [ get ] swap blech call ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 3 ]
|
|
|
|
[
|
|
|
|
global [ 3 \ foo set ] bind
|
2009-05-16 01:29:21 -04:00
|
|
|
\ foo [ global [ get ] swap >n call namespaces.private:ndrop ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 3 ]
|
|
|
|
[
|
|
|
|
global [ 3 \ foo set ] bind
|
2007-12-24 21:54:45 -05:00
|
|
|
\ foo [ global [ get ] bind ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 12 13 ] [
|
2008-03-29 21:36:58 -04:00
|
|
|
-12 -13 [ [ 0 swap fixnum-fast ] bi@ ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
2008-12-17 20:17:37 -05:00
|
|
|
[ -1 2 ] [ 1 2 [ [ 0 swap fixnum- ] dip ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
[ 12 13 ] [
|
2008-03-29 21:36:58 -04:00
|
|
|
-12 -13 [ [ 0 swap fixnum- ] bi@ ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
2008-03-27 06:13:52 -04:00
|
|
|
[ 1 ] [
|
|
|
|
SBUF" " [ 1 slot 1 [ slot ] keep ] compile-call nip
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Test slow shuffles
|
|
|
|
[ 3 1 2 3 4 5 6 7 8 9 ] [
|
|
|
|
1 2 3 4 5 6 7 8 9
|
2008-12-17 20:17:37 -05:00
|
|
|
[ [ [ [ [ [ [ [ [ [ 3 ] dip ] dip ] dip ] dip ] dip ] dip ] dip ] dip ] dip ]
|
2007-12-24 21:54:45 -05:00
|
|
|
compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 2 2 2 2 2 2 2 2 2 2 1 ] [
|
|
|
|
1 2
|
2008-12-17 20:17:37 -05:00
|
|
|
[ swap [ dup dup dup dup dup dup dup dup dup ] dip ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ ] [ [ 9 [ ] times ] compile-call ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
[ ] [
|
|
|
|
[
|
|
|
|
[ 200 dup [ 200 3array ] curry map drop ] times
|
2009-02-23 21:27:05 -05:00
|
|
|
] [ (( n -- )) define-temp ] with-compilation-unit drop
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Test how dispatch handles the end of a basic block
|
2008-10-19 04:51:01 -04:00
|
|
|
: try-breaking-dispatch ( n a b -- x str )
|
2007-09-20 18:09:08 -04:00
|
|
|
float+ swap { [ "hey" ] [ "bye" ] } dispatch ;
|
|
|
|
|
2008-06-08 16:32:55 -04:00
|
|
|
: try-breaking-dispatch-2 ( -- ? )
|
2008-12-17 20:17:37 -05:00
|
|
|
1 1.0 2.5 try-breaking-dispatch "bye" = [ 3.5 = ] dip and ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
[ t ] [
|
|
|
|
10000000 [ drop try-breaking-dispatch-2 ] all?
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Regression
|
|
|
|
: (broken) ( x -- y ) ;
|
|
|
|
|
|
|
|
[ 2.0 { 2.0 0.0 } ] [
|
|
|
|
2.0 1.0
|
2007-12-24 21:54:45 -05:00
|
|
|
[ float/f 0.0 [ drop (broken) ] 2keep 2array ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Regression
|
2008-10-19 04:51:01 -04:00
|
|
|
: hellish-bug-1 ( a b -- ) 2drop ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: hellish-bug-2 ( i array x -- x )
|
|
|
|
2dup 1 slot eq? [ 2drop ] [
|
|
|
|
2dup array-nth tombstone? [
|
|
|
|
[
|
2008-12-17 20:17:37 -05:00
|
|
|
[ array-nth ] 2keep [ 1 fixnum+fast ] dip array-nth
|
2007-09-20 18:09:08 -04:00
|
|
|
pick 2dup hellish-bug-1 3drop
|
|
|
|
] 2keep
|
2008-12-17 20:17:37 -05:00
|
|
|
] unless [ 2 fixnum+fast ] dip hellish-bug-2
|
2008-10-19 04:51:01 -04:00
|
|
|
] if ; inline recursive
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: hellish-bug-3 ( hash array -- )
|
|
|
|
0 swap hellish-bug-2 drop ;
|
|
|
|
|
|
|
|
[ ] [
|
2008-06-30 04:57:00 -04:00
|
|
|
H{ { 1 2 } { 3 4 } } dup array>>
|
2007-12-24 21:54:45 -05:00
|
|
|
[ 0 swap hellish-bug-2 drop ] compile-call
|
2007-09-20 18:09:08 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Regression
|
2008-06-08 16:32:55 -04:00
|
|
|
: foox ( obj -- obj )
|
2007-09-20 18:09:08 -04:00
|
|
|
dup not
|
|
|
|
[ drop 3 ] [ dup tuple? [ drop 4 ] [ drop 5 ] if ] if ;
|
|
|
|
|
|
|
|
[ 3 ] [ f foox ] unit-test
|
|
|
|
|
|
|
|
TUPLE: my-tuple ;
|
|
|
|
|
|
|
|
[ 4 ] [ T{ my-tuple } foox ] unit-test
|
|
|
|
|
|
|
|
[ 5 ] [ "hi" foox ] unit-test
|
2007-09-28 04:02:33 -04:00
|
|
|
|
|
|
|
! Making sure we don't needlessly unbox/rebox
|
2008-12-17 20:17:37 -05:00
|
|
|
[ t 3.0 ] [ 1.0 dup [ dup 2.0 float+ [ eq? ] dip ] compile-call ] unit-test
|
2007-09-28 04:02:33 -04:00
|
|
|
|
2008-12-17 20:17:37 -05:00
|
|
|
[ t 3.0 ] [ 1.0 dup [ dup 2.0 float+ ] compile-call [ eq? ] dip ] unit-test
|
2007-09-28 04:02:33 -04:00
|
|
|
|
2007-12-24 21:54:45 -05:00
|
|
|
[ t ] [ 1.0 dup [ [ 2.0 float+ ] keep ] compile-call nip eq? ] unit-test
|
2007-09-28 04:02:33 -04:00
|
|
|
|
|
|
|
[ 1 B{ 1 2 3 4 } ] [
|
|
|
|
B{ 1 2 3 4 } [
|
|
|
|
{ byte-array } declare
|
|
|
|
[ 0 alien-unsigned-1 ] keep
|
2007-12-24 21:54:45 -05:00
|
|
|
] compile-call
|
2007-09-28 04:02:33 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 1 t ] [
|
|
|
|
B{ 1 2 3 4 } [
|
2007-10-01 04:20:47 -04:00
|
|
|
{ c-ptr } declare
|
2008-04-03 01:22:10 -04:00
|
|
|
[ 0 alien-unsigned-1 ] keep hi-tag
|
2007-12-24 21:54:45 -05:00
|
|
|
] compile-call byte-array type-number =
|
2007-09-28 04:02:33 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ t ] [
|
|
|
|
B{ 1 2 3 4 } [
|
2007-10-01 04:20:47 -04:00
|
|
|
{ c-ptr } declare
|
2008-04-03 01:22:10 -04:00
|
|
|
0 alien-cell hi-tag
|
2007-12-24 21:54:45 -05:00
|
|
|
] compile-call alien type-number =
|
2007-09-28 04:02:33 -04:00
|
|
|
] unit-test
|
2007-10-01 06:56:45 -04:00
|
|
|
|
|
|
|
[ 2 1 ] [
|
|
|
|
2 1
|
2008-12-17 20:17:37 -05:00
|
|
|
[ 2dup fixnum< [ [ die ] dip ] when ] compile-call
|
2007-10-01 06:56:45 -04:00
|
|
|
] unit-test
|
2008-02-14 18:46:04 -05:00
|
|
|
|
|
|
|
! Regression
|
2008-10-19 04:34:42 -04:00
|
|
|
: a-dummy ( a -- ) drop "hi" print ;
|
2008-02-14 18:46:04 -05:00
|
|
|
|
|
|
|
[ ] [
|
|
|
|
1 [
|
|
|
|
dup 0 2 3dup pick >= [ >= ] [ 2drop f ] if [
|
|
|
|
drop - >fixnum {
|
|
|
|
[ a-dummy ]
|
|
|
|
[ a-dummy ]
|
|
|
|
[ a-dummy ]
|
|
|
|
} dispatch
|
|
|
|
] [ 2drop no-case ] if
|
|
|
|
] compile-call
|
|
|
|
] unit-test
|
2008-04-04 04:46:30 -04:00
|
|
|
|
2008-04-17 04:03:22 -04:00
|
|
|
! Regression
|
|
|
|
: dispatch-alignment-regression ( -- c )
|
|
|
|
{ tuple vector } 3 slot { word } declare
|
|
|
|
dup 1 slot 0 fixnum-bitand { [ ] } dispatch ;
|
|
|
|
|
2009-04-28 18:26:11 -04:00
|
|
|
[ t ] [ \ dispatch-alignment-regression optimized? ] unit-test
|
2008-04-17 04:03:22 -04:00
|
|
|
|
|
|
|
[ vector ] [ dispatch-alignment-regression ] unit-test
|
2008-10-20 02:56:28 -04:00
|
|
|
|
|
|
|
! Regression
|
|
|
|
: bad-value-bug ( a -- b ) [ 3 ] [ 3 ] if f <array> ;
|
|
|
|
|
|
|
|
[ { f f f } ] [ t bad-value-bug ] unit-test
|
2008-11-10 03:58:05 -05:00
|
|
|
|
|
|
|
! PowerPC regression
|
|
|
|
TUPLE: id obj ;
|
|
|
|
|
|
|
|
: (gc-check-bug) ( a b -- c )
|
|
|
|
{ [ id boa ] [ id boa ] } dispatch ;
|
|
|
|
|
|
|
|
: gc-check-bug ( -- )
|
|
|
|
10000000 [ "hi" 0 (gc-check-bug) drop ] times ;
|
|
|
|
|
|
|
|
[ ] [ gc-check-bug ] unit-test
|
2008-11-13 05:16:58 -05:00
|
|
|
|
|
|
|
! New optimization
|
|
|
|
: test-1 ( a -- b ) 8 fixnum-fast { [ "a" ] [ "b" ] } dispatch ;
|
|
|
|
|
|
|
|
[ "a" ] [ 8 test-1 ] unit-test
|
|
|
|
[ "b" ] [ 9 test-1 ] unit-test
|
|
|
|
|
|
|
|
: test-2 ( a -- b ) 1 fixnum-fast { [ "a" ] [ "b" ] } dispatch ;
|
|
|
|
|
|
|
|
[ "a" ] [ 1 test-2 ] unit-test
|
|
|
|
[ "b" ] [ 2 test-2 ] unit-test
|
2008-11-24 12:12:36 -05:00
|
|
|
|
|
|
|
! I accidentally fixnum/i-fast on PowerPC
|
|
|
|
[ { { 1 2 } { 3 4 } } ] [
|
|
|
|
{ 1 2 3 4 }
|
|
|
|
[
|
|
|
|
[ { array } declare 2 <groups> [ , ] each ] compile-call
|
|
|
|
] { } make
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 2 ] [
|
|
|
|
{ 1 2 3 4 }
|
|
|
|
[ { array } declare 2 <groups> length ] compile-call
|
|
|
|
] unit-test
|
2008-11-29 01:37:07 -05:00
|
|
|
|
|
|
|
! Oops with new intrinsics
|
|
|
|
: fixnum-overflow-control-flow-test ( a b -- c )
|
|
|
|
[ 1 fixnum- ] [ 2 fixnum- ] if 3 fixnum+fast ;
|
|
|
|
|
|
|
|
[ 3 ] [ 1 t fixnum-overflow-control-flow-test ] unit-test
|
|
|
|
[ 2 ] [ 1 f fixnum-overflow-control-flow-test ] unit-test
|
2008-11-29 04:46:57 -05:00
|
|
|
|
|
|
|
! LOL
|
|
|
|
: blah ( a -- b )
|
|
|
|
{ float } declare dup 0 =
|
|
|
|
[ drop 1 ] [
|
|
|
|
dup 0 >=
|
|
|
|
[ 2 "double" "libm" "pow" { "double" "double" } alien-invoke ]
|
|
|
|
[ -0.5 "double" "libm" "pow" { "double" "double" } alien-invoke ]
|
|
|
|
if
|
|
|
|
] if ;
|
|
|
|
|
|
|
|
[ 4.0 ] [ 2.0 blah ] unit-test
|
2008-11-29 05:23:23 -05:00
|
|
|
|
2008-11-29 01:44:46 -05:00
|
|
|
[ 4 ] [ 2 [ dup fixnum* ] compile-call ] unit-test
|
|
|
|
[ 7 ] [ 2 [ dup fixnum* 3 fixnum+fast ] compile-call ] unit-test
|
2009-01-29 00:35:41 -05:00
|
|
|
|
2009-01-29 02:44:58 -05:00
|
|
|
TUPLE: cucumber ;
|
2009-01-29 00:35:41 -05:00
|
|
|
|
|
|
|
M: cucumber equal? "The cucumber has no equal" throw ;
|
|
|
|
|
2009-04-26 01:51:47 -04:00
|
|
|
[ t ] [ [ cucumber ] compile-call cucumber eq? ] unit-test
|
2009-06-03 04:22:46 -04:00
|
|
|
|
|
|
|
[ 4294967295 B{ 255 255 255 255 } -1 ]
|
|
|
|
[
|
|
|
|
-1 <int> -1 <int>
|
2009-07-22 22:10:50 -04:00
|
|
|
[ [ 0 alien-unsigned-4 swap ] [ 0 alien-signed-2 ] bi ]
|
2009-06-03 04:22:46 -04:00
|
|
|
compile-call
|
2009-06-13 18:35:40 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Regression found while working on global register allocation
|
|
|
|
|
|
|
|
: linear-scan-regression-1 ( a b c -- ) 3array , ;
|
|
|
|
: linear-scan-regression-2 ( a b -- ) 2array , ;
|
|
|
|
|
|
|
|
: linear-scan-regression ( a b c -- )
|
|
|
|
[ linear-scan-regression-2 ]
|
|
|
|
[ linear-scan-regression-1 ]
|
|
|
|
bi-curry bi-curry interleave ;
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
{ 1 "x" "y" }
|
|
|
|
{ "x" "y" }
|
|
|
|
{ 2 "x" "y" }
|
|
|
|
{ "x" "y" }
|
|
|
|
{ 3 "x" "y" }
|
|
|
|
}
|
|
|
|
] [
|
|
|
|
[ { 1 2 3 } "x" "y" linear-scan-regression ] { } make
|
2009-07-04 03:50:50 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Regression from Doug's value numbering changes
|
|
|
|
[ t ] [ 2 [ 1 swap fixnum< ] compile-call ] unit-test
|
2009-07-14 17:05:25 -04:00
|
|
|
[ 3 ] [ 2 [ 1 swap fixnum< [ 3 ] [ 4 ] if ] compile-call ] unit-test
|
|
|
|
|
2009-07-14 17:11:14 -04:00
|
|
|
cell 4 = [
|
|
|
|
[ 0 ] [ 101 [ dup fixnum-fast 1 fixnum+fast 20 fixnum-shift-fast 20 fixnum-shift-fast ] compile-call ] unit-test
|
2009-07-14 21:05:01 -04:00
|
|
|
] when
|
|
|
|
|
|
|
|
! Regression from Slava's value numbering changes
|
2009-07-23 19:03:14 -04:00
|
|
|
[ 1 ] [ 31337 [ dup fixnum<= [ 1 ] [ 2 ] if ] compile-call ] unit-test
|
|
|
|
|
|
|
|
! Bug with ##return node construction
|
|
|
|
: return-recursive-bug ( nodes -- ? )
|
|
|
|
{ fixnum } declare [
|
|
|
|
dup 3 bitand 1 = [ drop t ] [
|
|
|
|
dup 3 bitand 2 = [
|
|
|
|
return-recursive-bug
|
|
|
|
] [ drop f ] if
|
|
|
|
] if
|
|
|
|
] any? ; inline recursive
|
|
|
|
|
2009-07-28 07:45:31 -04:00
|
|
|
[ t ] [ 3 [ return-recursive-bug ] compile-call ] unit-test
|
|
|
|
|
|
|
|
! Coalescing reductions
|
|
|
|
[ f ] [ V{ } 0 [ [ vector? ] both? ] compile-call ] unit-test
|
|
|
|
[ f ] [ 0 V{ } [ [ vector? ] both? ] compile-call ] unit-test
|
|
|
|
|
|
|
|
[ f ] [
|
|
|
|
f vector [
|
|
|
|
[ dup [ \ vector eq? ] [ drop f ] if ] dip
|
|
|
|
dup [ \ vector eq? ] [ drop f ] if
|
|
|
|
over rot [ drop ] [ nip ] if
|
|
|
|
] compile-call
|
2009-07-31 19:34:15 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Coalesing bug reduced from sequence-parser:take-sequence
|
2009-07-31 23:33:02 -04:00
|
|
|
: coalescing-bug-1 ( a b c d -- a b c d )
|
2009-07-31 19:34:15 -04:00
|
|
|
3dup {
|
|
|
|
[ 2drop 0 < ]
|
|
|
|
[ [ drop ] 2dip length > ]
|
|
|
|
[ drop > ]
|
|
|
|
} 3|| [ 3drop f ] [ slice boa ] if swap [ [ length ] bi@ ] 2keep ;
|
|
|
|
|
|
|
|
[ 0 3 f { 1 2 3 } ] [ { 1 2 3 } -10 3 "hello" coalescing-bug-1 ] unit-test
|
2009-07-31 23:33:02 -04:00
|
|
|
[ 0 3 f { 1 2 3 } ] [ { 1 2 3 } 0 7 "hello" coalescing-bug-1 ] unit-test
|
2009-07-31 19:34:15 -04:00
|
|
|
[ 0 3 f { 1 2 3 } ] [ { 1 2 3 } 3 2 "hello" coalescing-bug-1 ] unit-test
|
2009-08-01 21:22:31 -04:00
|
|
|
[ 2 3 T{ slice f 1 3 "hello" } { 1 2 3 } ] [ { 1 2 3 } 1 3 "hello" coalescing-bug-1 ] unit-test
|
|
|
|
|
|
|
|
! Another one, found by Dan
|
|
|
|
: coalescing-bug-2 ( a -- b )
|
|
|
|
dup dup 10 fixnum< [ 1 fixnum+fast ] when
|
|
|
|
fixnum+fast 2 fixnum*fast 2 fixnum-fast 2 fixnum*fast 2 fixnum+fast ;
|
|
|
|
|
|
|
|
[ 10 ] [ 1 coalescing-bug-2 ] unit-test
|
2009-08-02 04:49:54 -04:00
|
|
|
[ 86 ] [ 11 coalescing-bug-2 ] unit-test
|
|
|
|
|
|
|
|
! Regression in suffix-arrays code
|
|
|
|
: coalescing-bug-3 ( from/f to/f seq -- slice )
|
|
|
|
[
|
|
|
|
[ drop 0 or ] [ length or ] bi-curry bi*
|
|
|
|
[ min ] keep
|
|
|
|
] keep <slice> ;
|
|
|
|
|
|
|
|
[ T{ slice f 0 5 "hello" } ] [ f f "hello" coalescing-bug-3 ] unit-test
|
|
|
|
[ T{ slice f 1 5 "hello" } ] [ 1 f "hello" coalescing-bug-3 ] unit-test
|
|
|
|
[ T{ slice f 0 3 "hello" } ] [ f 3 "hello" coalescing-bug-3 ] unit-test
|
|
|
|
[ T{ slice f 1 3 "hello" } ] [ 1 3 "hello" coalescing-bug-3 ] unit-test
|
|
|
|
[ T{ slice f 3 3 "hello" } ] [ 4 3 "hello" coalescing-bug-3 ] unit-test
|
|
|
|
[ T{ slice f 5 5 "hello" } ] [ 6 f "hello" coalescing-bug-3 ] unit-test
|
|
|
|
|
|
|
|
! Reduction
|
|
|
|
: coalescing-bug-4 ( a b c -- a b c )
|
|
|
|
[ [ min ] keep ] dip vector? [ 1 ] [ 2 ] if ;
|
|
|
|
|
|
|
|
[ 2 3 2 ] [ 2 3 "" coalescing-bug-4 ] unit-test
|
|
|
|
[ 3 3 2 ] [ 4 3 "" coalescing-bug-4 ] unit-test
|
|
|
|
[ 3 3 2 ] [ 4 3 "" coalescing-bug-4 ] unit-test
|
|
|
|
[ 2 3 1 ] [ 2 3 V{ } coalescing-bug-4 ] unit-test
|
|
|
|
[ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test
|
2009-08-03 08:08:28 -04:00
|
|
|
[ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test
|
|
|
|
|
|
|
|
! Global stack analysis dataflow equations are wrong
|
|
|
|
: some-word ( a -- b ) 2 + ;
|
|
|
|
: global-dcn-bug-1 ( a b -- c d )
|
|
|
|
dup [ [ drop 1 ] dip ] [ [ some-word ] dip ] if
|
|
|
|
dup [ [ 1 fixnum+fast ] dip ] [ [ drop 1 ] dip ] if ;
|
|
|
|
|
|
|
|
[ 2 t ] [ 0 t global-dcn-bug-1 ] unit-test
|
2009-08-27 05:09:35 -04:00
|
|
|
[ 1 f ] [ 0 f global-dcn-bug-1 ] unit-test
|
|
|
|
|
|
|
|
! Forgot a GC check
|
|
|
|
: missing-gc-check-1 ( a -- b ) { fixnum } declare <alien> ;
|
|
|
|
: missing-gc-check-2 ( -- ) 10000000 [ missing-gc-check-1 drop ] each-integer ;
|
|
|
|
|
2009-08-30 05:52:01 -04:00
|
|
|
[ ] [ missing-gc-check-2 ] unit-test
|
|
|
|
|
2009-08-30 19:57:45 -04:00
|
|
|
[ 1 "0.169967142900241" ] [ 1.4 [ 1 swap fcos ] compile-call number>string ] unit-test
|
|
|
|
[ 1 "0.169967142900241" ] [ 1.4 1 [ swap fcos ] compile-call number>string ] unit-test
|
|
|
|
[ "0.169967142900241" "0.9854497299884601" ] [ 1.4 [ [ fcos ] [ fsin ] bi ] compile-call [ number>string ] bi@ ] unit-test
|
2009-09-03 03:33:07 -04:00
|
|
|
[ 1 "0.169967142900241" "0.9854497299884601" ] [ 1.4 1 [ swap >float [ fcos ] [ fsin ] bi ] compile-call [ number>string ] bi@ ] unit-test
|
|
|
|
|
2009-09-16 10:20:47 -04:00
|
|
|
[ 6.0 ] [ 1.0 [ >float 3.0 + [ B{ 0 0 0 0 } 0 set-alien-float ] [ 2.0 + ] bi ] compile-call ] unit-test
|
2009-09-22 04:19:23 -04:00
|
|
|
|
|
|
|
! Bug in linearization
|
|
|
|
[ 283686952174081 ] [
|
|
|
|
B{ 1 1 1 1 } [
|
|
|
|
{ byte-array } declare
|
|
|
|
[ 0 2 ] dip
|
|
|
|
[
|
|
|
|
[ drop ] 2dip
|
|
|
|
[
|
|
|
|
swap 1 < [ [ ] dip ] [ [ ] dip ] if
|
|
|
|
0 alien-signed-4
|
|
|
|
] curry dup bi *
|
|
|
|
] curry each-integer
|
|
|
|
] compile-call
|
|
|
|
] unit-test
|
2009-09-23 03:47:56 -04:00
|
|
|
|
|
|
|
TUPLE: myseq { underlying1 byte-array read-only } { underlying2 byte-array read-only } ;
|
|
|
|
|
|
|
|
[ 2 ] [
|
|
|
|
little-endian?
|
|
|
|
T{ myseq f B{ 1 0 0 0 } B{ 1 0 0 0 } }
|
|
|
|
T{ myseq f B{ 0 0 0 1 } B{ 0 0 0 1 } } ?
|
|
|
|
[
|
|
|
|
{ myseq } declare
|
|
|
|
[ 0 2 ] dip dup
|
|
|
|
[
|
|
|
|
[
|
|
|
|
over 1 < [ underlying1>> ] [ [ 1 - ] dip underlying2>> ] if
|
|
|
|
swap 4 * >fixnum alien-signed-4
|
|
|
|
] bi-curry@ bi * +
|
|
|
|
] 2curry each-integer
|
|
|
|
] compile-call
|
|
|
|
] unit-test
|