Saving paren progress
This commit is contained in:
parent
a98547b033
commit
a9c32a62d4
|
@ -6,24 +6,26 @@
|
||||||
|
|
||||||
(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-txt (build-path examples-dir (format "~a.txt" t)))
|
|
||||||
(test-equal? t
|
|
||||||
(filter (lambda (l)
|
|
||||||
(not (string=? l "")))
|
|
||||||
(file->lines test-txt))
|
|
||||||
(filter (lambda (l)
|
|
||||||
(not (string=? l "")))
|
|
||||||
(with-input-from-string
|
|
||||||
(with-output-to-string
|
|
||||||
(lambda () (dynamic-require test-ss #f)))
|
|
||||||
port->lines))))
|
|
||||||
|
|
||||||
(define eval-tests
|
(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)))
|
||||||
|
(test-equal? t
|
||||||
|
(filter (lambda (l)
|
||||||
|
(not (string=? l "")))
|
||||||
|
(file->lines test-txt))
|
||||||
|
(filter (lambda (l)
|
||||||
|
(not (string=? l "")))
|
||||||
|
(with-input-from-string
|
||||||
|
(with-output-to-string
|
||||||
|
(lambda () (dynamic-require test-rkt #f)))
|
||||||
|
port->lines))))
|
||||||
|
|
||||||
(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"))))
|
12
collects/datalog/tests/paren-examples/ancestor.rkt
Normal file
12
collects/datalog/tests/paren-examples/ancestor.rkt
Normal 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)?
|
6
collects/datalog/tests/paren-examples/ancestor.txt
Normal file
6
collects/datalog/tests/paren-examples/ancestor.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
ancestor(ebbon, bob).
|
||||||
|
ancestor(bob, john).
|
||||||
|
ancestor(john, douglas).
|
||||||
|
ancestor(bob, douglas).
|
||||||
|
ancestor(ebbon, john).
|
||||||
|
ancestor(ebbon, douglas).
|
7
collects/datalog/tests/paren-examples/bidipath.rkt
Normal file
7
collects/datalog/tests/paren-examples/bidipath.rkt
Normal 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)?
|
17
collects/datalog/tests/paren-examples/bidipath.txt
Normal file
17
collects/datalog/tests/paren-examples/bidipath.txt
Normal 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).
|
||||||
|
|
12
collects/datalog/tests/paren-examples/laps.rkt
Normal file
12
collects/datalog/tests/paren-examples/laps.rkt
Normal 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)?
|
2
collects/datalog/tests/paren-examples/laps.txt
Normal file
2
collects/datalog/tests/paren-examples/laps.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
permit(rams, store, rams_couch).
|
||||||
|
permit(will, fetch, rams_couch).
|
8
collects/datalog/tests/paren-examples/long.rkt
Normal file
8
collects/datalog/tests/paren-examples/long.rkt
Normal 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?
|
1
collects/datalog/tests/paren-examples/long.txt
Normal file
1
collects/datalog/tests/paren-examples/long.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
this_is_a_long_identifier_and_tests_the_scanners_concat_when_read_with_a_small_buffer.
|
6
collects/datalog/tests/paren-examples/path.rkt
Normal file
6
collects/datalog/tests/paren-examples/path.rkt
Normal 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)?
|
17
collects/datalog/tests/paren-examples/path.txt
Normal file
17
collects/datalog/tests/paren-examples/path.txt
Normal 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).
|
||||||
|
|
6
collects/datalog/tests/paren-examples/pq.rkt
Normal file
6
collects/datalog/tests/paren-examples/pq.rkt
Normal 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)?
|
1
collects/datalog/tests/paren-examples/pq.txt
Normal file
1
collects/datalog/tests/paren-examples/pq.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
q(a).
|
6
collects/datalog/tests/paren-examples/revpath.rkt
Normal file
6
collects/datalog/tests/paren-examples/revpath.rkt
Normal 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)?
|
17
collects/datalog/tests/paren-examples/revpath.txt
Normal file
17
collects/datalog/tests/paren-examples/revpath.txt
Normal 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).
|
||||||
|
|
5
collects/datalog/tests/paren-examples/says.rkt
Normal file
5
collects/datalog/tests/paren-examples/says.rkt
Normal 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)?
|
1
collects/datalog/tests/paren-examples/says.txt
Normal file
1
collects/datalog/tests/paren-examples/says.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
says(tpme1, m1).
|
3
collects/datalog/tests/paren-examples/true.rkt
Normal file
3
collects/datalog/tests/paren-examples/true.rkt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#lang datalog/sexp
|
||||||
|
(! true)
|
||||||
|
(? true)
|
1
collects/datalog/tests/paren-examples/true.txt
Normal file
1
collects/datalog/tests/paren-examples/true.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
true.
|
28
collects/datalog/tests/paren-examples/tutorial.rkt
Normal file
28
collects/datalog/tests/paren-examples/tutorial.rkt
Normal 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))
|
26
collects/datalog/tests/paren-examples/tutorial.txt
Normal file
26
collects/datalog/tests/paren-examples/tutorial.txt
Normal 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).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user