Commit 248976a3 authored by Leo's avatar Leo

add tests for variable-capitalized

parent a5d29d51
......@@ -641,4 +641,81 @@ is_travis() {
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'capitalized variable' {
cat <<-"EOF" >$apkbuild
Foo=bar
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
# Match lines[1] instead of lines[0] because check for variables that should have
# underscore coems before it
assert_match "${lines[1]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'underscored capitalized variable' {
cat <<-"EOF" >$apkbuild
_Foo=bar
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'normal variable' {
cat <<-"EOF" >$apkbuild
pkgver=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'normal underscored variable' {
cat <<-"EOF" >$apkbuild
_commit=aabbcc
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'capitalized local variable' {
cat <<-"EOF" >$apkbuild
foo() {
local NotValid
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'capitalized local variable between valid ones' {
cat <<-"EOF" >$apkbuild
foo() {
local valid NotValid correct
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'valid local variables' {
cat <<-"EOF" >$apkbuild
foo() {
local valid
}
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
# vim: noexpandtab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment