#!/bin/sh

echo "${TEST_NAME} -- test whether default preference order respects disabled impls"

set -- ${PYTHON_IMPLS}

unset DISABLED
while true; do
	if [ ${#} -lt 1 ]; then
		echo 'Not enough implementations to perform test.' >&2
		do_exit 77
	fi

	# Both impls must not be preferred.
	if ! is_preferred "${1}"; then
		# First must be disabled, second must not.
		if [ -n "${DISABLED}" ] && ! is_disabled "${1}"; then
			OTHER=${1}
			break
		elif is_disabled "${1}"; then
			DISABLED=${1}
		fi
	fi
	shift
done

echo "disabled: ${DISABLED}" >&2
echo "other: ${OTHER}" >&2

unset EPYTHON

write_impl "${DISABLED}" "#!/usr/bin/env false"
write_impl "${OTHER}"  "#!/usr/bin/env true"

do_test "${TEST_TMP}"
