Fix input-classes of /i and mod, and add some regression tests with various reductions of the original test-case from the terrain demo

db4
Slava Pestov 2010-01-14 18:15:47 +13:00
parent 2aa4d3d432
commit 50d68c1b10
5 changed files with 50 additions and 8 deletions

View File

@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private
quotations classes classes.algebra classes.tuple.private quotations classes classes.algebra classes.tuple.private
continuations growable namespaces hints alien.accessors continuations growable namespaces hints alien.accessors
compiler.tree.builder compiler.tree.optimizer sequences.deep compiler.tree.builder compiler.tree.optimizer sequences.deep
compiler definitions generic.single shuffle ; compiler definitions generic.single shuffle math.order ;
IN: compiler.tests.optimizer IN: compiler.tests.optimizer
GENERIC: xyz ( obj -- obj ) GENERIC: xyz ( obj -- obj )
@ -445,5 +445,17 @@ M: object bad-dispatch-position-test* ;
[ 1024 bignum ] [ 10 [ 1 >bignum swap >fixnum shift ] compile-call dup class ] unit-test [ 1024 bignum ] [ 10 [ 1 >bignum swap >fixnum shift ] compile-call dup class ] unit-test
! Not sure if I want to fix this... TUPLE: grid-mesh-tuple { length read-only } { step read-only } ;
! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with
: grid-mesh-test-case ( -- vertices )
1.0 1.0 { 2 } first /f [ /i 1 + ] keep grid-mesh-tuple boa
1 f <array>
[
[ drop length>> >fixnum 2 min ] 2keep
[
[ step>> 1 * ] dip
0 swap set-nth-unsafe
] 2curry times
] keep ;
[ { 0.5 } ] [ grid-mesh-test-case ] unit-test

View File

@ -1,4 +1,4 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel effects accessors math math.private USING: kernel effects accessors math math.private
math.integers.private math.floats.private math.partial-dispatch math.integers.private math.floats.private math.partial-dispatch
@ -23,11 +23,10 @@ IN: compiler.tree.propagation.known-words
{ + - * / } { + - * / }
[ { number number } "input-classes" set-word-prop ] each [ { number number } "input-classes" set-word-prop ] each
{ /f < > <= >= u< u> u<= u>= } { /f /i mod < > <= >= u< u> u<= u>= }
[ { real real } "input-classes" set-word-prop ] each [ { real real } "input-classes" set-word-prop ] each
{ /i mod /mod } \ /mod { rational rational } "input-classes" set-word-prop
[ { rational rational } "input-classes" set-word-prop ] each
{ bitand bitor bitxor bitnot shift } { bitand bitor bitxor bitnot shift }
[ { integer integer } "input-classes" set-word-prop ] each [ { integer integer } "input-classes" set-word-prop ] each

View File

@ -90,6 +90,8 @@ IN: compiler.tree.propagation.tests
[ float ] [ [ { float float } declare mod ] final-math-class ] unit-test [ float ] [ [ { float float } declare mod ] final-math-class ] unit-test
[ V{ integer float } ] [ [ { float float } declare [ /i ] keep ] final-classes ] unit-test
[ V{ fixnum } ] [ [ 255 bitand ] final-classes ] unit-test [ V{ fixnum } ] [ [ 255 bitand ] final-classes ] unit-test
[ V{ fixnum } ] [ [ V{ fixnum } ] [

View File

@ -1,6 +1,6 @@
! (c)Joe Groff bsd license ! (c)Joe Groff bsd license
USING: alien.data.map fry generalizations kernel locals math.vectors USING: alien.data.map fry generalizations kernel locals math.vectors
math.vectors.conversion math math.vectors.simd sequences math.vectors.conversion math math.vectors.simd math.ranges sequences
specialized-arrays tools.test ; specialized-arrays tools.test ;
FROM: alien.c-types => uchar short int float ; FROM: alien.c-types => uchar short int float ;
SPECIALIZED-ARRAYS: int float float-4 uchar-16 ; SPECIALIZED-ARRAYS: int float float-4 uchar-16 ;
@ -145,3 +145,11 @@ CONSTANT: plane-count 4
B{ 15 25 35 45 55 65 75 85 95 105 115 125 135 145 155 165 } B{ 15 25 35 45 55 65 75 85 95 105 115 125 135 145 155 165 }
fold-rgba-planes fold-rgba-planes
] unit-test ] unit-test
: data-map-compiler-bug-test ( n -- byte-array )
[ 0.0 1.0 1.0 ] dip /f <range>
[ ] data-map( object -- float ) ;
[ float-array{ 0.0 0.5 1.0 } ]
[ 2 data-map-compiler-bug-test byte-array>float-array ]
unit-test

View File

@ -0,0 +1,21 @@
IN: grid-meshes.tests
USING: alien.c-types grid-meshes grid-meshes.private
specialized-arrays tools.test ;
SPECIALIZED-ARRAY: float
[
float-array{
0.0 0.0 0.0 1.0
0.0 0.0 0.5 1.0
0.5 0.0 0.0 1.0
0.5 0.0 0.5 1.0
1.0 0.0 0.0 1.0
1.0 0.0 0.5 1.0
0.0 0.0 0.5 1.0
0.0 0.0 1.0 1.0
0.5 0.0 0.5 1.0
0.5 0.0 1.0 1.0
1.0 0.0 0.5 1.0
1.0 0.0 1.0 1.0
}
] [ { 2 2 } vertex-array byte-array>float-array ] unit-test