From a9c32a62d4afe896c136cb7d30e311d37be6da2c Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Thu, 24 Jun 2010 16:10:28 -0600 Subject: [PATCH] Saving paren progress --- collects/datalog/tests/eval.rkt | 43 +++++++++++-------- .../datalog/tests/paren-examples/ancestor.rkt | 12 ++++++ .../datalog/tests/paren-examples/ancestor.txt | 6 +++ .../datalog/tests/paren-examples/bidipath.rkt | 7 +++ .../datalog/tests/paren-examples/bidipath.txt | 17 ++++++++ .../datalog/tests/paren-examples/laps.rkt | 12 ++++++ .../datalog/tests/paren-examples/laps.txt | 2 + .../datalog/tests/paren-examples/long.rkt | 8 ++++ .../datalog/tests/paren-examples/long.txt | 1 + .../datalog/tests/paren-examples/path.rkt | 6 +++ .../datalog/tests/paren-examples/path.txt | 17 ++++++++ collects/datalog/tests/paren-examples/pq.rkt | 6 +++ collects/datalog/tests/paren-examples/pq.txt | 1 + .../datalog/tests/paren-examples/revpath.rkt | 6 +++ .../datalog/tests/paren-examples/revpath.txt | 17 ++++++++ .../datalog/tests/paren-examples/says.rkt | 5 +++ .../datalog/tests/paren-examples/says.txt | 1 + .../datalog/tests/paren-examples/true.rkt | 3 ++ .../datalog/tests/paren-examples/true.txt | 1 + .../datalog/tests/paren-examples/tutorial.rkt | 28 ++++++++++++ .../datalog/tests/paren-examples/tutorial.txt | 26 +++++++++++ 21 files changed, 207 insertions(+), 18 deletions(-) create mode 100644 collects/datalog/tests/paren-examples/ancestor.rkt create mode 100644 collects/datalog/tests/paren-examples/ancestor.txt create mode 100644 collects/datalog/tests/paren-examples/bidipath.rkt create mode 100644 collects/datalog/tests/paren-examples/bidipath.txt create mode 100644 collects/datalog/tests/paren-examples/laps.rkt create mode 100644 collects/datalog/tests/paren-examples/laps.txt create mode 100644 collects/datalog/tests/paren-examples/long.rkt create mode 100644 collects/datalog/tests/paren-examples/long.txt create mode 100644 collects/datalog/tests/paren-examples/path.rkt create mode 100644 collects/datalog/tests/paren-examples/path.txt create mode 100644 collects/datalog/tests/paren-examples/pq.rkt create mode 100644 collects/datalog/tests/paren-examples/pq.txt create mode 100644 collects/datalog/tests/paren-examples/revpath.rkt create mode 100644 collects/datalog/tests/paren-examples/revpath.txt create mode 100644 collects/datalog/tests/paren-examples/says.rkt create mode 100644 collects/datalog/tests/paren-examples/says.txt create mode 100644 collects/datalog/tests/paren-examples/true.rkt create mode 100644 collects/datalog/tests/paren-examples/true.txt create mode 100644 collects/datalog/tests/paren-examples/tutorial.rkt create mode 100644 collects/datalog/tests/paren-examples/tutorial.txt diff --git a/collects/datalog/tests/eval.rkt b/collects/datalog/tests/eval.rkt index 6caa151cb1..360f5a2854 100644 --- a/collects/datalog/tests/eval.rkt +++ b/collects/datalog/tests/eval.rkt @@ -6,24 +6,26 @@ (provide eval-tests) -(define-runtime-path examples-dir "examples") -(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-runtime-path here ".") -(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 - "eval" + (path->string examples-dir) (test-example "ancestor") (test-example "bidipath") @@ -34,6 +36,11 @@ (test-example "revpath") (test-example "says") (test-example "true") - (test-example "tutorial") + (test-example "tutorial"))) + +(define eval-tests + (test-suite + "eval" - )) \ No newline at end of file + (test-examples (build-path here "examples")) + (test-examples (build-path here "paren-examples")))) \ No newline at end of file diff --git a/collects/datalog/tests/paren-examples/ancestor.rkt b/collects/datalog/tests/paren-examples/ancestor.rkt new file mode 100644 index 0000000000..f9b52b562c --- /dev/null +++ b/collects/datalog/tests/paren-examples/ancestor.rkt @@ -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)? \ No newline at end of file diff --git a/collects/datalog/tests/paren-examples/ancestor.txt b/collects/datalog/tests/paren-examples/ancestor.txt new file mode 100644 index 0000000000..bed107f84b --- /dev/null +++ b/collects/datalog/tests/paren-examples/ancestor.txt @@ -0,0 +1,6 @@ +ancestor(ebbon, bob). +ancestor(bob, john). +ancestor(john, douglas). +ancestor(bob, douglas). +ancestor(ebbon, john). +ancestor(ebbon, douglas). diff --git a/collects/datalog/tests/paren-examples/bidipath.rkt b/collects/datalog/tests/paren-examples/bidipath.rkt new file mode 100644 index 0000000000..a57fd01fde --- /dev/null +++ b/collects/datalog/tests/paren-examples/bidipath.rkt @@ -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)? diff --git a/collects/datalog/tests/paren-examples/bidipath.txt b/collects/datalog/tests/paren-examples/bidipath.txt new file mode 100644 index 0000000000..6c197dd6eb --- /dev/null +++ b/collects/datalog/tests/paren-examples/bidipath.txt @@ -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). + diff --git a/collects/datalog/tests/paren-examples/laps.rkt b/collects/datalog/tests/paren-examples/laps.rkt new file mode 100644 index 0000000000..45c631d4cb --- /dev/null +++ b/collects/datalog/tests/paren-examples/laps.rkt @@ -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)? diff --git a/collects/datalog/tests/paren-examples/laps.txt b/collects/datalog/tests/paren-examples/laps.txt new file mode 100644 index 0000000000..d87ea5fb54 --- /dev/null +++ b/collects/datalog/tests/paren-examples/laps.txt @@ -0,0 +1,2 @@ +permit(rams, store, rams_couch). +permit(will, fetch, rams_couch). diff --git a/collects/datalog/tests/paren-examples/long.rkt b/collects/datalog/tests/paren-examples/long.rkt new file mode 100644 index 0000000000..d2908dbec4 --- /dev/null +++ b/collects/datalog/tests/paren-examples/long.rkt @@ -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? diff --git a/collects/datalog/tests/paren-examples/long.txt b/collects/datalog/tests/paren-examples/long.txt new file mode 100644 index 0000000000..ebf5669da9 --- /dev/null +++ b/collects/datalog/tests/paren-examples/long.txt @@ -0,0 +1 @@ +this_is_a_long_identifier_and_tests_the_scanners_concat_when_read_with_a_small_buffer. diff --git a/collects/datalog/tests/paren-examples/path.rkt b/collects/datalog/tests/paren-examples/path.rkt new file mode 100644 index 0000000000..e24f03731b --- /dev/null +++ b/collects/datalog/tests/paren-examples/path.rkt @@ -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)? diff --git a/collects/datalog/tests/paren-examples/path.txt b/collects/datalog/tests/paren-examples/path.txt new file mode 100644 index 0000000000..cfe9daed0a --- /dev/null +++ b/collects/datalog/tests/paren-examples/path.txt @@ -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). + diff --git a/collects/datalog/tests/paren-examples/pq.rkt b/collects/datalog/tests/paren-examples/pq.rkt new file mode 100644 index 0000000000..bfc88d2665 --- /dev/null +++ b/collects/datalog/tests/paren-examples/pq.rkt @@ -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)? diff --git a/collects/datalog/tests/paren-examples/pq.txt b/collects/datalog/tests/paren-examples/pq.txt new file mode 100644 index 0000000000..7526e512b1 --- /dev/null +++ b/collects/datalog/tests/paren-examples/pq.txt @@ -0,0 +1 @@ +q(a). diff --git a/collects/datalog/tests/paren-examples/revpath.rkt b/collects/datalog/tests/paren-examples/revpath.rkt new file mode 100644 index 0000000000..741b28ac42 --- /dev/null +++ b/collects/datalog/tests/paren-examples/revpath.rkt @@ -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)? diff --git a/collects/datalog/tests/paren-examples/revpath.txt b/collects/datalog/tests/paren-examples/revpath.txt new file mode 100644 index 0000000000..6c197dd6eb --- /dev/null +++ b/collects/datalog/tests/paren-examples/revpath.txt @@ -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). + diff --git a/collects/datalog/tests/paren-examples/says.rkt b/collects/datalog/tests/paren-examples/says.rkt new file mode 100644 index 0000000000..cedc2fdc91 --- /dev/null +++ b/collects/datalog/tests/paren-examples/says.rkt @@ -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)? diff --git a/collects/datalog/tests/paren-examples/says.txt b/collects/datalog/tests/paren-examples/says.txt new file mode 100644 index 0000000000..473484aa10 --- /dev/null +++ b/collects/datalog/tests/paren-examples/says.txt @@ -0,0 +1 @@ +says(tpme1, m1). diff --git a/collects/datalog/tests/paren-examples/true.rkt b/collects/datalog/tests/paren-examples/true.rkt new file mode 100644 index 0000000000..0bce7f8cb7 --- /dev/null +++ b/collects/datalog/tests/paren-examples/true.rkt @@ -0,0 +1,3 @@ +#lang datalog/sexp +(! true) +(? true) diff --git a/collects/datalog/tests/paren-examples/true.txt b/collects/datalog/tests/paren-examples/true.txt new file mode 100644 index 0000000000..48eb7ed1a0 --- /dev/null +++ b/collects/datalog/tests/paren-examples/true.txt @@ -0,0 +1 @@ +true. diff --git a/collects/datalog/tests/paren-examples/tutorial.rkt b/collects/datalog/tests/paren-examples/tutorial.rkt new file mode 100644 index 0000000000..ddf0de3922 --- /dev/null +++ b/collects/datalog/tests/paren-examples/tutorial.rkt @@ -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)) diff --git a/collects/datalog/tests/paren-examples/tutorial.txt b/collects/datalog/tests/paren-examples/tutorial.txt new file mode 100644 index 0000000000..629d2dc725 --- /dev/null +++ b/collects/datalog/tests/paren-examples/tutorial.txt @@ -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). +