diff options
Diffstat (limited to 'lambda-calcul/haskell/test.sh')
| -rwxr-xr-x | lambda-calcul/haskell/test.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lambda-calcul/haskell/test.sh b/lambda-calcul/haskell/test.sh new file mode 100755 index 0000000..1b78960 --- /dev/null +++ b/lambda-calcul/haskell/test.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -euo pipefail + +HOST=${1:-https://lambda.pankzsoft.net} + +ALICE=$(curl -s -X POST -H 'content-type: application/json' $HOST/api/register -d '"alice"' | jq -r) +echo "registered alice with token '$ALICE'" +sleep 2 + +for i in $(seq 1 14); do + GRADE=$(curl -s -X GET -H 'content-type: application/json' "$HOST/api/score?token=$ALICE" | jq -r .grade) + echo "alice's grade is $GRADE" + sleep 1 + + CHAL=$(curl -s -X GET -H 'content-type: application/json' "$HOST/api/challenge?token=$ALICE" | jq -r .expr) + echo "alice's challenge is '$CHAL'" + sleep 1 + + ANSWER=$(echo "$CHAL" | cabal run) + echo "alice's answer is '$ANSWER'" + + RESULT=$(curl -s -X POST -H 'content-type: application/json' "$HOST/api/challenge?token=$ALICE" -d "\"$ANSWER\"") + + if [ "$RESULT" != "[]" ]; then + echo "Failed challenge: $RESULT" + fi +done + +SCORE=$(curl -s -X DELETE -H 'content-type: application/json' "$HOST/api/register?token=$ALICE") + +echo "Unregistered alice: $SCORE" |
