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

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

[nongnu] elpa/typescript-mode ae32e1c28f 193/222: Use ‘insert-file-cont


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode ae32e1c28f 193/222: Use ‘insert-file-contents’ instead of ‘find-file’ for tests.
Date: Sun, 6 Feb 2022 16:59:32 -0500 (EST)

branch: elpa/typescript-mode
commit ae32e1c28f6dfb4ea2e56c770e4c944f0ee247f2
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    Use ‘insert-file-contents’ instead of ‘find-file’ for tests.
    
    ‘find-file’ doesn’t signal errors if visiting the file failed and is 
therefore
    more brittle.  Also it makes the file buffer readonly if the visited file is
    readonly, causing tests to fail if the testfiles are readonly.
---
 typescript-mode-general-tests.el | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/typescript-mode-general-tests.el b/typescript-mode-general-tests.el
index d9def0a2f6..3ccdb0539f 100644
--- a/typescript-mode-general-tests.el
+++ b/typescript-mode-general-tests.el
@@ -19,7 +19,8 @@
   (untabify (point-min) (point-max)))
 
 (ert-deftest indentation-reference-document-is-reflowed-correctly ()
-  (let ((buffer (find-file "test-files/indentation-reference-document.ts")))
+  (with-temp-buffer
+    (insert-file-contents "test-files/indentation-reference-document.ts")
     ;; double ensure mode is active
     (typescript-mode)
 
@@ -30,61 +31,60 @@
       (let ((typescript-indent-switch-clauses nil))
         (typescript-test-indent-all)
         (should (string-equal test-reference
-                              (typescript-test-get-doc)))))
-    (kill-buffer buffer)))
+                              (typescript-test-get-doc)))))))
 
 (ert-deftest switch-case-indent-default ()
-  (let ((buffer (find-file "test-files/switch-case-indent-default.ts")))
+  (with-temp-buffer
+    (insert-file-contents "test-files/switch-case-indent-default.ts")
     (typescript-mode)
     (let ((test-reference (typescript-test-get-doc)))
       (typescript-test-indent-all)
       (should (string-equal test-reference
-                            (typescript-test-get-doc))))
-    (kill-buffer buffer)))
+                            (typescript-test-get-doc))))))
 
 (ert-deftest switch-case-indent-disabled ()
-  (let ((buffer (find-file "test-files/switch-case-indent-disabled.ts"))
-        (typescript-indent-switch-clauses nil))
-    (typescript-mode)
-    (let ((test-reference (typescript-test-get-doc)))
-      (typescript-test-indent-all)
-      (should (string-equal test-reference
-                            (typescript-test-get-doc))))
-    (kill-buffer buffer)))
+  (with-temp-buffer
+    (insert-file-contents "test-files/switch-case-indent-disabled.ts")
+    (let ((typescript-indent-switch-clauses nil))
+      (typescript-mode)
+      (let ((test-reference (typescript-test-get-doc)))
+        (typescript-test-indent-all)
+        (should (string-equal test-reference
+                              (typescript-test-get-doc)))))))
 
 (ert-deftest list-items-indent-default ()
-  (with-current-buffer (find-file "test-files/list-items-indent-default.ts")
+  (with-temp-buffer
+    (insert-file-contents "test-files/list-items-indent-default.ts")
     (typescript-mode)
     (let ((test-reference (typescript-test-get-doc)))
       (typescript-test-indent-all)
-      (should (string= test-reference (typescript-test-get-doc))))
-    (kill-buffer)))
+      (should (string= test-reference (typescript-test-get-doc))))))
 
 (ert-deftest list-items-indent-default-not-comma-first ()
-  (with-current-buffer (find-file 
"test-files/list-items-indent-comma-first.ts")
+  (with-temp-buffer
+    (insert-file-contents "test-files/list-items-indent-comma-first.ts")
     (typescript-mode)
     (let ((test-reference (typescript-test-get-doc)))
       (typescript-test-indent-all)
-      (should-not (string= test-reference (typescript-test-get-doc))))
-    (kill-buffer)))
+      (should-not (string= test-reference (typescript-test-get-doc))))))
 
 (ert-deftest list-items-indent-comma-first ()
-  (with-current-buffer (find-file 
"test-files/list-items-indent-comma-first.ts")
+  (with-temp-buffer
+    (insert-file-contents "test-files/list-items-indent-comma-first.ts")
     (typescript-mode)
     (let ((test-reference (typescript-test-get-doc))
           (typescript-indent-list-items nil))
       (typescript-test-indent-all)
-      (should (string= test-reference (typescript-test-get-doc))))
-    (kill-buffer)))
+      (should (string= test-reference (typescript-test-get-doc))))))
 
 (ert-deftest list-items-indent-comma-first-not-default ()
-  (with-current-buffer (find-file "test-files/list-items-indent-default.ts")
+  (with-temp-buffer
+    (insert-file-contents "test-files/list-items-indent-default.ts")
     (typescript-mode)
     (let ((test-reference (typescript-test-get-doc))
           (typescript-indent-list-items nil))
       (typescript-test-indent-all)
-      (should-not (string= test-reference (typescript-test-get-doc))))
-    (kill-buffer)))
+      (should-not (string= test-reference (typescript-test-get-doc))))))
 
 (defun get-all-matched-strings (to-match)
   (let (result)



reply via email to

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