From 9fc7a1eca4d51c4415e1a27a4df4cd66ca97ba73 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Tue, 8 Jun 2010 12:00:37 -0400 Subject: [PATCH] Use `assert' for casts in typed benchmarks. --- .../tests/racket/benchmarks/common/fft-typed.rktl | 7 ++++--- .../racket/benchmarks/common/paraffins-typed.rktl | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/collects/tests/racket/benchmarks/common/fft-typed.rktl b/collects/tests/racket/benchmarks/common/fft-typed.rktl index ff74be369f..339a345424 100644 --- a/collects/tests/racket/benchmarks/common/fft-typed.rktl +++ b/collects/tests/racket/benchmarks/common/fft-typed.rktl @@ -1,3 +1,4 @@ +#lang typed/racket ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; File: fft.cl ; Description: FFT benchmark from the Gabriel tests. @@ -47,9 +48,9 @@ (set! ar areal) (set! ai aimag) (set! n (vector-length ar)) - (set! n (abs (- n 1))) ; abs is to appease the typechecker + (set! n (assert (- n 1) exact-nonnegative-integer?)) (set! nv2 (quotient n 2)) - (set! nm1 (abs (- n 1))) ; abs is to appease the typechecker + (set! nm1 (assert (- n 1) exact-nonnegative-integer?)) (set! m 0) ;compute m = log(n) (set! i 1) (let loop () @@ -74,7 +75,7 @@ (set! k nv2) (let l6 () (cond ((< k j) - (set! j (abs (- j k))) ; abs is to appease the typechecker + (set! j (assert (- j k) exact-nonnegative-integer?)) ; abs is to appease the typechecker (set! k (quotient k 2)) (l6)))) (set! j (+ j k)) diff --git a/collects/tests/racket/benchmarks/common/paraffins-typed.rktl b/collects/tests/racket/benchmarks/common/paraffins-typed.rktl index 7e441ecac3..547c0d5b28 100644 --- a/collects/tests/racket/benchmarks/common/paraffins-typed.rktl +++ b/collects/tests/racket/benchmarks/common/paraffins-typed.rktl @@ -155,9 +155,9 @@ (if (< nc2 nc1) (loop1 lst (- nc1 1)) - (loop2 (cons (vector (abs nc1) - (abs nc2) - (abs (- m (+ nc1 nc2)))) ; abs is to appease the typechecker + (loop2 (cons (vector nc1 + nc2 + (assert (- m (+ nc1 nc2)) exact-nonnegative-integer?)) lst) (- nc2 1))))))) @@ -178,10 +178,10 @@ (nc3 (quotient (- m (+ nc1 nc2)) 2))) (if (< nc3 start) (loop2 lst (- nc2 1)) - (loop3 (cons (vector (abs nc1) - (abs nc2) - (abs nc3) - (abs (- m (+ nc1 (+ nc2 nc3))))) ; abs is to appease the typechecker + (loop3 (cons (vector nc1 + nc2 + nc3 + (assert (- m (+ nc1 (+ nc2 nc3))) exact-nonnegative-integer?)) lst) (- nc3 1))))))))))