From 3e505d36acb7510a5170fc3529fa8cf1c69e0f50 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 31 Jul 2023 13:13:33 +0200 Subject: [PATCH] Convert align-tests to use erts --- test/lisp/align-resources/align-post.c | 3 --- test/lisp/align-resources/align-post.java | 9 --------- test/lisp/align-resources/align-pre.c | 3 --- test/lisp/align-resources/align-pre.java | 9 --------- test/lisp/align-resources/c-mode.erts | 11 +++++++++++ test/lisp/align-resources/java-mode.erts | 23 ++++++++++++++++++++++ test/lisp/align-tests.el | 24 ++++++++++------------- 7 files changed, 44 insertions(+), 38 deletions(-) delete mode 100644 test/lisp/align-resources/align-post.c delete mode 100644 test/lisp/align-resources/align-post.java delete mode 100644 test/lisp/align-resources/align-pre.c delete mode 100644 test/lisp/align-resources/align-pre.java create mode 100644 test/lisp/align-resources/c-mode.erts create mode 100644 test/lisp/align-resources/java-mode.erts diff --git a/test/lisp/align-resources/align-post.c b/test/lisp/align-resources/align-post.c deleted file mode 100644 index 157e1d6242a..00000000000 --- a/test/lisp/align-resources/align-post.c +++ /dev/null @@ -1,3 +0,0 @@ -int -main (int argc, - char *argv[]); diff --git a/test/lisp/align-resources/align-post.java b/test/lisp/align-resources/align-post.java deleted file mode 100644 index e0ea8e727f1..00000000000 --- a/test/lisp/align-resources/align-post.java +++ /dev/null @@ -1,9 +0,0 @@ -class X -{ - String field1; - String[] field2; - int field3; - int[] field4; - X field5; - X[] field6; -} diff --git a/test/lisp/align-resources/align-pre.c b/test/lisp/align-resources/align-pre.c deleted file mode 100644 index b1774181a40..00000000000 --- a/test/lisp/align-resources/align-pre.c +++ /dev/null @@ -1,3 +0,0 @@ -int -main (int argc, - char *argv[]); diff --git a/test/lisp/align-resources/align-pre.java b/test/lisp/align-resources/align-pre.java deleted file mode 100644 index fe7a87a9393..00000000000 --- a/test/lisp/align-resources/align-pre.java +++ /dev/null @@ -1,9 +0,0 @@ -class X -{ - String field1; - String[] field2; - int field3; - int[] field4; - X field5; - X[] field6; -} diff --git a/test/lisp/align-resources/c-mode.erts b/test/lisp/align-resources/c-mode.erts new file mode 100644 index 00000000000..0a0fa046b34 --- /dev/null +++ b/test/lisp/align-resources/c-mode.erts @@ -0,0 +1,11 @@ +Name: align function declaration + +=-= +int +main (int argc, + char *argv[]); +=-= +int +main (int argc, + char *argv[]); +=-=-= diff --git a/test/lisp/align-resources/java-mode.erts b/test/lisp/align-resources/java-mode.erts new file mode 100644 index 00000000000..693a4123121 --- /dev/null +++ b/test/lisp/align-resources/java-mode.erts @@ -0,0 +1,23 @@ +Name: align class fields + +=-= +class X +{ + String field1; + String[] field2; + int field3; + int[] field4; + X field5; + X[] field6; +} +=-= +class X +{ + String field1; + String[] field2; + int field3; + int[] field4; + X field5; + X[] field6; +} +=-=-= diff --git a/test/lisp/align-tests.el b/test/lisp/align-tests.el index 62ef9cf27fa..5f9580fabf0 100644 --- a/test/lisp/align-tests.el +++ b/test/lisp/align-tests.el @@ -25,22 +25,18 @@ (require 'ert-x) (require 'align) -(defun test-align-compare (file function) - (should (equal - (with-temp-buffer - (insert-file-contents (ert-resource-file (format file "pre"))) - (funcall function) - (align (point-min) (point-max)) - (buffer-substring-no-properties (point-min) (point-max))) - (with-temp-buffer - (insert-file-contents (ert-resource-file (format file "post"))) - (buffer-string))))) - -(ert-deftest align-java () - (test-align-compare "align-%s.java" #'java-mode)) +(defun test-align-transform-fun (function) + (lambda () + (funcall function) + (align (point-min) (point-max)))) (ert-deftest align-c () - (test-align-compare "align-%s.c" #'c-mode)) + (ert-test-erts-file (ert-resource-file "c-mode.erts") + (test-align-transform-fun #'c-mode))) + +(ert-deftest align-java () + (ert-test-erts-file (ert-resource-file "java-mode.erts") + (test-align-transform-fun #'java-mode))) (provide 'align-tests) -- 2.39.2