; Copyright (C) 2006 Will M. Farr ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License along ; with this program; if not, write to the Free Software Foundation, Inc., ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. (module test (lib "swindle.ss" "swindle") (require (planet "test.ss" ("schematics" "schemeunit.plt" 2)) (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2)) (all-except (lib "43.ss" "srfi") vector->list vector-fill!) "tuples.ss") (provide (all-from (planet "test.ss" ("schematics" "schemeunit.plt" 2))) (all-from (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2))) close? tuple-close? tuple= check-close? check-tuple-close? check= check-tuple= check-equals?) (define ((close? eps) a b) (< (abs (- a b)) eps)) (define-check (check-close? eps a b) (if (not ((close? eps) a b)) (fail-check))) (define ((tuple-close? eps) a b) (and (tuple-same-type? a b) (vector= (lambda (aelt belt) (if (tuple? aelt) ((tuple-close? eps) aelt belt) ((close? eps) aelt belt))) (slot-ref a 'elts) (slot-ref b 'elts)))) (define (tuple= a b) (and (tuple-same-type? a b) (vector= (lambda (aelt belt) (if (tuple? aelt) (tuple= aelt belt) (= aelt belt))) (slot-ref a 'elts) (slot-ref b 'elts)))) (define-check (check-tuple-close? eps a b) (if (not ((tuple-close? eps) a b)) (fail-check))) (define-check (check= a b) (if (not (= a b)) (fail-check))) (define-check (check-tuple= a b) (if (not (tuple= a b)) (fail-check))) (define-check (check-equals? a b) (if (not (equals? a b)) (fail-check))))