pre_testing1/collatz_test.sh
changeset 360 e45d2890749d
parent 356 d1046d9d3213
child 376 6cc36d0ef79e
equal deleted inserted replaced
359:8aaf187d25f0 360:e45d2890749d
     5 
     5 
     6 
     6 
     7 out=${1:-output}
     7 out=${1:-output}
     8 
     8 
     9 echo -e "" > $out
     9 echo -e "" > $out
    10 echo -e "" > c$out
       
    11 
    10 
    12 echo -e "Below is the feedback for your submission collatz.scala" >> $out
    11 echo -e "Below is the feedback for your submission collatz.scala" >> $out
    13 echo -e "" >> $out
    12 echo -e "" >> $out
    14 
    13 
    15 
    14 
    16 # compilation tests
    15 # compilation tests
    17 
    16 
    18 function scala_compile {
    17 function scala_compile {
    19   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2>> $out 1>> $out)
    18   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
    20 }
    19 }
    21 
    20 
    22 # functional tests
    21 # functional tests
    23 
    22 
    24 function scala_assert {
    23 function scala_assert {
    25   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
    24   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
    26 }
    25 }
    27 
    26 
    28 # purity test
    27 # purity test
    29 
    28 
    30 function scala_vars {
    29 function scala_vars {
    36 
    35 
    37 echo -e "collatz.scala runs?" >> $out
    36 echo -e "collatz.scala runs?" >> $out
    38 
    37 
    39 if (scala_compile collatz.scala)
    38 if (scala_compile collatz.scala)
    40 then
    39 then
    41     echo -e "  --> passed" >> $out
    40     echo -e "  --> success" >> $out
    42     tsts=$(( 0 ))
    41     tsts=$(( 0 ))
    43 else
    42 else
    44     echo -e "  --> SCALA DID NOT RUN collatz.scala\n" >> $out
    43     echo -e "  --> SCALA DID NOT RUN collatz.scala\n" >> $out
    45     tsts=$(( 1 )) 
    44     tsts=$(( 1 )) 
    46 fi
    45 fi
    57    if (scala_vars collatz.scala)
    56    if (scala_vars collatz.scala)
    58    then
    57    then
    59       echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
    58       echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
    60       tsts=$(( 1 ))
    59       tsts=$(( 1 ))
    61    else
    60    else
    62       echo -e "  --> passed" >> $out
    61       echo -e "  --> success" >> $out
    63       tsts=$(( 0 )) 
    62       tsts=$(( 0 )) 
    64    fi
    63    fi
    65 fi    
    64 fi    
    66 
    65 
    67 
    66