]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix input-classes of /i and mod, and add some regression tests with various reduction...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 14 Jan 2010 05:15:47 +0000 (18:15 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 14 Jan 2010 05:15:51 +0000 (18:15 +1300)
basis/compiler/tests/optimizer.factor
basis/compiler/tree/propagation/known-words/known-words.factor
basis/compiler/tree/propagation/propagation-tests.factor
extra/alien/data/map/map-tests.factor
extra/grid-meshes/grid-meshes-tests.factor [new file with mode: 0644]

index 0831d6e8ddc91b7aeb2d7c768b514237123cf5af..04064e442758dbd0a26fb4d50abed22c002b186a 100644 (file)
@@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private
 quotations classes classes.algebra classes.tuple.private
 continuations growable namespaces hints alien.accessors
 compiler.tree.builder compiler.tree.optimizer sequences.deep
-compiler definitions generic.single shuffle ;
+compiler definitions generic.single shuffle math.order ;
 IN: compiler.tests.optimizer
 
 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
 
-! Not sure if I want to fix this...
-! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with
+TUPLE: grid-mesh-tuple { length read-only } { step read-only } ;
+
+: 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
index 0fde7ffa86d1b154389be7b923f61f93c5221c6c..6aacbc57daaa4a5168f5918ad52368e6c9588f72 100644 (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.
 USING: kernel effects accessors math math.private
 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
 
-{ /f < > <= >= u< u> u<= u>= }
+{ /f /i mod < > <= >= u< u> u<= u>= }
 [ { real real } "input-classes" set-word-prop ] each
 
-{ /i mod /mod }
-[ { rational rational } "input-classes" set-word-prop ] each
+\ /mod { rational rational } "input-classes" set-word-prop
 
 { bitand bitor bitxor bitnot shift }
 [ { integer integer } "input-classes" set-word-prop ] each
index f8a53b3287578205be19b5163fa74be5d7475c34..9be76ba0d03f646378243f123c83c0d8bf2e8602 100644 (file)
@@ -90,6 +90,8 @@ IN: compiler.tree.propagation.tests
 
 [ 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 } ] [
index b97a356e6ef8496113fd13fadf8d9d83c4d48878..305ae6bdf236f4b7b2d07d23bd1e58218968abad 100644 (file)
@@ -1,6 +1,6 @@
 ! (c)Joe Groff bsd license
 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 ;
 FROM: alien.c-types => uchar short int float ;
 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 }
     fold-rgba-planes
 ] 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
diff --git a/extra/grid-meshes/grid-meshes-tests.factor b/extra/grid-meshes/grid-meshes-tests.factor
new file mode 100644 (file)
index 0000000..ef71a66
--- /dev/null
@@ -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