blob: 1c8dcfff1cf3f488da8c584a230cca8a14999313 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/sh
# Test suite for mp.
run() {
[ "$filter" ] && case $1 in $filter) ;; *) return; esac
out=$(echo "$2" | ./mp 2>&1 | tr -d '\034' | awk -v ORS='\\n' 1)
[ "$out" = "$3" ] && pass=$((pass + 1)) && return
printf "%s FAIL\nWant: \"%s\"\n Got: \"%s\"\n" "$1" "$3" "$out"
fail=$((fail + 1))
return 1
}
[ "$FAILFAST" ] && set -e
pass=0 fail=0 filter="$1"
trap 'echo "$pass passed, $fail failed"; exit $((fail))' EXIT
run test1 'parse null' 'v[type]: null\n'
run test2 'parse true' 'v[type]: true\n'
run test3 'parse false' 'v[type]: false\n'
run test4 'parse 12' 'v[string]: 12\nv[type]: number\n'
run test5 'parse "hello"' 'v[string]: hello\nv[type]: string\n'
|