#!/bin/bash

. ../init.sh

tests=(
	"q file -Cq /bin/bash /bin/XXXXX"
	"app-shells/bash"

	"q file -Co /bin/bash /bin/XXXXX"
	"/bin/XXXXX"

	"echo -e \"/bin/bash\n/bin/XXXXX\" | q file -Cq -f -"
	"app-shells/bash"

	"echo -e \"/bin/bash\n/bin/XXXXX\" | q file -Co -f -"
	"/bin/XXXXX"

	"q file -Co -x bash /bin/bash"
	"/bin/bash"

	"q file -Co -x app-shells/bash /bin/bash"
	"/bin/bash"

	"q file -Co -x bash:0 /bin/bash"
	"/bin/bash"

	"q file -Co -x app-shells/bash:0 /bin/bash"
	"/bin/bash"
)

set -- "${tests[@]}"
while [[ $# -gt 0 ]] ; do
	test=$1; shift
	exp=$1; shift

	res=$(eval ${test})
	[[ "${res}" == "${exp}" ]]
	if ! tend $? "${test}" ; then
		(
		echo " - expected result was: ${exp}"
		echo " - actual result was:   ${res}"
		) > /dev/stderr
	fi
done

end
