Tester in Lisp

Cute little thing: http://sourceforge.net/projects/lispsnippets/files/tester.lisp

Got the idea from the book — V. A. Potapenko, “Lisp From All Sides” (in Russian). I just added keywords, their default values, and removed cond (it’s not really needed here).

It takes some input, applies a test-function to it, and compares the result with the output, using eq-p as a comparison operator.

It returns T or NIL.

By default it checks that 2 + 2 is 4. You can specify input, output, test-function and eq-p.

For example, to check that 2 – 2 – 1 is approximately (with the tolerance 0.5) equal to -1.2, type:

(tester :input '(2 2 1)
        :output '-1.2
        :test-function (lambda (&rest x) (apply #'- x))
        :eq-p (lambda (x y) (< (abs (- x y)) 0.5)))
Published in: on 28/11/2012 at 18:04  Leave a Comment  

The URI to TrackBack this entry is: https://burubaxair.wordpress.com/2012/11/28/tester-in-lisp/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: