emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 3f09ff3 09/45: Fix string literals in parser.el test harne


From: Dmitry Gutov
Subject: [elpa] master 3f09ff3 09/45: Fix string literals in parser.el test harness.
Date: Mon, 02 Feb 2015 03:18:35 +0000

branch: master
commit 3f09ff32e92e709214b0241083489a5d92e8f02f
Author: Stephen Hicks <address@hidden>
Commit: Stephen Hicks <address@hidden>

    Fix string literals in parser.el test harness.
    
    Previously all string literals in tests would fail, because they referred 
to a temporary buffer that no longer exists.  This fix works around this by 
extending the life of the temporary input buffer.
---
 tests/parser.el |   46 +++++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/tests/parser.el b/tests/parser.el
index 8d2cf70..d986ffc 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -36,28 +36,28 @@
 (put 'js2-deftest 'lisp-indent-function 'defun)
 
 (defun js2-test-string-to-ast (s)
-  (ert-with-test-buffer (:name 'origin)
-    (insert s)
-    (js2-mode)
-    (should (null js2-mode-buffer-dirty-p))
-    js2-mode-ast))
+  (insert s)
+  (js2-mode)
+  (should (null js2-mode-buffer-dirty-p))
+  js2-mode-ast)
 
 (defun* js2-test-parse-string (code-string &key syntax-error errors-count
                                                 reference)
-  (let ((ast (js2-test-string-to-ast code-string)))
-    (if syntax-error
-        (let ((errors (js2-ast-root-errors ast)))
-          (should (= (or errors-count 1) (length errors)))
-          (destructuring-bind (_ pos len) (first errors)
-            (should (string= syntax-error (substring code-string
-                                                     (1- pos) (+ pos len 
-1))))))
-      (should (= 0 (length (js2-ast-root-errors ast))))
-      (ert-with-test-buffer (:name 'copy)
-        (js2-print-tree ast)
-        (skip-chars-backward " \t\n")
-        (should (string= (or reference code-string)
-                         (buffer-substring-no-properties
-                          (point-min) (point))))))))
+  (ert-with-test-buffer (:name 'origin)
+    (let ((ast (js2-test-string-to-ast code-string)))
+      (if syntax-error
+          (let ((errors (js2-ast-root-errors ast)))
+            (should (= (or errors-count 1) (length errors)))
+            (destructuring-bind (_ pos len) (first errors)
+              (should (string= syntax-error (substring code-string
+                                                       (1- pos) (+ pos len 
-1))))))
+        (should (= 0 (length (js2-ast-root-errors ast))))
+        (ert-with-test-buffer (:name 'copy)
+          (js2-print-tree ast)
+          (skip-chars-backward " \t\n")
+          (should (string= (or reference code-string)
+                           (buffer-substring-no-properties
+                            (point-min) (point)))))))))
 
 (defmacro* js2-deftest-parse (name code-string &key bind syntax-error 
errors-count
                                                     reference)
@@ -332,6 +332,14 @@ the test."
 (js2-deftest-parse octal-number-broken "0o812;"
   :syntax-error "0o8" :errors-count 2)
 
+;;; Strings
+
+(js2-deftest-parse string-literal
+  "var x = 'y';")
+
+(js2-deftest-parse object-get-string-literal
+  "var x = {y: 5};\nvar z = x[\"y\"];")
+
 ;;; Classes
 
 (js2-deftest-parse parse-harmony-class-statement



reply via email to

[Prev in Thread] Current Thread [Next in Thread]