Arc Forumnew | comments | leaders | submitlogin
More better Spec for Arc
2 points by will 5939 days ago | 1 comment
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 http://www.entish.org/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


2 points by will 5939 days ago | link

I've added this to the git repository under 'lib'.

-----