compiler tests: add test case for coalescing bug

db4
Slava Pestov 2009-08-02 03:49:54 -05:00
parent e1c7f7394a
commit 21489ce85e
1 changed files with 28 additions and 2 deletions

View File

@ -2,7 +2,8 @@ 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
alien.accessors layouts words definitions compiler.units io
combinators vectors grouping make alien.c-types combinators.short-circuit ;
combinators vectors grouping make alien.c-types combinators.short-circuit
math.order ;
QUALIFIED: namespaces.private
IN: compiler.tests.codegen
@ -366,4 +367,29 @@ cell 4 = [
fixnum+fast 2 fixnum*fast 2 fixnum-fast 2 fixnum*fast 2 fixnum+fast ;
[ 10 ] [ 1 coalescing-bug-2 ] unit-test
[ 86 ] [ 11 coalescing-bug-2 ] unit-test
[ 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
[ 3 3 1 ] [ 4 3 V{ } coalescing-bug-4 ] unit-test