Mercurial > core / lisp/lib/q/tests/suite.lisp
changeset 698: |
96958d3eb5b0 |
parent: |
7ce855f76e1d
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 ;;; tests.lisp --- Q Tests 13 (is (make-instance 'query-engine 14 :parser (make-instance 'query-parser) 15 :optimizer (make-instance 'sql-optimizer) 18 (deftest sql-select () 19 (setf (gethash "FOO" tbl) (make-df nil)) 20 (with-sql (expr "SELECT I FROM FOO") 21 (is (typep expr 'sql-select)) 22 (let ((tbl (make-hash-table :test 'equalp))) 23 (is (gethash "FOO" tbl)) 24 (make-sql-data-frame expr tbl)))) 27 (with-sql (expr "1 + 2 * 3") 28 (is (typep expr 'sql-math-expression)) 29 (is (typep (rhs expr) 'sql-math-expression)) 30 (is (typep (lhs expr) 'sql-number)))) 32 ;; https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_1.html 33 (deftest dql (:skip t) 62 Exercise 2.9. Translate to clausal logic: 63 (a) every mouse has a tail; 64 (b) somebody loves everybody; 65 (c) every two numbers have a maximum. 67 (deftest dql-clausal-simple (:skip t)) 69 ;; ref: https://en.wikipedia.org/wiki/Zebra_Puzzle 71 ;; ref: https://franz.com/support/documentation/11.0/prolog.html 73 "A solution for the Zebra problem using DQL." 74 (<-- (nextto ?x ?y ?list) (iright ?x ?y ?list)) 75 (<- (nextto ?x ?y ?list) (iright ?y ?x ?list)) 76 (<-- (iright ?left ?right (?left ?right . ?rest))) 77 (<- (iright ?left ?right (?x . ?rest)) 78 (iright ?left ?right ?rest)) 80 ;; Each house is of the form: 81 ;; (house nationality pet cigarette drink house-color) 82 (= ?h ((house norwegian ? ? ? ?) ;1,10 84 (house ? ? ? milk ?) ? ?)) ; 9 85 (member (house englishman ? ? ? red) ?h) ; 2 86 (member (house spaniard dog ? ? ?) ?h) ; 3 87 (member (house ? ? ? coffee green) ?h) ; 4 88 (member (house ukrainian ? ? tea ?) ?h) ; 5 89 (iright (house ? ? ? ? ivory) ; 6 90 (house ? ? ? ? green) ?h) 91 (member (house ? snails winston ? ?) ?h) ; 7 92 (member (house ? ? kools ? yellow) ?h) ; 8 93 (nextto (house ? ? chesterfield ? ?) ;11 94 (house ? fox ? ? ?) ?h) 95 (nextto (house ? ? kools ? ?) ;12 96 (house ? horse ? ? ?) ?h) 97 (member (house ? ? luckystrike oj ?) ?h) ;13 98 (member (house japanese ? parliaments ? ?) ?h) ;14 99 (nextto (house norwegian ? ? ? ?) ;15 100 (house ? ? ? ? blue) ?h) 101 (member (house ?w ? ? water ?) ?h) ;Q1 102 (member (house ?z zebra ? ? ?) ?h)) ;Q2 104 (?- (zebra ?houses ?water-drinker ?zebra-owner)) 105 ;; It is believed that solving zebra a 106 ;; single time requires 12825 inferences.