pre_testing1/collatz_test.sh
changeset 346 663c2a9108d1
parent 345 40657f9a4e4a
child 352 97bcf8efe4e0
equal deleted inserted replaced
345:40657f9a4e4a 346:663c2a9108d1
    13 
    13 
    14 
    14 
    15 # compilation tests
    15 # compilation tests
    16 
    16 
    17 function scala_compile {
    17 function scala_compile {
    18   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out) 
    18   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
    19 }
    19 }
    20 
    20 
    21 # functional tests
    21 # functional tests
    22 
    22 
    23 function scala_assert {
    23 function scala_assert {
    25 }
    25 }
    26 
    26 
    27 # purity test
    27 # purity test
    28 
    28 
    29 function scala_vars {
    29 function scala_vars {
    30    (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|collection.mutable|util.control|new Array' "$1" 2> /dev/null 1> /dev/null)
    30    (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null)
    31 }
    31 }
       
    32 
       
    33 
       
    34 ### compilation test
       
    35 
       
    36 echo -e "collatz.scala runs?" >> $out
       
    37 
       
    38 if (scala_compile collatz.scala)
       
    39 then
       
    40     echo -e "  --> success" >> $out
       
    41     tsts=$(( 0 ))
       
    42 else
       
    43     echo -e "  --> SCALA DID NOT RUN collatz.scala\n" >> $out
       
    44     tsts=$(( 1 )) 
       
    45 fi
       
    46 
    32 
    47 
    33 
    48 
    34 # var, .par return, ListBuffer test
    49 # var, .par return, ListBuffer test
    35 #
    50 #
    36 echo -e "collatz.scala does not contain vars, returns etc?" >> $out
    51 echo -e "collatz.scala does not contain VARS, RETURNS etc?" >> $out
    37 
    52 
    38 if (scala_vars collatz.scala)
    53 if  [ $tsts -eq 0 ]
    39 then
    54 then 
    40   echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
    55    if (scala_vars collatz.scala)
    41   tsts0=$(( 0 ))
    56    then
    42 else
    57       echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
    43   echo -e "  --> success" >> $out
    58       tsts=$(( 1 ))
    44   tsts0=$(( 0 )) 
    59    else
    45 fi
    60       echo -e "  --> success" >> $out
       
    61       tsts=$(( 0 )) 
       
    62    fi
       
    63 fi    
    46 
    64 
    47 ### compilation test
       
    48 
       
    49 
       
    50 if  [ $tsts0 -eq 0 ]
       
    51 then 
       
    52   echo -e "collatz.scala runs?" >> $out
       
    53 
       
    54   if (scala_compile collatz.scala)
       
    55   then
       
    56     echo -e "  --> success" >> $out
       
    57     tsts=$(( 0 ))
       
    58   else
       
    59     echo -e "  --> SCALA DID NOT RUN COLLATZ.SCALA\n" >> $out
       
    60     tsts=$(( 1 )) 
       
    61   fi
       
    62 else
       
    63   tsts=$(( 1 ))     
       
    64 fi
       
    65 
    65 
    66 ### collatz tests
    66 ### collatz tests
    67 
    67 
    68 if [ $tsts -eq 0 ]
    68 if [ $tsts -eq 0 ]
    69 then
    69 then