#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

JAVA="java -cp pa2-tests/chocopy-ref.jar:target/assignment.jar chocopy.ChocoPy"

echo "# CORE TESTS"
${JAVA} --pass=.s --test --dir pa2-tests/core

echo
echo "# EXTRA TESTS"
${JAVA} --pass=.s --test --dir pa2-tests/extra

echo
echo "# STUDENT TESTS"
function regen_and_test {
  ${JAVA} --pass=r "${1}" --out "${1}.ast" 2>/dev/null 1>&2
  ${JAVA} --pass=.r "${1}.ast" --out "${1}.ast.typed" 2>/dev/null 1>&2
  ${JAVA} --pass=.s --test "${1}.ast"
}
regen_and_test "src/test/data/pa2/student_contributed/bad_semantic.py"
regen_and_test "src/test/data/pa2/student_contributed/bad_types.py"
regen_and_test "src/test/data/pa2/student_contributed/good.py"
