Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix test_indentation.sh, add basic_blocks.lua indentation test

  • Loading branch information...
commit 66cd58af854aa3d067958c48d688b19c4a5f3813 1 parent d128a74
@immerrr authored
View
45 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
View
45 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
View
13 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 \
Please sign in to comment.
Something went wrong with that request. Please try again.