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

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

[nongnu] elpa/lua-mode 93da584 449/468: Bump indentation tests, add miss


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 93da584 449/468: Bump indentation tests, add missing function-call-arguments suite
Date: Thu, 5 Aug 2021 04:59:27 -0400 (EDT)

branch: elpa/lua-mode
commit 93da584109ea2bfb4627436a521cc1f0642ac9b5
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>

    Bump indentation tests, add missing function-call-arguments suite
---
 test/indentation-tests/assignment-indentation.lua  |   8 +-
 test/indentation-tests/function-call-arguments.lua | 109 +++++++++++++++
 test/test-indentation.el                           | 148 +++++++++++----------
 3 files changed, 189 insertions(+), 76 deletions(-)

diff --git a/test/indentation-tests/assignment-indentation.lua 
b/test/indentation-tests/assignment-indentation.lua
index 10adb60..4d0f7ee 100644
--- a/test/indentation-tests/assignment-indentation.lua
+++ b/test/indentation-tests/assignment-indentation.lua
@@ -175,14 +175,14 @@ x = t[very_very_very_long_name()
 
 -- does not indent binary operators inside brackets: indentation 1
 
-x = [
+x = foo[
    very_very_very_long_name() +
    another_very_very_very_long_name()
-    ]
+       ]
 
 -- does not indent binary operators inside brackets: indentation 2
 
-x = [
+x = foo[
    very_very_very_long_name()
    + another_very_very_very_long_name()
-    ]
+       ]
diff --git a/test/indentation-tests/function-call-arguments.lua 
b/test/indentation-tests/function-call-arguments.lua
new file mode 100644
index 0000000..e4a520a
--- /dev/null
+++ b/test/indentation-tests/function-call-arguments.lua
@@ -0,0 +1,109 @@
+-- THINGS TO TEST:
+-- parentheses vs braces (table ctor)
+-- close paren/brace: attached/detached
+-- alignment/indentation
+-- args in horizontal line vs args in column vs mixed
+-- one of params is a table/function literal/function call/single-line 
table/single-line function
+
+-- it works for single line case
+
+foobar(a, b, c)
+
+a = 0
+
+-- it works for indenting all args on one line: close paren on separate line
+
+foobar(
+   a, b, c
+)
+
+a = 0
+
+-- it works for indenting all args in a column: close paren on separate line
+
+foobar(
+   a,
+   b,
+   c
+)
+
+a = 0
+
+-- it works for mixed arg indentation: close paren on separate line
+
+foobar(
+   a, b,
+   c, d
+)
+
+a = 0
+
+-- it works with table ctorfor single line case
+
+foobar{a, b, c}
+
+a = 0
+
+-- it works with table ctor for indenting all args on one line: close paren on 
separate line
+
+foobar{
+   a, b, c
+}
+
+a = 0
+
+-- it works with table ctor for indenting all args in a column: close paren on 
separate line
+
+foobar{
+   a,
+   b,
+   c
+}
+
+a = 0
+
+-- it works with table ctor for mixed arg indentation: close paren on separate 
line
+
+foobar{
+   a, b,
+   c, d
+}
+
+a = 0
+
+-- it works for mixed arg indentation with table in the middle: close paren on 
separate line
+
+foobar(
+   a, b,
+   {
+      foo = bar,
+      qux = quux
+   }, d
+)
+
+a = 0
+
+-- it works for mixed arg indentation with table first: close paren on 
separate line
+
+foobar(
+   {
+      foo = bar,
+      qux = quux
+   }, b,
+   c, d
+)
+
+a = 0
+
+-- it works for mixed arg indentation with table last: close paren on separate 
line
+
+foobar(
+   a, b,
+   c, {
+      foo = bar,
+      qux = quux
+      }
+)
+
+a = 0
+
diff --git a/test/test-indentation.el b/test/test-indentation.el
index 7cc6d12..d581504 100644
--- a/test/test-indentation.el
+++ b/test/test-indentation.el
@@ -59,163 +59,167 @@
           indentation-tests))
 
 (describe "Continuation lines"
-  (it "are indented before/after binary operators"
-    (let ((binops '("+"  "-"  "*"  "/"  "^"  "%"  ".."
-                    "<"  "<="  ">"  ">="  "=="  "~="
-                    "and"  "or")))
-      (cl-dolist (binop binops)
-        (lua--reindent-like (replace-regexp-in-string "BINOP" binop "\
+  (lua--parametrize-tests
+   (binop)
+   (("+") ("-") ("*") ("/") ("^") ("%") ("..")
+    ("<") ("<=") (">") (">=") ("==") ("~=") ("and") ("or"))
+
+   :it (format "are indented before/after binary operators: %s" binop)
+   (expect (replace-regexp-in-string "BINOP" binop "\
 a = foo BINOP
-   bar" 'fixedcase))
-        (lua--reindent-like (replace-regexp-in-string "BINOP" binop "\
+   bar" 'fixedcase)
+           :to-be-reindented-the-same-way)
+   (expect (replace-regexp-in-string "BINOP" binop "\
 a = foo
-   BINOP bar" 'fixedcase)))))
-
-
-
-  (xit "are indented before/after unary operators"
-    (expect (lua--reindent-like "\
-foo = bar
-   -#some_str"))
-
-    (cl-dolist (unop '("-" "#" "not "))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop  "\
-foobar(qux,
-       <>quux)")))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
-foobar(qux, xyzzy
-          <>quux)")))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
-foobar(
-   <>quux)")))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
-x = {qux,
-     <>quux}")))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
-x = {qux;
-     <>quux}")))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
-x = {qux, xyzzy
-        <>quux}")))
-      (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
-x = {
-   <>quux
-}"))))))
+   BINOP bar" 'fixedcase)
+           :to-be-reindented-the-same-way))
+) ;; (
+
+
+
+;;    (xit "are indented before/after unary operators"
+;;      (expect (lua--reindent-like "\
+;; foo = bar
+;;    -#some_str"))
+
+;;      (cl-dolist (unop '("-" "#" "not "))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop  "\
+;; foobar(qux,
+;;        <>quux)")))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
+;; foobar(qux, xyzzy
+;;           <>quux)")))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
+;; foobar(
+;;    <>quux)")))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
+;; x = {qux,
+;;      <>quux}")))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
+;; x = {qux;
+;;      <>quux}")))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
+;; x = {qux, xyzzy
+;;         <>quux}")))
+;;        (expect (lua--reindent-like (replace-regexp-in-string "<>" unop "\
+;; x = {
+;;    <>quux
+;; }"))))))
 
 
 
 (describe "Function indentation"
   (it "indents function call arguments"
-    (expect (lua--reindent-like "\
+    (expect "\
 foobar(
-   a, b, c)"))
-    (expect (lua--reindent-like "\
+   a, b, c)" :to-be-reindented-the-same-way)
+    (expect "\
 foobar(
    a,
-   b, c)"))
+   b, c)" :to-be-reindented-the-same-way)
 
-    (expect (lua--reindent-like "\
+    (expect "\
 foobar(
    a, b, c
-)"))
+)" :to-be-reindented-the-same-way)
 
-    (expect (lua--reindent-like "\
+    (expect "\
 foobar(a,
        b,
-       c)"))
+       c)" :to-be-reindented-the-same-way)
 
-    (expect (lua--reindent-like "\
+    (expect "\
 foobar{
    a, b, c
-}")))
+}" :to-be-reindented-the-same-way))
 
   (it "indent blocks with lua-indent-nested-block-content-align"
     (let ((lua-indent-nested-block-content-align nil))
-      (expect (lua--reindent-like "\
+      (expect "\
 call_some_fn( something, {
       val = 5,
       another = 6,
-} )"))
-      (expect (lua--reindent-like "\
+} )" :to-be-reindented-the-same-way)
+      (expect "\
 local def = {
    some_very_long_name = { fn =
          function()
             return true
          end
    }
-}"))
+}" :to-be-reindented-the-same-way)
       ))
 
   (it "indent blocks with lua-indent-close-paren-align"
     (let ((lua-indent-close-paren-align nil))
-      (expect (lua--reindent-like "\
+      (expect "\
 local foo = setmetatable( {
       a = 4,
       b = 5,
 }, {
       __index = some_func,
-} )"))
+} )" :to-be-reindented-the-same-way)
       ))
 
   (it "indents nested tables with alternative block indenting"
     (let ((lua-indent-nested-block-content-align nil)
          (lua-indent-close-paren-align nil))
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar({
       a, b, c
-})"))
+})" :to-be-reindented-the-same-way)
 
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar(a, {
       b,
       c
-})"))
+})" :to-be-reindented-the-same-way)
 
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar(
    a,
    {
       b,
       c
-})"))
+})" :to-be-reindented-the-same-way)
 
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar(
    a,
    {
       b,
       c
    }
-)"))
+)" :to-be-reindented-the-same-way)
 
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar(a,
    {
       b,
       c
-})"))
+})" :to-be-reindented-the-same-way)
 
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar(a,
    {
       b,
       c
    }
-)"))
+)" :to-be-reindented-the-same-way)
 
-      (expect (lua--reindent-like "\
+      (expect "\
 foobar(
    {
       a,
       b
    },
    c, d
-)"))
+)" :to-be-reindented-the-same-way)
       )))
 
 
 (ert-deftest lua-indentation-keywords-with-special-characters ()
-  (expect (lua--reindent-like "\
+  (expect "\
 do
    foobar = _do
-end")))
+end" :to-be-reindented-the-same-way))



reply via email to

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