]> code.delx.au - gnu-emacs-elpa/blobdiff - tests/parser.el
(Hopefully) fix #117 and capitaomorte/autopair#21
[gnu-emacs-elpa] / tests / parser.el
index 0a076e12d3c1a0f966b41cddb8bf453231d6d29b..b84265ebe4fcf1196182910e32d736df6d90f135 100644 (file)
@@ -85,7 +85,7 @@ the test."
 (js2-deftest-parse named-function-expression\r
   "a = function b() {};")\r
 \r
-;;; Callers of `js2-valid-prop-name-token'.\r
+;;; Callers of `js2-valid-prop-name-token'\r
 \r
 (js2-deftest-parse parse-property-access-when-not-keyword\r
   "A.foo = 3;")\r
@@ -106,7 +106,7 @@ the test."
   "a = {in: 1};"\r
   :bind ((js2-allow-keywords-as-property-names t)))\r
 \r
-;;; 'of' contextual keyword.\r
+;;; 'of' contextual keyword\r
 \r
 (js2-deftest-parse parse-array-comp-loop-with-of\r
   "[a for (a of [])];")\r
@@ -120,7 +120,7 @@ the test."
 (js2-deftest-parse of-can-be-function-name\r
   "function of() {\n}")\r
 \r
-;;; Destructuring binding.\r
+;;; Destructuring binding\r
 \r
 (js2-deftest-parse destruct-in-declaration\r
   "var {a, b} = {a: 1, b: 2};")\r
@@ -134,7 +134,7 @@ the test."
 (js2-deftest-parse destruct-in-catch-clause\r
   "try {\n} catch ({a, b}) {\n  a + b;\n}")\r
 \r
-;;; Function parameters.\r
+;;; Function parameters\r
 \r
 (js2-deftest-parse function-with-default-parameters\r
   "function foo(a = 1, b = a + 1) {\n}")\r
@@ -161,7 +161,7 @@ the test."
 (js2-deftest-parse function-with-rest-after-default-parameter\r
   "function foo(a = 1, ...rest) {\n}")\r
 \r
-;;; Arrow functions.\r
+;;; Arrow functions\r
 \r
 (js2-deftest-parse arrow-function-with-empty-args-and-no-curlies\r
   "() => false;" :reference "() => {false};")\r
@@ -175,7 +175,7 @@ the test."
 (js2-deftest-parse parenless-arrow-function-prohibits-destructuring\r
   "[a, b] => {a + b;};" :syntax-error "]" :errors-count 5)\r
 \r
-;;; Automatic semicolon insertion.\r
+;;; Automatic semicolon insertion\r
 \r
 (js2-deftest-parse no-auto-semi-insertion-after-if\r
   "if (true) {\n}")\r
@@ -243,3 +243,14 @@ the test."
     (should (eq js2-NUMBER (js2-next-token)))\r
     (should (eq 1 (js2-token-number\r
                    (js2-current-token))))))\r
+\r
+;;; Error handling\r
+\r
+(js2-deftest for-node-with-error-len "for "\r
+  (js2-mode)\r
+  (let ((node (js2-node-at-point (point-min))))\r
+    (should (= (js2-node-len (js2-node-parent node)) 4))))\r
+\r
+(js2-deftest function-without-parens-error "function b {}"\r
+  ;; Should finish the parse.\r
+  (js2-mode))\r