Will.Whim

A weblog by Will Fitzgerald

More better spec for Arc

A DESCRIBE form now creates a procedure, which, when run, returns a set of results, which can be printed. Also, errors in test forms are caught.

See spec.arc

Can an HTML format be far behind?

(= test-basics
   (describe "Basic ARC list functions"
     (prolog
      (= li '(a b c))
      (= pair '(a . b)))
     (it "CAR should return the first item in a list"
       (is (car li) 'a))
     (it "CAR should return nil for an empty list"
       (is (car '()) nil))
     (it "CADR should return the second item of a list"
       (is (cadr li) 'b))
     (it "CADR should return NIL for an empty list"
       (is (cadr '()) nil))
     (it "CADR should return NIL for the 2nd item of a one item list"
       (is (cadr '(a)) nil))
     (it "CDR should return the rest of a list"
       (iso (cdr li) '(b c)))
     (it "CDR should returns '() for an empty list"
       (is (cdr '()) '()))
     (it "CDR should return the rest of a dotted pair"
       (is (cdr pair) 'b))
     (it "CDDR should return the rest of the rest of a list"
       (iso (cddr li) '(c)))
     (it "CDDR should return '() for an empty list"
       (is (cddr '()) '()))
     (it "CDDR should returns '() for a one item list"
       (is (cddr '(a)) '()))))

(print-results (test-basics) t)

;; Basic ARC list functions
;; CAR should return the first item in a list: t	(is (car li) (quote a))
;; CAR should return nil for an empty list: t	(is (car (quote nil)) nil)
;; CADR should return the second item of a list: t	(is (cadr li) (quote b))
;; CADR should return NIL for an empty list: t	(is (cadr (quote nil)) nil)
;; CADR should return NIL for the 2nd item of a one item list: t	(is (cadr (quote (a))) nil)
;; CDR should return the rest of a list: t	(iso (cdr li) (quote (b c)))
;; CDR should returns '() for an empty list: t	(is (cdr (quote nil)) (quote nil))
;; CDR should return the rest of a dotted pair: t	(is (cdr pair) (quote b))
;; CDDR should return the rest of the rest of a list: t	(iso (cddr li) (quote (c)))
;; CDDR should return '() for an empty list: t	(is (cddr (quote nil)) (quote nil))
;; CDDR should returns '() for a one item list: t	(is (cddr (quote (a))) (quote nil))
;; Tests: 11; Good: 11; Errors: 0; Pct: 100.0

It’s not perfect. But parts of it are excellent.

Advertisements

One response to “More better spec for Arc

  1. Byron Saltysiak February 12, 2008 at 10:41 pm

    Two comments:
    First, Can you check this into nex3’s arc git repo? It seems to be the defacto repository for community work.

    Second, I don’t think using “it” is a good idea. This is a pseudo keyword used in all of the anaphoric macros which makes first glance at the spec somewhat confusing. I was wonder what value was mapped to the “it” at first.

    Third, Very cool. I’m going to try it out now.

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: