Topics

programming

php drupal scheme scheming macros design patterns da la

design

design css

random thoughts

scribbles

alter ego

other me 'em that link us my space me linked in

Collections

Programmable web
PHP design patterns

Similar things

  • Emulating closures in PHP
  • Some ways to use saved state with closures in php
  • scheming templates
  • scheming away
  • still scheming away
  • scheming anything/anytype - creating base types experiment
  • Scoped php functions or more ways to abuse php
  • An exercise with continuations, prompts and scheme macros
  • macro processor - initial notes
  • Relations and their domain structures

Home » blogs » vlado's blog

a sample testsuite for the (any/type) base types

Submitted by vlado on Tue, 2006-02-14 13:25.code | programming | scheme | work in progress

Here comes a sample test suite (it is too long, so only the beginning features in here) for the any/types, I described earlier. I like the clenliness of the schemeunit library. It features a rich set of assertions, simple but powerful grouping and both text and gui result interfaces. In order to use it you need plt scheme. Then you can grab the unit test suite from planet: (require (planet "test.ss" ("schematics" "schemeunit.plt" 1 2)))

The code here shows testing only the any/text type and all relevant auxilary functions, using this datatatype. Looking at the code, it could be turned into a macro, so we could generate type tests automatically, rather than writing this long code..

(define any-types-tests (make-test-suite "Tests for any/types" (let ((var (make-any/text 1 "test/text" "lorem ipsum" 0 #t 'text/plain))) (make-test-suite "any/text tests" (make-test-case "x '? 'any/text " (assert-true (var '? 'any/text))) (make-test-case "x '? 'not/any/text " (assert-false (var '? 'not/any/text))) (make-test-case "any/stext? x " (assert-false (any/stext? var))) (make-test-case "any/float? x " (assert-false (any/float? var))) (make-test-case "any/int? x " (assert-false (any/int? var))) (make-test-case "any/date? x " (assert-false (any/date? var))) (make-test-case "type? x " (assert-equal? 'any/text (type? var))) (make-test-case "id? x " (assert-equal? 1 (id? var))) (make-test-case "name? x " (assert-equal? "test/text" (name? var))) (make-test-case "data? x " (assert-equal? "lorem ipsum" (data? var))) (make-test-case "delta? x " (assert-equal? 0 (delta? var))) (make-test-case "required? x " (assert-equal? #t (required? var))) (make-test-case "format? x " (assert-equal? 'text/plain (format? var))) (make-test-case "delta= x x " (assert-equal? #t (delta= var var))) (make-test-case "id! x 2" (begin (id! var 2) (assert-equal? 2 (id? var)))) (make-test-case "name! x test1" (begin (name! var "test1") (assert-equal? "test1" (name? var)))) (make-test-case "data! x data" (begin (data! var "data") (assert-equal? "data" (data? var)))) (make-test-case "delta! x 1" (begin (delta! var 1) (assert-equal? 1 (delta? var)))) (make-test-case "required! x 2" #f (begin (required! var #f) (assert-false (required? var)))) (make-test-case "format! x text/html" #f (begin (format! var 'text/html) (assert-equal? 'text/html (format? var)))))) ;====================================================== ;similarly define test suites for the rest of the types ;======================================================

vlado's blog | add new comment
Home » blogs » vlado's blog

dikini.net

spreading confusion by accident since 1970