]> code.delx.au - gnu-emacs/blobdiff - test/automated/libxml-tests.el
Update copyright year to 2016
[gnu-emacs] / test / automated / libxml-tests.el
index ced0df7b3c42444dd4593406ee70f35bef7fe25b..dc60197b59ed8a27384bb598c75510ae6c95d49f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; libxml-parse-tests.el --- Test suite for libxml parsing.
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
 
 ;; Author: Ulf Jasper <ulf.jasper@web.de>
 ;; Keywords:       internal
@@ -27,7 +27,7 @@
 
 (require 'ert)
 
-(defvar libxml-tests--data
+(defvar libxml-tests--data-comments-preserved
   `(;; simple case
     ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>"
      . (foo ((baz . "true")) "bar"))
              "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->")
      . (top nil (comment nil "comment-a") (foo ((a . "b")) (bar nil "blub"))
             (comment nil "comment-b") (comment nil "comment-c"))))
-  "Alist of XML strings and their expected parse trees.")
+  "Alist of XML strings and their expected parse trees for preserved comments.")
+
+(defvar libxml-tests--data-comments-discarded
+  `(;; simple case
+    ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>"
+     . (foo ((baz . "true")) "bar"))
+    ;; toplevel comments -- first document child must not get lost
+    (,(concat "<?xml version=\"1.0\"?><foo>bar</foo><!--comment-1-->"
+             "<!--comment-2-->")
+     . (foo nil "bar"))
+    (,(concat "<?xml version=\"1.0\"?><!--comment-a--><foo a=\"b\">"
+             "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->")
+     . (foo ((a . "b")) (bar nil "blub"))))
+  "Alist of XML strings and their expected parse trees for discarded comments.")
 
 
 (ert-deftest libxml-tests ()
   "Test libxml."
   (when (fboundp 'libxml-parse-xml-region)
     (with-temp-buffer
-      (dolist (test libxml-tests--data)
+      (dolist (test libxml-tests--data-comments-preserved)
+        (erase-buffer)
+        (insert (car test))
+        (should (equal (cdr test)
+                       (libxml-parse-xml-region (point-min) (point-max)))))
+      (dolist (test libxml-tests--data-comments-discarded)
         (erase-buffer)
         (insert (car test))
         (should (equal (cdr test)
-                       (libxml-parse-xml-region (point-min) (point-max))))))))
+                       (libxml-parse-xml-region (point-min) (point-max) nil t)))))))
 
 ;;; libxml-tests.el ends here