]> git.eshelyaron.com Git - emacs.git/commitdiff
Convert indent test for css-mode into automatic test
authorStefan Kangas <stefan@marxist.se>
Thu, 10 Sep 2020 18:40:34 +0000 (20:40 +0200)
committerStefan Kangas <stefan@marxist.se>
Thu, 10 Sep 2020 18:40:34 +0000 (20:40 +0200)
* test/lisp/textmodes/css-mode-tests.el (css-mode-test-indent): New
test.
(css-mode-tests-data-dir): New variable.
* test/manual/indent/css-mode.css: Move from here...
* test/lisp/textmodes/css-mode-resources/test-indent.css: ...to here.

test/lisp/textmodes/css-mode-resources/test-indent.css [new file with mode: 0644]
test/lisp/textmodes/css-mode-tests.el
test/manual/indent/css-mode.css [deleted file]

diff --git a/test/lisp/textmodes/css-mode-resources/test-indent.css b/test/lisp/textmodes/css-mode-resources/test-indent.css
new file mode 100644 (file)
index 0000000..041aeec
--- /dev/null
@@ -0,0 +1,100 @@
+/* asdfasdf */
+
+.xxx
+{
+}
+
+article[role="main"] {
+    width: 60%;
+}
+
+a, b:hover, c {
+    color: black !important;
+}
+
+a, b:hover {                    /* bug:20282 */
+    c {
+        color: black;
+    }
+    color: black;
+}
+
+a.b:c,d.e:f,g[h]:i,j[k]:l,.m.n:o,.p.q:r,.s[t]:u,.v[w]:x { /* bug:20282 */
+    background-color: white;
+}
+
+/* asdfasdf */
+@foo x2 {
+    bla:toto;
+}
+.x2
+{
+    /* foo: bar; */ foo2: bar2;
+    bar1: url("http://toto/titi");
+    bar2: url('http://toto/titi');
+    bar3: url(http://toto/titi);
+}
+
+div.x3
+{
+}
+
+article:hover
+{
+    color: black;
+}
+
+/* bug:13425 */
+div:first-child,
+div:last-child,
+div[disabled],
+div::before {
+    font: 15px "Helvetica Neue",
+          Helvetica,
+          Arial,
+          "Nimbus Sans L",
+          sans-serif;
+    font: 15px "Helvetica Neue", Helvetica, Arial,
+          "Nimbus Sans L", sans-serif;
+    background: no-repeat right
+                5px center;
+    transform: matrix(1.0, 2.0,
+                      3.0, 4.0,
+                      5.0, 6.0);
+    transform: matrix(
+        1.0, 2.0,
+        3.0, 4.0,
+        5.0, 6.0
+    );
+}
+
+/* Multi-line selector including both a pseudo-class and
+   parenthesis. */
+.form-group:not(.required) label,
+.birth-date .row > * {
+    &::after {
+        display: inline;
+        font-weight: normal;
+    }
+}
+
+@font-face {
+    src: url("Sans-Regular.eot") format("eot"),
+         url("Sans-Regular.woff") format("woff"),
+         url("Sans-Regular.ttf") format("truetype");
+}
+
+@font-face {
+    src:
+        url("Sans-Regular.eot") format("eot"),
+        url("Sans-Regular.woff") format("woff");
+}
+
+.foo-bar--baz {
+    --foo-variable: 5px;
+    --_variable_with_underscores: #fff;
+    --_variable-starting-with-underscore: none;
+    margin: var(--foo-variable);
+    color: var(--_variable_with_underscores);
+    display: var(--_variable-starting-with-underscore);
+}
index 38cb73b355772767dd653a3d19b1596ea295a934..f627d1c02c9fd5d91204ec6b4b5105dd70b8b6ed 100644 (file)
 (require 'ert)
 (require 'seq)
 
+(defvar css-mode-tests-data-dir
+  (file-truename
+   (expand-file-name "css-mode-resources/"
+                     (file-name-directory (or load-file-name
+                                              buffer-file-name)))))
+
 (ert-deftest css-test-property-values ()
   ;; The `float' property has a flat value list.
   (should
                                       (point))
                                     "black")))))
 
+(ert-deftest css-mode-test-indent ()
+  (with-current-buffer
+      (find-file-noselect (expand-file-name "test-indent.css"
+                                            css-mode-tests-data-dir))
+    (let ((orig (buffer-string)))
+      (indent-region (point-min) (point-max))
+      (should (equal (buffer-string) orig)))))
+
 (provide 'css-mode-tests)
 ;;; css-mode-tests.el ends here
diff --git a/test/manual/indent/css-mode.css b/test/manual/indent/css-mode.css
deleted file mode 100644 (file)
index 041aeec..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* asdfasdf */
-
-.xxx
-{
-}
-
-article[role="main"] {
-    width: 60%;
-}
-
-a, b:hover, c {
-    color: black !important;
-}
-
-a, b:hover {                    /* bug:20282 */
-    c {
-        color: black;
-    }
-    color: black;
-}
-
-a.b:c,d.e:f,g[h]:i,j[k]:l,.m.n:o,.p.q:r,.s[t]:u,.v[w]:x { /* bug:20282 */
-    background-color: white;
-}
-
-/* asdfasdf */
-@foo x2 {
-    bla:toto;
-}
-.x2
-{
-    /* foo: bar; */ foo2: bar2;
-    bar1: url("http://toto/titi");
-    bar2: url('http://toto/titi');
-    bar3: url(http://toto/titi);
-}
-
-div.x3
-{
-}
-
-article:hover
-{
-    color: black;
-}
-
-/* bug:13425 */
-div:first-child,
-div:last-child,
-div[disabled],
-div::before {
-    font: 15px "Helvetica Neue",
-          Helvetica,
-          Arial,
-          "Nimbus Sans L",
-          sans-serif;
-    font: 15px "Helvetica Neue", Helvetica, Arial,
-          "Nimbus Sans L", sans-serif;
-    background: no-repeat right
-                5px center;
-    transform: matrix(1.0, 2.0,
-                      3.0, 4.0,
-                      5.0, 6.0);
-    transform: matrix(
-        1.0, 2.0,
-        3.0, 4.0,
-        5.0, 6.0
-    );
-}
-
-/* Multi-line selector including both a pseudo-class and
-   parenthesis. */
-.form-group:not(.required) label,
-.birth-date .row > * {
-    &::after {
-        display: inline;
-        font-weight: normal;
-    }
-}
-
-@font-face {
-    src: url("Sans-Regular.eot") format("eot"),
-         url("Sans-Regular.woff") format("woff"),
-         url("Sans-Regular.ttf") format("truetype");
-}
-
-@font-face {
-    src:
-        url("Sans-Regular.eot") format("eot"),
-        url("Sans-Regular.woff") format("woff");
-}
-
-.foo-bar--baz {
-    --foo-variable: 5px;
-    --_variable_with_underscores: #fff;
-    --_variable-starting-with-underscore: none;
-    margin: var(--foo-variable);
-    color: var(--_variable_with_underscores);
-    display: var(--_variable-starting-with-underscore);
-}