about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/lua-5/tests/assert.sh
blob: c5783a24b2d7bc88d9219c4ec4b1a5e482a8b73d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Always failing assertion with a message.
#
# Example:
#     fail "It should have been but it wasn't to be"
function fail() {
    echo "$1"
    exit 1
}


function assertStringEqual() {
    if ! diff <(echo "$1") <(echo "$2") ; then
        fail "expected \"$1\" to be equal to \"$2\""
    fi
}

function assertStringContains() {
    if ! echo "$1" | grep -q "$2" ; then
        fail "expected \"$1\" to contain \"$2\""
    fi
}