Skip to content

Commit

Permalink
Adds tests for f32vectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
astlouisf committed Aug 7, 2015
1 parent 69dc36d commit 81026b9
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 0 deletions.
39 changes: 39 additions & 0 deletions gsc/tests/68-f32vector/and.scm
@@ -0,0 +1,39 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define x1 '#f32())
(define x2 '#f32(1.5 2.5 3.5))

(define (which z)
(cond ((##eq? z x1)
"=x1")
((##eq? z x2)
"=x2")
((##eq? z #f)
"=#f")
(else
"not =x1 or =x2 or =#f")))

(define (test2 x y)
(println (which (and x y)))
(println (if (and x y) 11 22))
(println (which (and (##not x) y)))
(println (if (and (##not x) y) 11 22))
(println (which (and x (##not y))))
(println (if (and x (##not y)) 11 22))
(println (which (and (##not x) (##not y))))
(println (if (and (##not x) (##not y)) 11 22))
(println (which (##not (and x y))))
(println (if (##not (and x y)) 11 22))
(println (which (##not (and (##not x) y))))
(println (if (##not (and (##not x) y)) 11 22))
(println (which (##not (and x (##not y)))))
(println (if (##not (and x (##not y))) 11 22))
(println (which (##not (and (##not x) (##not y)))))
(println (if (##not (and (##not x) (##not y))) 11 22)))

(define (test x)
(test2 x x1)
(test2 x x2))

(test x1)
(test x2)
15 changes: 15 additions & 0 deletions gsc/tests/68-f32vector/eq.scm
@@ -0,0 +1,15 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 '#f32())
(define v2 '#f32(1.5 2.5 3.5))

(define (test2 x y)
(println (##eq? x y))
(println (if (##eq? x y) 11 22)))

(define (test x)
(test2 x v1)
(test2 x v2))

(test v1)
(test v2)
10 changes: 10 additions & 0 deletions gsc/tests/68-f32vector/if.scm
@@ -0,0 +1,10 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 '#f32())
(define v2 '#f32(1.5 2.5 3.5))

(define (test x)
(println (if x 11 22)))

(test v1)
(test v2)
27 changes: 27 additions & 0 deletions gsc/tests/68-f32vector/makevector.scm
@@ -0,0 +1,27 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define f (##not 123))
(define t (##not f))
(define s "")
(define x 1.5)
(define y (##make-f32vector 2 5.5))
(define z (##list 1 2 3))

(define (test x)
(println (##f32vector? x))
(println (if (##f32vector? x) 11 22)))

(test 0)
(test 1)
(test f)
(test t)
(test s)
(test x)
(test y)
(test z)
(test (##cdr z))

(println (##f32vector-ref y 0))
(println (##f32vector-ref y 1))
(##f32vector-set! y 1 9.5)
(println (##f32vector-ref y 1))
10 changes: 10 additions & 0 deletions gsc/tests/68-f32vector/not.scm
@@ -0,0 +1,10 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 '#f32())
(define v2 '#f32(1.5 2.5 3.5))

(define (test x)
(println (if (##not x) 11 22)))

(test v1)
(test v2)
39 changes: 39 additions & 0 deletions gsc/tests/68-f32vector/or.scm
@@ -0,0 +1,39 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define x1 '#f32())
(define x2 '#f32(1.5 2.5 3.5))

(define (which z)
(cond ((##eq? z x1)
"=x1")
((##eq? z x2)
"=x2")
((##eq? z #f)
"=#f")
(else
"not =x1 or =x2 or =#f")))

(define (test2 x y)
(println (which (or x y)))
(println (if (or x y) 11 22))
(println (which (or (##not x) y)))
(println (if (or (##not x) y) 11 22))
(println (which (or x (##not y))))
(println (if (or x (##not y)) 11 22))
(println (which (or (##not x) (##not y))))
(println (if (or (##not x) (##not y)) 11 22))
(println (which (##not (or x y))))
(println (if (##not (or x y)) 11 22))
(println (which (##not (or (##not x) y))))
(println (if (##not (or (##not x) y)) 11 22))
(println (which (##not (or x (##not y)))))
(println (if (##not (or x (##not y))) 11 22))
(println (which (##not (or (##not x) (##not y)))))
(println (if (##not (or (##not x) (##not y))) 11 22)))

(define (test x)
(test2 x x1)
(test2 x x2))

(test x1)
(test x2)
27 changes: 27 additions & 0 deletions gsc/tests/68-f32vector/vector.scm
@@ -0,0 +1,27 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define f (##not 123))
(define t (##not f))
(define s "")
(define x 1.5)
(define y (##f32vector 1.5 2.5))
(define z (##list 1 2 3))

(define (test x)
(println (##f32vector? x))
(println (if (##f32vector? x) 11 22)))

(test 0)
(test 1)
(test f)
(test t)
(test s)
(test x)
(test y)
(test z)
(test (##cdr z))

(println (##f32vector-ref y 0))
(println (##f32vector-ref y 1))
(##f32vector-set! y 1 9.5)
(println (##f32vector-ref y 1))
12 changes: 12 additions & 0 deletions gsc/tests/68-f32vector/vectorlength.scm
@@ -0,0 +1,12 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define a (##f32vector 1.5 2.5))
(define b (##make-f32vector 10 5.5))
(define c '#f32(1.5 2.5 3.5 4.5))

(define (test v)
(println (##f32vector-length v)))

(test a)
(test b)
(test c)
15 changes: 15 additions & 0 deletions gsc/tests/68-f32vector/vectorref.scm
@@ -0,0 +1,15 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 (##f32vector 1.5 2.5))
(define v2 (##make-f32vector 10 5.5))
(define v3 '#f32(1.5 2.5 3.5 4.5))

(define (test v i)
(println (##f32vector-ref v i)))

(test v1 0)
(test v1 1)

(test v2 9)

(test v3 3)
12 changes: 12 additions & 0 deletions gsc/tests/68-f32vector/vectorset.scm
@@ -0,0 +1,12 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 (##f32vector 1.5 2.5))
(define v2 (##make-f32vector 10 5.5))

(define (test v i)
(println (##f32vector-ref v i))
(println (##eq? v (##f32vector-set! v i 9.5)))
(println (##f32vector-ref v i)))

(test v1 1)
(test v2 9)
11 changes: 11 additions & 0 deletions gsc/tests/68-f32vector/vectorshrink.scm
@@ -0,0 +1,11 @@
(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 (##f32vector 1.5 2.5))
(define v2 (##make-f32vector 10 5.5))

(define (test v n)
(println (##eq? v (##f32vector-shrink! v n)))
(println (##f32vector-length v)))

(test v1 1)
(test v2 5)

0 comments on commit 81026b9

Please sign in to comment.