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

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

[nongnu] elpa/typescript-mode b6cd68ae77 177/222: Add test-cases for typ


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode b6cd68ae77 177/222: Add test-cases for type-highlights supported so far.
Date: Sun, 6 Feb 2022 16:59:30 -0500 (EST)

branch: elpa/typescript-mode
commit b6cd68ae7726f46a9a8716c023d0f1252537bcd8
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Add test-cases for type-highlights supported so far.
    
    Still missing: namespaced classes.
---
 typescript-mode-general-tests.el | 48 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index 368a7d5719..7fdb1bcc8d 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -464,6 +464,54 @@ function foo<Z, Y, Z & Y, Z | Y | Z, Y<X<X, Y>>>()\n"
       "type Thing = number;"
     (should (eq (get-face-at "Thing") 'font-lock-type-face))))
 
+(ert-deftest font-lock/type-names-level4 ()
+  "Typenames should be highlighted in declarations"
+
+  (test-with-fontified-buffer
+      "function test(var1: Type1, var2: Type2): RetType {\n}"
+    (should (not (eq (get-face-at "var1") 'font-lock-type-face)))
+    (should (eq (get-face-at "Type1") 'font-lock-type-face))
+    (should (not (eq (get-face-at "var2") 'font-lock-type-face)))
+    (should (eq (get-face-at "Type2") 'font-lock-type-face))
+    (should (eq (get-face-at "RetType") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "class foo { test(var1: Type1, var2: Type2): RetType {\n} }"
+    (should (not (eq (get-face-at "var1") 'font-lock-type-face)))
+    (should (eq (get-face-at "Type1") 'font-lock-type-face))
+    (should (not (eq (get-face-at "var2") 'font-lock-type-face)))
+    (should (eq (get-face-at "Type2") 'font-lock-type-face))
+    (should (eq (get-face-at "RetType") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "let a: SomeType;"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face)))
+  (test-with-fontified-buffer
+      "private b: SomeType;"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face)))
+  (test-with-fontified-buffer
+      "private someArray: SomeType[];"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face)))
+  (test-with-fontified-buffer
+      "private generic: SomeType<Foo>;"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
+    (should (eq (get-face-at "Foo") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "private genericArray: SomeType<Foo>[];"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
+    (should (eq (get-face-at "Foo") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "private genericArray2: SomeType<Foo[]>;"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
+    (should (eq (get-face-at "Foo") 'font-lock-type-face)))
+
+  (test-with-fontified-buffer
+      "private genericArray3: SomeType<Foo[]>[];"
+    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
+    (should (eq (get-face-at "Foo") 'font-lock-type-face))))
+
 (defun flyspell-predicate-test (search-for)
   "This function runs a test on
 `typescript--flyspell-mode-predicate'.  `SEARCH-FOR' is a string



reply via email to

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