#!/bin/sh
# As-installed smoke test: exercise the basex standalone XQuery/XPath processor.
set -e

check() {
	desc="$1"; expected="$2"; got="$3"
	if [ "$got" = "$expected" ]; then
		echo "ok - $desc"
	else
		echo "FAIL - $desc: expected [$expected], got [$got]"
		exit 1
	fi
}

# Arithmetic evaluation.
check "arithmetic" "2" "$(basex -q '1 + 1' 2>/dev/null)"

# XML parsing and XPath navigation.
check "xml parse + xpath" "3" \
	"$(basex -q 'count(parse-xml("<a><b/><b/><b/></a>")//b)' 2>/dev/null)"

# Standard XQuery function library.
check "string-join" "x-y" "$(basex -q 'string-join(("x","y"),"-")' 2>/dev/null)"

echo "all smoke tests passed"
