mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
Shell: Add tests for 'if'
This commit is contained in:
parent
b90eb5c9ba
commit
db18e75a09
Notes:
sideshowbarker
2024-07-19 03:17:26 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/db18e75a09e Pull-request: https://github.com/SerenityOS/serenity/pull/3245
1 changed files with 46 additions and 0 deletions
46
Shell/Tests/if.sh
Normal file
46
Shell/Tests/if.sh
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
if test 1 -eq 1 {
|
||||
# Are comments ok?
|
||||
# Basic 'if' structure, empty block.
|
||||
if true {
|
||||
} else {
|
||||
exit 2
|
||||
}
|
||||
if false {
|
||||
exit 2
|
||||
} else {
|
||||
}
|
||||
|
||||
# Basic 'if' structure, without 'else'
|
||||
if false {
|
||||
echo "Fail: 'if false' runs the branch"
|
||||
exit 2
|
||||
}
|
||||
|
||||
# Extended 'cond' form.
|
||||
if false {
|
||||
echo "Fail: 'if false' with 'else if' runs first branch"
|
||||
exit 2
|
||||
} else if true {
|
||||
} else {
|
||||
echo "Fail: 'if false' with 'else if' runs last branch"
|
||||
exit 2
|
||||
}
|
||||
|
||||
# FIXME: Some form of 'not' would be nice
|
||||
# &&/|| in condition
|
||||
if true || false {
|
||||
} else {
|
||||
echo "Fail: 'if true || false' runs false branch"
|
||||
exit 2
|
||||
}
|
||||
|
||||
if true && false {
|
||||
echo "Fail: 'if true && false' runs true branch"
|
||||
exit 2
|
||||
}
|
||||
} else {
|
||||
echo "Fail: 'if test 1 -eq 1' runs false branch"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in a new issue