September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
21
Task/Assertions/AWK/assertions.awk
Normal file
21
Task/Assertions/AWK/assertions.awk
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
BEGIN {
|
||||
meaning = 6 * 7
|
||||
assert(meaning == 42, "Integer mathematics failed")
|
||||
assert(meaning == 42)
|
||||
meaning = strtonum("42 also known as forty-two")
|
||||
assert(meaning == 42, "Built-in function failed")
|
||||
meaning = "42"
|
||||
assert(meaning == 42, "Dynamic type conversion failed")
|
||||
meaning = 6 * 9
|
||||
assert(meaning == 42, "Ford Prefect's experiment failed")
|
||||
print "That's all folks"
|
||||
exit
|
||||
}
|
||||
|
||||
# Errormsg is optional, displayed if assertion fails
|
||||
function assert(cond, errormsg){
|
||||
if (!cond) {
|
||||
if (errormsg != "") print errormsg
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue