Saving paren progress

This commit is contained in:
Jay McCarthy 2010-06-24 16:10:28 -06:00
parent a98547b033
commit a9c32a62d4
21 changed files with 207 additions and 18 deletions

View File

@ -6,9 +6,12 @@
(provide eval-tests) (provide eval-tests)
(define-runtime-path examples-dir "examples") (define-runtime-path here ".")
(define (test-example t)
(define test-ss (build-path examples-dir (format "~a.rkt" t))) (define (test-examples examples-dir)
(define (test-example t)
(define test-rkt (build-path examples-dir (format "~a.rkt" t)))
(define test-txt (build-path examples-dir (format "~a.txt" t))) (define test-txt (build-path examples-dir (format "~a.txt" t)))
(test-equal? t (test-equal? t
(filter (lambda (l) (filter (lambda (l)
@ -18,12 +21,11 @@
(not (string=? l ""))) (not (string=? l "")))
(with-input-from-string (with-input-from-string
(with-output-to-string (with-output-to-string
(lambda () (dynamic-require test-ss #f))) (lambda () (dynamic-require test-rkt #f)))
port->lines)))) port->lines))))
(define eval-tests
(test-suite (test-suite
"eval" (path->string examples-dir)
(test-example "ancestor") (test-example "ancestor")
(test-example "bidipath") (test-example "bidipath")
@ -34,6 +36,11 @@
(test-example "revpath") (test-example "revpath")
(test-example "says") (test-example "says")
(test-example "true") (test-example "true")
(test-example "tutorial") (test-example "tutorial")))
)) (define eval-tests
(test-suite
"eval"
(test-examples (build-path here "examples"))
(test-examples (build-path here "paren-examples"))))

View File

@ -0,0 +1,12 @@
#lang datalog/sexp
% Equality test
ancestor(A, B) :-
parent(A, B).
ancestor(A, B) :-
parent(A, C),
D = C, % Unification required
ancestor(D, B).
parent(john, douglas).
parent(bob, john).
parent(ebbon, bob).
ancestor(A, B)?

View File

@ -0,0 +1,6 @@
ancestor(ebbon, bob).
ancestor(bob, john).
ancestor(john, douglas).
ancestor(bob, douglas).
ancestor(ebbon, john).
ancestor(ebbon, douglas).

View File

@ -0,0 +1,7 @@
#lang datalog/sexp
% path test from Chen & Warren
edge(a, b). edge(b, c). edge(c, d). edge(d, a).
path(X, Y) :- edge(X, Y).
path(X, Y) :- edge(X, Z), path(Z, Y).
path(X, Y) :- path(X, Z), edge(Z, Y).
path(X, Y)?

View File

@ -0,0 +1,17 @@
path(a, a).
path(a, d).
path(a, c).
path(a, b).
path(b, b).
path(b, a).
path(b, d).
path(b, c).
path(c, c).
path(c, b).
path(c, a).
path(c, d).
path(d, d).
path(d, c).
path(d, b).
path(d, a).

View File

@ -0,0 +1,12 @@
#lang datalog/sexp
% Laps Test
contains(ca, store, rams_couch, rams).
contains(rams, fetch, rams_couch, will).
contains(ca, fetch, Name, Watcher) :-
contains(ca, store, Name, Owner),
contains(Owner, fetch, Name, Watcher).
trusted(ca).
permit(User, Priv, Name) :-
contains(Auth, Priv, Name, User),
trusted(Auth).
permit(User, Priv, Name)?

View File

@ -0,0 +1,2 @@
permit(rams, store, rams_couch).
permit(will, fetch, rams_couch).

View File

@ -0,0 +1,8 @@
#lang datalog/sexp
abcdefghi(z123456789,
z1234567890123456789,
z123456789012345678901234567890123456789,
z1234567890123456789012345678901234567890123456789012345678901234567890123456789).
this_is_a_long_identifier_and_tests_the_scanners_concat_when_read_with_a_small_buffer.
this_is_a_long_identifier_and_tests_the_scanners_concat_when_read_with_a_small_buffer?

View File

@ -0,0 +1 @@
this_is_a_long_identifier_and_tests_the_scanners_concat_when_read_with_a_small_buffer.

View File

@ -0,0 +1,6 @@
#lang datalog/sexp
% path test from Chen & Warren
edge(a, b). edge(b, c). edge(c, d). edge(d, a).
path(X, Y) :- edge(X, Y).
path(X, Y) :- edge(X, Z), path(Z, Y).
path(X, Y)?

View File

@ -0,0 +1,17 @@
path(a, a).
path(a, d).
path(a, c).
path(a, b).
path(b, a).
path(b, d).
path(b, c).
path(b, b).
path(c, a).
path(c, b).
path(c, c).
path(c, d).
path(d, b).
path(d, c).
path(d, d).
path(d, a).

View File

@ -0,0 +1,6 @@
#lang datalog/sexp
% p q test from Chen & Warren
q(X) :- p(X).
q(a).
p(X) :- q(X).
q(X)?

View File

@ -0,0 +1 @@
q(a).

View File

@ -0,0 +1,6 @@
#lang datalog/sexp
% path test from Chen & Warren
edge(a, b). edge(b, c). edge(c, d). edge(d, a).
path(X, Y) :- edge(X, Y).
path(X, Y) :- path(X, Z), edge(Z, Y).
path(X, Y)?

View File

@ -0,0 +1,17 @@
path(a, a).
path(a, d).
path(a, c).
path(a, b).
path(b, b).
path(b, a).
path(b, d).
path(b, c).
path(c, c).
path(c, b).
path(c, a).
path(c, d).
path(d, d).
path(d, c).
path(d, b).
path(d, a).

View File

@ -0,0 +1,5 @@
#lang datalog/sexp
tpme(tpme1).
ms(m1,'TPME',tpme1,ek,tp).
says(TPME,M) :- tpme(TPME),ms(M,'TPME',TPME,A,B).
says(A,B)?

View File

@ -0,0 +1 @@
says(tpme1, m1).

View File

@ -0,0 +1,3 @@
#lang datalog/sexp
(! true)
(? true)

View File

@ -0,0 +1 @@
true.

View File

@ -0,0 +1,28 @@
#lang datalog/sexp
(! (parent john douglas))
(? (parent john douglas))
(? (parent john ebbon))
(! (parent bob john))
(! (parent ebbon bob))
(? (parent ,A ,B))
(? (parent john ,B))
(? (parent ,A ,A))
(:- (ancestor ,A ,B)
(parent ,A ,B))
(:- (ancestor ,A ,B)
(parent ,A ,C)
(ancestor ,C ,B))
(? (ancestor ,A ,B))
(? (ancestor ,X john))
(~ (parent bob john))
(? (parent ,A ,B))
(? (ancestor ,A ,B))

View File

@ -0,0 +1,26 @@
parent(john, douglas).
parent(john, douglas).
parent(bob, john).
parent(ebbon, bob).
parent(john, douglas).
ancestor(ebbon, bob).
ancestor(bob, john).
ancestor(john, douglas).
ancestor(bob, douglas).
ancestor(ebbon, john).
ancestor(ebbon, douglas).
ancestor(bob, john).
ancestor(ebbon, john).
parent(john, douglas).
parent(ebbon, bob).
ancestor(ebbon, bob).
ancestor(john, douglas).