[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a5b586f 13/33: Test const scoping.
From: |
Dmitry Gutov |
Subject: |
[elpa] master a5b586f 13/33: Test const scoping. |
Date: |
Sun, 12 Jul 2015 22:35:38 +0000 |
branch: master
commit a5b586f22dace6436d133ba48a602203f485b9d6
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Test const scoping.
---
tests/parser.el | 37 +++++++++++++++++++++++++++++--------
1 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/tests/parser.el b/tests/parser.el
index 1a93f36..8be0833 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -721,19 +721,40 @@ the test."
(should (= (js2-symbol-decl-type var-entry) js2-VAR))
(should (js2-name-node-p (js2-symbol-ast-node var-entry)))))
-(js2-deftest for-node-is-declaration-scope "for (let i = 0; i; ++i) {};"
- (js2-mode)
- (search-forward "i")
+(defun js2-test-scope-of-nth-variable-satisifies-predicate (variable nth
predicate)
+ (goto-char (point-min))
+ (dotimes (n (1+ nth)) (search-forward variable))
(forward-char -1)
(let ((scope (js2-node-get-enclosing-scope (js2-node-at-point))))
- (should (js2-for-node-p (js2-get-defining-scope scope "i")))))
+ (should (funcall predicate (js2-get-defining-scope scope variable)))))
+
+(js2-deftest for-node-is-declaration-scope "for (let i = 0; i; ++i) {};"
+ (js2-mode)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "i" 0 #'js2-for-node-p))
+
+(js2-deftest const-scope-sloppy-script "{const a;} a;"
+ (js2-mode)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-script-node-p)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 1
#'js2-script-node-p))
+
+(js2-deftest const-scope-strict-script "'use strict'; { const a; } a;"
+ (js2-mode)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-block-node-p)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 1 #'null))
+
+(js2-deftest const-scope-sloppy-function "function f() { { const a; } a; }"
+ (js2-mode)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-function-node-p)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 1
#'js2-function-node-p))
+
+(js2-deftest const-scope-strict-function "function f() { 'use strict'; { const
a; } a; }"
+ (js2-mode)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 0
#'js2-block-node-p)
+ (js2-test-scope-of-nth-variable-satisifies-predicate "a" 1 #'null))
(js2-deftest array-comp-is-result-scope "[x * 2 for (x in y)];"
(js2-mode)
- (search-forward "x")
- (forward-char -1)
- (let ((scope (js2-node-get-enclosing-scope (js2-node-at-point))))
- (should (js2-comp-loop-node-p (js2-get-defining-scope scope "x")))))
+ (js2-test-scope-of-nth-variable-satisifies-predicate "x" 0
#'js2-comp-loop-node-p))
(js2-deftest array-comp-has-parent-scope
"var a,b=[for (i of [[1,2]]) for (j of i) j * a];"
- [elpa] master 6d4aa28 03/33: Don't unset `js2-recorded-identifiers', (continued)
- [elpa] master 6d4aa28 03/33: Don't unset `js2-recorded-identifiers', Dmitry Gutov, 2015/07/12
- [elpa] master 709ff60 05/33: Add a NEWS entry for d4d9c54, Dmitry Gutov, 2015/07/12
- [elpa] master a632b02 04/33: Merge pull request #232 from jacksonrayhamilton/unset-identifiers, Dmitry Gutov, 2015/07/12
- [elpa] master d6e6cd6 06/33: Fix object keys highlighting (closes #234), Dmitry Gutov, 2015/07/12
- [elpa] master 422be2d 08/33: Add NEWS entry, Dmitry Gutov, 2015/07/12
- [elpa] master c13eda4 01/33: Generalize object literal parsing to support short-hand function/generator/getter/setter declarations with all kinds of keys (string, named, computed, numeric)., Dmitry Gutov, 2015/07/12
- [elpa] master 09a86b2 09/33: js2-node-externs: Add querystring, Dmitry Gutov, 2015/07/12
- [elpa] master 7c423dd 10/33: Define const variables in the current block., Dmitry Gutov, 2015/07/12
- [elpa] master d39764f 02/33: Merge pull request #231 from shicks/computed, Dmitry Gutov, 2015/07/12
- [elpa] master 88d7565 11/33: Respect strict mode., Dmitry Gutov, 2015/07/12
- [elpa] master a5b586f 13/33: Test const scoping.,
Dmitry Gutov <=
- [elpa] master 254c78c 07/33: Highlight unused and/or uninitialized variables, Dmitry Gutov, 2015/07/12
- [elpa] master 1277c7d 12/33: Track script and function strict mode., Dmitry Gutov, 2015/07/12
- [elpa] master 498bcca 21/33: Fix refactoring regression., Dmitry Gutov, 2015/07/12
- [elpa] master 663efb1 24/33: Remove strict mode slots on nodes., Dmitry Gutov, 2015/07/12
- [elpa] master 6255edb 18/33: Cleanup, Dmitry Gutov, 2015/07/12
- [elpa] master ad4c5cc 20/33: Report the correct octal number error, Dmitry Gutov, 2015/07/12
- [elpa] master ac205a4 16/33: Octal syntax is an error in strict mode, Dmitry Gutov, 2015/07/12
- [elpa] master 7850d12 25/33: Cleanup, Dmitry Gutov, 2015/07/12
- [elpa] master e6cb7bf 15/33: with statements are syntax errors in strict mode, Dmitry Gutov, 2015/07/12
- [elpa] master 46e1492 23/33: Reparse strict functions., Dmitry Gutov, 2015/07/12