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

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

[nongnu] elpa/lua-mode 66cd58a 171/468: Fix test_indentation.sh, add bas


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 66cd58a 171/468: Fix test_indentation.sh, add basic_blocks.lua indentation test
Date: Thu, 5 Aug 2021 04:58:30 -0400 (EDT)

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

    Fix test_indentation.sh, add basic_blocks.lua indentation test
---
 test/indentation/basic_blocks.lua        | 45 ++++++++++++++++++++++++++++++++
 test/indentation/basic_blocks.lua.etalon | 45 ++++++++++++++++++++++++++++++++
 test/indentation/test_indentation.sh     | 13 ++++++---
 3 files changed, 100 insertions(+), 3 deletions(-)

diff --git a/test/indentation/basic_blocks.lua 
b/test/indentation/basic_blocks.lua
new file mode 100644
index 0000000..2131dbc
--- /dev/null
+++ b/test/indentation/basic_blocks.lua
@@ -0,0 +1,45 @@
+do
+a = 2
+c = 5
+end
+
+if good then
+do_good()
+elseif bad then
+do_bad()
+else
+do_nothing()
+really_do_nothing()
+end
+
+while true do
+sun.rise_in_the_east()
+end
+
+repeat
+host.offer_hot_beverage(guest)
+until guest.good
+
+for i,v in ipairs(base) do
+take(base)
+end
+
+function fact(i)
+if i == 0 then
+return 1
+else
+if i == 1 then
+return 1
+else
+if i == 2 then
+return 2
+else
+fact = 2
+for n=3,i do
+fact = fact * n
+end
+return fact
+end
+end
+end
+end
diff --git a/test/indentation/basic_blocks.lua.etalon 
b/test/indentation/basic_blocks.lua.etalon
new file mode 100644
index 0000000..51fa544
--- /dev/null
+++ b/test/indentation/basic_blocks.lua.etalon
@@ -0,0 +1,45 @@
+do
+   a = 2
+   c = 5
+end
+
+if good then
+   do_good()
+elseif bad then
+   do_bad()
+else
+   do_nothing()
+   really_do_nothing()
+end
+
+while true do
+   sun.rise_in_the_east()
+end
+
+repeat
+   host.offer_hot_beverage(guest)
+until guest.good
+
+for i,v in ipairs(base) do
+   take(base)
+end
+
+function fact(i)
+   if i == 0 then
+      return 1
+   else
+      if i == 1 then
+         return 1
+      else
+         if i == 2 then
+            return 2
+         else
+            fact = 2
+            for n=3,i do
+               fact = fact * n
+            end
+            return fact
+         end
+      end
+   end
+end
diff --git a/test/indentation/test_indentation.sh 
b/test/indentation/test_indentation.sh
index 799c98e..040faeb 100755
--- a/test/indentation/test_indentation.sh
+++ b/test/indentation/test_indentation.sh
@@ -8,7 +8,7 @@ declare -a PARAMS
 PARAMS=( "$@" )
 
 set ${EMACS=emacs}
-set ${LUA_MODE=$(dirname $0)/../lua-mode.el}
+set ${LUA_MODE=$(dirname $0)/../../lua-mode.el}
 
 if [ ${#PARAMS[@]} -eq 0 ]; then
     cat <<EOF
@@ -54,9 +54,16 @@ test_file_indentation() {
         --load $LUA_MODE \
         --eval "(setq make-backup-files nil)" \
         --eval "\
-(progn
-  (find-file \"$INPUT\")
+(with-temp-buffer
+  ;; lua-mode indents by 3s, that's not even a multiple of tab width (4/8)
+  (set-default 'indent-tabs-mode nil) \
+  (insert-file-contents \"$INPUT\")
   (lua-mode)
+
+  ;; permit unsafe (e.g. lua-*) local variables and read them
+  (setq enable-local-variables :all)
+  (hack-local-variables)
+
   (indent-region (point-min) (point-max))
   (write-file \"$OUTPUT\"))" \
       > $ERROR_LOG 2>&1 \



reply via email to

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