Modified Files:
Wed Apr 15 10:24:28 UTC 2009 mantoniotti
* Modified Files:
Modified Files:
test/unification-tests.lisp
Added Files:
lib-dependent/cl-ppcre-template.lisp
The cl-ppcre-template reuses E. Weitz's wonderful CL-PPCRE library
to provide a seamless (YMMV) reuse of regular expressions within
CL-UNIFICATION.
hunk ./lib-dependent/cl-ppcre-template.lisp 8
+(require "CL-PPCRE")
+
hunk ./lib-dependent/cl-ppcre-template.lisp 125
+ (multiple-value-bind (m-start m-end r-starts r-ends)
+ (cl-ppcre:scan (scanner re-t) s :start start :end end)
+ ;; Maybe SCAN-TO-STRINGS would be simpler to use...
hunk ./lib-dependent/cl-ppcre-template.lisp 129
- (multiple-value-bind (matched-p strings)
- (cl-ppcre:scan-to-strings (scanner re-t) s :start start :end end)
- (unless matched-p
+ (declare (type (integer 0 #.most-positive-fixnum) m-start m-end)
+ (type (vector (integer 0 #.most-positive-fixnum)) r-starts r-ends))
+ (unless (and (= start m-start) (= m-end end))
hunk ./lib-dependent/cl-ppcre-template.lisp 140
- (loop for r-string of-type string across strings
+ (loop for r-start across r-starts
+ for r-end across r-ends
+ for r-string of-type string = (subseq s r-start r-end)
hunk ./test/unification-tests.lisp 6
+(in-package "UNIFY.TESTS")
+
hunk ./test/unification-tests.lisp 113
+(defstruct s-root a)
+(defstruct (s-child (:include s-root)) b)
+
hunk ./test/unification-tests.lisp 122
- (test '(#\f T) (ignore-errors (v? '?x (unify "asdfasdfasdf" #T(elt 3 ?x))))
- :multiple-values t
- :known-failure t
- :fail-info "ELT templates must be fixed.")
+ (test '(#\Space T) (ignore-errors (v? '?x (unify "This is a string!" #T(elt 4 ?x))))
+ :multiple-values t)
+
+ (test '(42 T) (ignore-errors (v? '?x (unify '(0 1 42 3 4 5) #T(nth 2 ?x))))
+ :multiple-values t)
+
+ (test '(42 T) (ignore-errors (v? '?x (unify '(0 1 42 3 4 5) #T(elt 2 ?x))))
+ :multiple-values t)
+
+ (test '(42 T) (ignore-errors (v? '?x (unify #(0 1 42 3 4 5) #T(aref 2 ?x))))
+ :multiple-values t)
+
+ (test '(42 T) (ignore-errors (v? '?x (unify #(0 1 42 3 4 5) #T(elt 2 ?x))))
+ :multiple-values t)
+
+ (test '(42 T) (v? '?x (unify #2a((0 1 42 3 4 5)) #T(aref (0 2) ?x)))
+ :multiple-values t)
+
+ (test '(42 T) (v? '?x (unify #T(aref (0 2) 42) #2a((0 1 ?x 3 4 5))))
+ :multiple-values t)
+
+ (test '(42 T) (v? '?x (unify #2a((0 1 ?x 3 4 5)) #T(aref (0 2) 42)))
+ :multiple-values t)
+
+ (test-error (unify #(0 1 42 3 4 5) #T(nth 2 ?x))
+ :condition-type 'unification-failure
+ :announce t)
hunk ./test/unification-tests.lisp 150
- (test '(42 T) (ignore-errors (v? 'x (unify '(0 1 42 3 4 5) #T(nth 2 ?x))))
- :multiple-values t
- :known-failure t
- :fail-info "NTH templates must be fixed.")
+ (test '(foo (1) (2) (3)) (let ((result-env (unify '(0 1 #T(list foo _ &rest ?z) 42)
+ '(0 1 (?y bar (1) (2) (3)) 42)))
+ )
+ (cons (v? '?y result-env)
+ (v? '?z result-env)))
+ :test #'equal)
hunk ./test/unification-tests.lisp 158
- (make-instance 'test1 :a '(1 2 3) :b "woot")))
+ (make-instance 'test1 :a '(1 2 3) :b "woot")))
+ :multiple-values t)
+
+ (test-error (unify #T(s-root s-root-a '(1 ?x 3 4))
+ (make-s-root :a '(1 2 3 4)))
+ :condition-type 'unification-failure
+ :announce t
+ ;; #T reader non evaluating sub forms.
+ )
+
+ (test '(2 T) (v? '?x (unify #T(s-root s-root-a #T(list 1 ?x 3 4))
+ (make-s-root :a '(1 2 3 4))))
+ :multiple-values t)
+
+ (test '(2 T) (v? '?x (unify #T(s-root s-root-a (1 ?x 3 4))
+ (make-s-root :a '(1 2 3 4))))
+ :multiple-values t)
+
+ (test '(2 T) (v? '?x (unify #T(s-root s-root-a #T(list 1 ?x 3 &rest))
+ (make-s-root :a '(1 2 3 4))))
+ :multiple-values t)
+
+ (test '(2 T) (v? '?x (unify #T(s-root s-root-a #(1 ?x 3 4))
+ (make-s-root :a #(1 2 3 4))))
+ :multiple-values t)
+
+ (test '(2 T) (v? '?x (unify #T(s-root s-root-a #T(vector 1 ?x 3 &rest))
+ (make-s-root :a #(1 2 3 4))))
hunk ./test/unification-tests.lisp 199
- (otherwise "error-outer")))
+ (otherwise (error "error-outer"))))
hunk ./test/unification-tests.lisp 202
- (test "error-outer" (nested-match-cases '(:a 42 :b 33)) :test 'string=)
+ (test-error (nested-match-cases '(:a 42 :b 33)) :announce t)
+
+ (test-error (nested-match-cases '(:a 42 :b (33 42))) :announce t)
hunk ./test/unification-tests.lisp 206
+ (test '(42 43 44) (nested-match-cases '(:a 42 :b ((:d 42) (:c 43) (:c 44))))
+ :test #'equal)