[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 84bab53b7a 05/10: test(fontlock): update t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 84bab53b7a 05/10: test(fontlock): update tests related to arglist fontification |
Date: |
Sat, 30 Jul 2022 06:59:04 -0400 (EDT) |
branch: elpa/typescript-mode
commit 84bab53b7a53ec2a5ff03794336f526c3c6768aa
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
test(fontlock): update tests related to arglist fontification
---
typescript-mode-general-tests.el | 191 +++++++++++++++++++++++++++++++++++----
1 file changed, 174 insertions(+), 17 deletions(-)
diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 9c1102b915..493d23727a 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -358,7 +358,7 @@ declare function declareFunctionDefn(x3: xty3, y3: yty3):
ret3;"
("exportedDefaultDefn" . font-lock-function-name-face)
("declareFunctionDefn" . font-lock-function-name-face)
(("x0" "x1" "x2" "x3") . font-lock-variable-name-face)
- (("y0" "y1" "y2" "y3") . font-lock-variable-name-face)
+ (("\\by0" "\\by1" "\\by2" "\\by3") . font-lock-variable-name-face)
(("ret0" "ret1" "ret2" "ret3") . nil))))
(ert-deftest font-lock/level-four ()
@@ -380,7 +380,7 @@ snake_cased_function(1, 2, 3)"
("methodCall" . font-lock-function-name-face)
("snake_cased_function" . font-lock-function-name-face)
(("string" "boolean" "number" "any") . typescript-primitive-face)
- (("endpoint" "data") . nil)
+ (("endpoint" "data") . font-lock-variable-name-face)
(("<" ">" ",") . nil))))
(ert-deftest font-lock/generics ()
@@ -593,19 +593,24 @@ should be fontified as variable, keyword and type."
(should (eq (get-face-at "Namespaced") 'font-lock-type-face))
(should (eq (get-face-at "ClassName") 'font-lock-type-face))))
-(ert-deftest font-lock/variables-in-declaration-multiline-with-types ()
+(ert-deftest font-lock/funargs--function--multiline-with-types ()
"Variables should be highlighted in multiline declarations with types."
(test-with-fontified-buffer
"function test(
-var1: Type1,
-var2: Type2,
+var1: Promise<U1, V1>,
+var2: (xxx: Foo) => Bar,
+var3: Type3,
): RetType {\n}"
(should (eq (get-face-at "var1") 'font-lock-variable-name-face))
(should (eq (get-face-at "var2") 'font-lock-variable-name-face))
- (should (eq (get-face-at "Type1") 'font-lock-type-face))
- (should (eq (get-face-at "Type2") 'font-lock-type-face))))
+ (should (eq (get-face-at "var3") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "xxx") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "Promise") 'font-lock-type-face))
+ (should (eq (get-face-at "U1") 'font-lock-type-face))
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Type3") 'font-lock-type-face))))
-(ert-deftest font-lock/variables-in-declaration-multiline-without-types ()
+(ert-deftest font-lock/funargs--function--multiline-without-types ()
"Variables should be highlighted in multiline declarations without types."
(test-with-fontified-buffer
"function test(
@@ -615,8 +620,8 @@ var2,
(should (eq (get-face-at "var1") 'font-lock-variable-name-face))
(should (eq (get-face-at "var2") 'font-lock-variable-name-face))))
-(ert-deftest font-lock/variables-in-declaration-multiline-no-hanging-paren ()
- "Variables should be highlighted in multiline declarations with no hanging
paren."
+(ert-deftest font-lock/funargs--function--multiline-hanging-paren ()
+ "Variables should be highlighted in multiline declarations with hanging
paren."
(test-with-fontified-buffer
"function test(
var1,
@@ -624,8 +629,8 @@ var2): RetType {\n}"
(should (eq (get-face-at "var1") 'font-lock-variable-name-face))
(should (eq (get-face-at "var2") 'font-lock-variable-name-face))))
-(ert-deftest
font-lock/variables-in-declaration-multiline-ending-comma-no-hanging-paren ()
- "Variables should be highlighted in multiline declarations with no hanging
paren and trailing comma."
+(ert-deftest font-lock/funargs--function--multiline-ending-comma-hanging-paren
()
+ "Variables should be highlighted in multiline declarations with hanging
paren and trailing comma."
(test-with-fontified-buffer
"function test(
var1,
@@ -633,15 +638,15 @@ var2,): RetType {\n}"
(should (eq (get-face-at "var1") 'font-lock-variable-name-face))
(should (eq (get-face-at "var2") 'font-lock-variable-name-face))))
-(ert-deftest
font-lock/variables-in-declaration-singleline-ending-comma-hanging-paren ()
- "Variables should be highlighted in singleline declarations with hanging
paren and trailing comma."
+(ert-deftest
font-lock/funargs--function--singleline-ending-comma-no-hanging-paren ()
+ "Variables should be highlighted in singleline declarations with no hanging
paren and trailing comma."
(test-with-fontified-buffer
"function test(var1,var2,
): RetType {\n}"
(should (eq (get-face-at "var1") 'font-lock-variable-name-face))
(should (eq (get-face-at "var2") 'font-lock-variable-name-face))))
-(ert-deftest font-lock/variables-in-declaration-singleline-with-types ()
+(ert-deftest font-lock/funargs--function--singleline-with-types ()
"Variables should be highlighted in singleline declarations with types."
(test-with-fontified-buffer
"function test(var1: Foo, var2: Bar,): RetType {\n}"
@@ -650,13 +655,165 @@ var2,): RetType {\n}"
(should (eq (get-face-at "Foo") 'font-lock-type-face))
(should (eq (get-face-at "Bar") 'font-lock-type-face))))
-(ert-deftest
font-lock/variables-in-declaration-singleline-ending-comma-no-hanging-paren ()
- "Variables should be highlighted in singleline declarations with no hanging
paren and trailing comma."
+(ert-deftest
font-lock/funargs--function--singleline-ending-comma-hanging-paren ()
+ "Variables should be highlighted in singleline declarations with hanging
paren and trailing comma."
(test-with-fontified-buffer
"function test(var1,var2,): RetType {\n}"
(should (eq (get-face-at "var1") 'font-lock-variable-name-face))
(should (eq (get-face-at "var2") 'font-lock-variable-name-face))))
+(ert-deftest font-lock/funargs--function--keywords-as-variables ()
+ "Keywords when used as variables should have variable face"
+ (test-with-fontified-buffer
+ "function test(type, unknown): void {}"
+ (should (eq (get-face-at "type") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "unknown") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--keywords-as-variables ()
+ "Keywords when used as variables should have variable face"
+ (test-with-fontified-buffer
+ "const test = (type, unknown): void => {}"
+ (should (eq (get-face-at "type") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "unknown") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--single-line--no-type ()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb, ccc): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--single-line--no-type--no-return-type ()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb, ccc) => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--single-line--no-type--trailing-comma ()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb, ccc,): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--single-line--no-type--optional ()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb?): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb?") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--multiline--no-type ()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb,
+ccc, ddd): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--multiline--no-type--newline-after-last
()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb,
+ccc, ddd
+): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))
+
+(ert-deftest
font-lock/funargs--arrow--multiline--no-type--newline-before-first ()
+ (test-with-fontified-buffer
+ "const test = (
+aaa, bbb,
+ccc, ddd
+): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--arrow--multiline--no-type--with-comment ()
+ (test-with-fontified-buffer
+ "const test = (
+aaa, bbb, // comment
+ccc, ddd // comment
+): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))
+
+(ert-deftest
font-lock/funargs--arrow--single--mixed-type--newline-before-first ()
+ (test-with-fontified-buffer
+ "const test = (aaa, bbb: Promise, ccc: number, ddd): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "Promise") 'font-lock-type-face))
+ (should (eq (get-face-at "number") 'typescript-primitive-face))))
+
+(ert-deftest font-lock/funargs--arrow--single--with-type--complex-type ()
+ (test-with-fontified-buffer
+ "const test = (aaa: Promise<U, V, (xxx: A) => Foo>, bbb): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "xxx") 'font-lock-variable-name-face))))
+
+(ert-deftest
font-lock/funargs--arrow--multiline--with-type--newline-before-first-after-last
()
+ (test-with-fontified-buffer
+ "const test = (
+aaa: Foo,
+bbb: Bar
+): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))))
+
+(ert-deftest
font-lock/funargs--arrow--multiline--with-type--newline-before-first-after-last--hanging-comma
()
+ (test-with-fontified-buffer
+ "const test = (
+aaa: Foo,
+bbb: Bar,
+): void => {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))))
+
+(ert-deftest font-lock/funargs--method--multiline--with-type ()
+ (test-with-fontified-buffer
+ "class Foo { foo(
+aaa: Foo,
+bbb: Bar,
+): void {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))))
+
+(ert-deftest font-lock/funargs--method--single-line--with-type ()
+ (test-with-fontified-buffer
+ "class Foo { foo(aaa: Foo,bbb: Bar,): void {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "Foo") 'font-lock-type-face))
+ (should (eq (get-face-at "Bar") 'font-lock-type-face))))
+
+(ert-deftest font-lock/funargs--method--single-line--no-type ()
+ (test-with-fontified-buffer
+ "class Foo { foo(aaa, bbb): void {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))))
+
+(ert-deftest font-lock/funargs--method--single-line--no-return-type ()
+ (test-with-fontified-buffer
+ "class Foo { foo(aaa, bbb) {}"
+ (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
+ (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))))
+
(defun flyspell-predicate-test (search-for)
"This function runs a test on
`typescript--flyspell-mode-predicate'. `SEARCH-FOR' is a string
- [nongnu] elpa/typescript-mode updated (83bf47e406 -> acd8d79952), ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode d21c9837cb 04/10: feat(fontlock): fontify arrow fn arguments, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode 84bab53b7a 05/10: test(fontlock): update tests related to arglist fontification,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode acd8d79952 10/10: Merge pull request #170 from Fuco1/feature/fontify-arrow-fn-args, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode 93e1040ea9 01/10: feat(tests): use font-lock-ensure instead of font-lock-fontify-buffer, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode e5704af123 09/10: Merge pull request #171 from Fuco1/bugfix/fontify-return-type-function-type, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode ec2c4c11fc 08/10: Merge pull request #172 from Fuco1/fix/keywords-method-calls, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode 367cfb70f5 02/10: fix(fontlock): do not fontify function calls as keywords, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode 9bd226b386 06/10: fix(fontlock): do not fontify builtins in object/interface key context, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode ba047458dd 03/10: fix(fontlock): fontify return type in a function type definition, ELPA Syncer, 2022/07/30
- [nongnu] elpa/typescript-mode 35f01b3aeb 07/10: Merge pull request #173 from Fuco1/fix/keywords-in-interfaces, ELPA Syncer, 2022/07/30