diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-07-11 18:08:11 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-07-11 18:08:11 +0200 |
| commit | 43e3a8a08668b068eb07b5c1ee3aaa767021d3c0 (patch) | |
| tree | c509903adbd8143aeb2d6c8e794775a52fc8ea4c /tests | |
| parent | c5cbfacba61a9fba9e1bf3ea6abc4f067298c80f (diff) | |
add format. Improve tests.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -2,8 +2,9 @@ # 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) + # shellcheck disable=SC2254 + [ "$filter" ] && case $1 in ($filter) ;; (*) return; esac + out=$(echo "$2" | ./mp 2>&1) [ "$out" = "$3" ] && pass=$((pass + 1)) && return printf "%s FAIL\nWant: \"%s\"\n Got: \"%s\"\n" "$1" "$3" "$out" fail=$((fail + 1)) @@ -14,8 +15,12 @@ run() { 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' +run basic1 'parse' '' +run basic2 'parse null' 'null' +run basic3 'parse true' 'true' +run basic4 'parse false' 'false' +run num1 'parse 12' '12' +run str1 'parse "hello"' '"hello"' +run obj1 'parse {}' '{}' +run arr1 'parse []' '[]' + |
