main_testing2/wordle_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 02 Nov 2023 23:34:53 +0000
changeset 475 59e005dcf163
parent 463 0315d9983cd0
child 477 a4e1f63157d8
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
436
Christian Urban <christian.urban@kcl.ac.uk>
parents: 435
diff changeset
     1
#!/bin/bash
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
# to make the script fail safely
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
set -euo pipefail
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
out=${1:-output}
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
echo -e "" > $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
echo "The feedback for your submission for wordle.scala" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
echo "" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
# marks for main part 2
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
# compilation tests
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
function scala_compile {
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 463
diff changeset
    19
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala-cli compile "$1" 2> c$out 1> c$out)
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
}
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
# functional tests
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
function scala_assert {
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 463
diff changeset
    25
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala-cli -i "$1" "$2" -e "urbanmain()" 2> /dev/null 1> /dev/null)
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
}
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 463
diff changeset
    27
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
# purity test
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
function scala_vars {
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
   (sed 's/immutable/ok/g' c$out > cb$out;
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
    egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
}
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
### compilation test
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
echo -e "wordle.scala runs?" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
if (scala_compile wordle.scala)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
    echo -e "  --> success" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
    tsts0=$(( 0 ))
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
    echo -e "  --> SCALA DID NOT RUN wordle.scala\n" >> $out
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 463
diff changeset
    45
    echo -e "  --> try running scala-cli compile wordle.scala on your own computer\n" >> $out
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
    tsts0=$(( 1 )) 
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
# var, .par return, ListBuffer test
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
#
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
if  [ $tsts0 -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
   echo -e "wordle.scala does not contain VARS, RETURNS etc?" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
    
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
   if (scala_vars wordle.scala)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
   then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
      echo -e "  --> test failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
      tsts=$(( 1 ))
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
   else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
      echo -e "  --> success" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
      tsts=$(( 0 )) 
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
   fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
   tsts=$(( 1 ))  
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
fi    
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
echo >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
### wordle tests: Task 1 (0.25%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
  echo "Task 1:"  >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
  echo "  val wordle_url = \"\"\"https://nms.kcl.ac.uk/christian.urban/wordle.txt\"\"\""     >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
  echo "  val secrets = get_wordle_list(wordle_url)"     >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
  echo "  secrets.length == 12972"    >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
  echo "  secrets.filter(_.length != 5) == Nil" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
  echo "  get_wordle_list(wordle_url ++ \"2\") == Nil" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
  
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
  if (scala_assert "wordle.scala" "wordle_test1.scala")
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
      echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
### wordle tests: Task 2 (0.25%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
  echo "Task 2:"  >> $out  
439
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
    96
  echo "  removeN(List(1,2,3,2,1), 3, 1) == List(1, 2, 2, 1)" >> $out
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
    97
  echo "  removeN(List(1,2,3,2,1), 2, 1) == List(1, 3, 2, 1)" >> $out
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
    98
  echo "  removeN(List(1,2,3,2,1), 1, 1) == List(2, 3, 2, 1)" >> $out
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
    99
  echo "  removeN(List(1,2,3,2,1), 0, 1) == List(1, 2, 3, 2, 1)" >> $out
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
   100
  echo "  removeN(List(\"a\", \"b\", \"b\"), \"b\", 1) == List(\"a\", \"b\")" >> $out
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
   101
  echo "  removeN(List(\"b\", \"a\", \"b\", \"b\"), \"b\", 2) == List(\"a\", \"b\")" >> $out
97594b9998a8 updated jars
Christian Urban <christian.urban@kcl.ac.uk>
parents: 436
diff changeset
   102
  echo "  removeN(List(\"b\", \"a\", \"b\"), \"a\", 2) == List(\"b\", \"b\")" >> $out
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
  if (scala_assert "wordle.scala" "wordle_test2.scala")
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
      echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
### wordle tests: Task 3 (1.5%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
  echo "Task 3:"  >> $out    
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
  echo "  pool(\"chess\", \"caves\").toSet == Set('h', 'e', 's')" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
  echo "  pool(\"chess\", \"swiss\").toSet == Set('c', 'h', 'e')" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
  if (scala_assert "wordle.scala" "wordle_test3a.scala") 
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
    echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
then    
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
  echo "  score(\"chess\", \"caves\") == List(C, A, A, P, C)" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
  echo "  score(\"doses\", \"slide\") == List(P, A, A, P, P)" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
  echo "  score(\"chess\", \"swiss\") == List(A, A, A, C, C)" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
  echo "  score(\"chess\", \"eexss\") == List(P, A, A, C, C)" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
  echo "" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  echo "  val p = pool(\"chess\", \"caves\")"     >> $out
452
4772b6166720 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 439
diff changeset
   137
  echo "  aux(\"chess\".toList, \"caves\".toList, Nil) == List(C, A, A, A, C)" >> $out
4772b6166720 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 439
diff changeset
   138
  echo "  aux(\"chess\".toList, \"caves\".toList, p)   == List(C, A, A, P, C)" >> $out
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
  if (scala_assert "wordle.scala" "wordle_test3b.scala") 
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
    echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
### wordle tests: Task 4 (0.5%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
  echo "Task 4:"  >> $out  
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
  echo "  iscore(\"chess\", \"caves\") == 21" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
  echo "  iscore(\"chess\", \"swiss\") == 20" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
 
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
  if (scala_assert "wordle.scala" "wordle_test4.scala")
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
      echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
### wordle tests: Task 5 (1.5%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
  echo "Task 5:"  >> $out  
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
  echo "  val secrets = ..." >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
  echo "  evil(secrets, \"stent\").length == 1907" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
  echo "  evil(secrets, \"hexes\").length == 2966" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
  echo "  evil(secrets, \"horse\").length == 1203" >> $out
455
557d18cce0f0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 452
diff changeset
   174
  echo "  evil(secrets, \"hoise\").length == 971" >> $out
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
  echo "  evil(secrets, \"house\").length == 1228" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
  if (scala_assert "wordle.scala" "wordle_test5.scala")
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
      echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
### wordle tests: Task 6 (1.0%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
  echo "Task 6:"  >> $out  
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
  echo "  val secrets = ..." >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
  echo "  frequencies(secrets)('y') == 0.9680234350909651" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
  echo "  frequencies(secrets)('e') == 0.897286463151403"  >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
  echo "  frequencies(secrets)('z') == 0.9933086648165279" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
  if (scala_assert "wordle.scala" "wordle_test6.scala")
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
  then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
  else
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
      echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   201
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
### wordle tests: Task 7 (1.0%)
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   205
if [ $tsts -eq 0 ]
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
then
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   207
  echo "Task 7:"  >> $out  
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   208
  echo "  val secrets = ..." >> $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   209
  echo "  ranked_evil(secrets, \"beats\") == List(\"fuzzy\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   210
  echo "  ranked_evil(secrets, \"vitae\") == List(\"fuzzy\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   211
  echo "  ranked_evil(secrets, \"bento\") == List(\"fuzzy\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   212
  echo "  ranked_evil(secrets, \"belts\") == List(\"fuzzy\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   213
  echo " " >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   214
  echo "  ranked_evil(secrets, \"abbey\") == List(\"whizz\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   215
  echo "  ranked_evil(secrets, \"afear\") == List(\"buzzy\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   216
  echo "  ranked_evil(secrets, \"zincy\") == List(\"jugum\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   217
  echo "  ranked_evil(secrets, \"zippy\") == List(\"chuff\")" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   218
  START=$(date +%s)
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   219
  if (scala_assert "wordle.scala" "wordle_test7.scala")
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   220
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   221
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   222
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   223
      echo " This test ran for $DIFF seconds." >> $out
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
      echo -e "  --> success\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
  else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   226
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   227
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 455
diff changeset
   228
      echo " This test ran for $DIFF seconds." >> $out
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
      echo -e "  --> one of the tests failed\n" >> $out
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   230
  fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
fi
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   232
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   235