#!/bin/sh

echo "${TEST_NAME} -- test whether default preference order is respected"

set -- ${PYTHON_IMPLS}

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

	# we need to find two not-selected and not-disabled implementations.
	if is_preferred "${1}" || is_disabled "${1}"; then
		shift
	else
		if [ -n "${FIRST}" ]; then
			SECOND=${1}
			break
		else
			FIRST=${1}
			shift
		fi
	fi
done

echo "first: ${FIRST}" >&2
echo "second: ${SECOND}" >&2

unset EPYTHON

write_impl "${FIRST}" "#!/usr/bin/env false"
write_impl "${SECOND}"  "#!/usr/bin/env true"

do_test "${TEST_TMP}"
