Skip to content

Instantly share code, notes, and snippets.

@slyrus
Last active December 14, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slyrus/5071736 to your computer and use it in GitHub Desktop.
Save slyrus/5071736 to your computer and use it in GitHub Desktop.
this one fails
;;; Ok, here's a simple standalone test case that fails.
;;;
;;; NB: make sure you #-abcl the evaluate define-compiler-macro form in xpath/api.lisp
;;; in order to load xpath properly
;;;
;;; Then C-c C-k this form from slime and boom...
(defpackage :xpath-bug
(:use :cl))
(in-package :xpath-bug)
(defun my-evaluate-fn (xpath context &optional unordered-p)
(xpath::evaluate-compiled
(if (functionp xpath)
xpath
(xpath::compile-xpath xpath (xpath::make-dynamic-environment xpath::*dynamic-namespaces*)))
context
unordered-p))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun my-evaluate (xpath context &optional unordered-p)
(xpath::evaluate-compiled
(if (functionp xpath)
xpath
(xpath::compile-xpath xpath (xpath::make-dynamic-environment xpath::*dynamic-namespaces*)))
context
unordered-p))
(define-compiler-macro my-evaluate (xpath context &optional unordered-p)
(xpath::once-only (xpath)
`(xpath::evaluate-compiled
(if (functionp ,xpath)
,xpath
(xpath::with-cache ((,xpath :test equal)
(xpath::*dynamic-namespaces* :test xpath::namespaces-match-p)
(xpath::*profiling-enabled-p* :test eql))
(xpath::compile-xpath ,xpath
(xpath::make-dynamic-environment
xpath::*dynamic-namespaces*))))
,context
,unordered-p))))
(xpath:with-namespaces (("" ""))
(my-evaluate-fn "count(html/following::text())"
(cxml:parse-rod "<html></html>"
(cxml-dom:make-dom-builder))))
(xpath:with-namespaces (("" ""))
(my-evaluate "count(html/following::text())"
(cxml:parse-rod "<html></html>"
(cxml-dom:make-dom-builder))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment