Skip to content

Commit

Permalink
Fix test_indentation.sh, add basic_blocks.lua indentation test
Browse files Browse the repository at this point in the history
  • Loading branch information
immerrr committed Jun 23, 2012
1 parent d128a74 commit 66cd58a
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 3 deletions.
45 changes: 45 additions & 0 deletions test/indentation/basic_blocks.lua
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions test/indentation/basic_blocks.lua.etalon
Original file line number Diff line number Diff line change
@@ -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
13 changes: 10 additions & 3 deletions test/indentation/test_indentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 66cd58a

Please sign in to comment.