testing5/bf_test.sh
changeset 286 5c57c407e27b
parent 266 ca48ac1d3c3e
child 340 9eeab89d0671
equal deleted inserted replaced
285:bd9d142d2cd8 286:5c57c407e27b
     1 #!/bin/bash
     1 #!/bin/bash
     2 set -e
     2 set -euo pipefail
     3 
     3 
     4 out=${1:-output}
     4 out=${1:-output}
     5 
     5 
     6 echo -e "" > $out
     6 echo -e "" > $out
     7 
     7 
     8 echo -e "Below is the feedback for your submission of CW 10, Part 1." >> $out
     8 echo -e "Below is the feedback for your submission of CW 10." >> $out
     9 echo -e "" >> $out
     9 echo -e "" >> $out
    10 
    10 
    11 
    11 
    12 # compilation tests
    12 # compilation tests
    13 
    13 
    16 }
    16 }
    17 
    17 
    18 # functional tests
    18 # functional tests
    19 
    19 
    20 function scala_assert {
    20 function scala_assert {
    21   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)   
    21   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)   
    22 }
    22 }
    23 
    23 
    24 # purity test
    24 # purity test
    25 
    25 
    26 function scala_vars {
    26 function scala_vars {
    32 #
    32 #
    33 echo -e "bf.scala does not contain vars, returns etc?" >> $out
    33 echo -e "bf.scala does not contain vars, returns etc?" >> $out
    34 
    34 
    35 if (scala_vars bf.scala)
    35 if (scala_vars bf.scala)
    36 then
    36 then
    37   echo -e "   --> fail (make triple-sure your program conforms to the required format)" >> $out  
    37   echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out  
    38   tsts0=$(( 0 ))
    38   tsts0=$(( 0 ))
    39 else
    39 else
    40   echo -e "  --> success" >> $out
    40   echo -e "  --> success" >> $out
    41   tsts0=$(( 0 )) 
    41   tsts0=$(( 0 )) 
    42 fi
    42 fi
    50   if (scala_compile bf.scala)
    50   if (scala_compile bf.scala)
    51   then
    51   then
    52     echo -e "  --> success" >> $out
    52     echo -e "  --> success" >> $out
    53     tsts1=$(( 0 ))
    53     tsts1=$(( 0 ))
    54   else
    54   else
    55     echo -e "  -->   --> SCALA DID NOT RUN BF.SCALA\nx" >> $out
    55     echo -e "  --> SCALA DID NOT RUN BF.SCALA\n" >> $out
    56     tsts1=$(( 1 )) 
    56     tsts1=$(( 1 )) 
    57   fi
    57   fi
    58 else
    58 else
    59   tsts1=$(( 1 ))     
    59   tsts1=$(( 1 ))     
    60 fi
    60 fi