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

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

[elpa] externals/csharp-mode b061f8a 104/459: Add unit-test for indentat


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode b061f8a 104/459: Add unit-test for indentation.
Date: Sun, 22 Aug 2021 13:59:06 -0400 (EDT)

branch: externals/csharp-mode
commit b061f8aedb28ad7c05251244640763612ba7dae7
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Add unit-test for indentation.
---
 csharp-mode-tests.el            | 11 +++++++
 test-files/indentation-tests.cs | 69 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 21156ba..3db42f1 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -139,4 +139,15 @@
     (should (equal t (and csharp-hook1
                           csharp-hook2)))))
 
+(ert-deftest indentation-rules-should-be-as-specified-in-test-doc ()
+  (let* ((buffer (find-file "test-files/indentation-tests.cs")))
+    ;; double-ensure mode is active
+    (csharp-mode)
+
+    (setq orig-content (buffer-substring-no-properties (point-min) 
(point-max)))
+    (indent-region (point-min) (point-max))
+    (setq indented-content (buffer-substring-no-properties (point-min) 
(point-max)))
+
+    (should (equal orig-content indented-content))))
+
 ;;(ert-run-tests-interactively t)
diff --git a/test-files/indentation-tests.cs b/test-files/indentation-tests.cs
new file mode 100644
index 0000000..d054655
--- /dev/null
+++ b/test-files/indentation-tests.cs
@@ -0,0 +1,69 @@
+using System;
+
+/* comment block
+   on namespace test */
+namespace Boo
+{
+    // comment on class test
+    public class Foo
+    {
+        // auto-property-test
+        public bool AutoProperty { get; set; }
+
+        // regular property-test
+        public bool Property
+        {
+            get
+            {
+                return true;
+            }
+            set
+            {
+                // ignored
+            }
+        }
+
+        /// <summary>
+        ///   Codedoc on method-test
+        /// </summary>
+        public void Foo(string a = "hkfdhkd", string b = "bbbbbb")
+        {
+            // OK!
+        }
+
+        public void Test()
+        {
+            if (test)
+            {
+
+            }
+
+            if (test2) {
+                // should work too
+                bool b = true;
+            }
+
+            var x = new {
+                adhoc = object,
+                with = new prop(),
+            };
+
+            var map = new Dictionary<int,string> {
+                { 1, "true" },
+                { 2, "false" },
+            };
+
+            // indents incorrectly! :(
+            // var map2 = new Dictionary<int,string>
+            //     {
+            //         { 1, "true" },
+            //         { 2, "false" },
+            //     };
+
+            using (test)
+            {
+                System.Console.WriteLine("boo");
+            }
+        }
+    }
+}



reply via email to

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