marking/test
changeset 93 21f41e08457d
equal deleted inserted replaced
92:cfff88de2ff5 93:21f41e08457d
       
     1 #!/bin/bash
       
     2 set -e
       
     3 
       
     4 out=${1:-output-test}
       
     5 
       
     6 
       
     7 function scala_vars {
       
     8    (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
       
     9 }
       
    10 
       
    11 
       
    12 # compilation tests
       
    13 
       
    14 function scala_compile {
       
    15   (scala "$1" 2> /dev/null 1> /dev/null) 
       
    16 }
       
    17 
       
    18 
       
    19 # functional tests
       
    20 
       
    21 function scala_assert {
       
    22   (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
       
    23 }
       
    24 
       
    25 
       
    26 
       
    27 # var, return, ListBuffer test
       
    28 #
       
    29 #echo "re.scala does not contain vars, returns etc?" | tee -a $out
       
    30 
       
    31 if (scala_vars re.scala)
       
    32 then
       
    33   #echo "  --> fail" | tee -a $out
       
    34   tsts0=$(( 1 ))
       
    35 else
       
    36   #echo "  --> yes" | tee -a $out
       
    37   tsts0=$(( 0 )) 
       
    38 fi
       
    39 
       
    40 
       
    41 # compilation test
       
    42 if  [ $tsts0 -eq 0 ]
       
    43 then    
       
    44   #echo "re.scala runs?" | tee -a $out
       
    45 
       
    46   if (scala_compile re.scala.bak)
       
    47   then
       
    48     #echo "  --> yes" | tee -a $out
       
    49     tsts1=$(( 0 ))
       
    50   else
       
    51     #echo "  --> scala re.scala did not run successfully" | tee -a $out
       
    52     tsts1=$(( 1 )) 
       
    53   fi
       
    54 else
       
    55   tsts1=$(( 1 ))     
       
    56 fi
       
    57 
       
    58 
       
    59 if [ $tsts1 -eq 0 ]
       
    60 then
       
    61   if (scala_assert "re.scala.bak" "../../../marking/re1d_test.scala")
       
    62   then
       
    63     echo "  --> success" | tee -a $out
       
    64     t1=$(( 1 ))
       
    65   else
       
    66     echo "  --> test failed" | tee -a $out
       
    67     t1=$(( 0 ))   
       
    68   fi
       
    69 else  
       
    70   t1=$(( 0 ))
       
    71 fi
       
    72 
       
    73 if [ $tsts1 -eq 0 ]
       
    74 then
       
    75   if (scala_assert "re.scala.bak" "../../../marking/re1d_bug_test.scala")
       
    76   then
       
    77     echo "  bug --> success" | tee -a $out
       
    78     t2=$(( 1 ))
       
    79   else
       
    80     echo "  bug --> test failed" | tee -a $out
       
    81     t2=$(( 0 ))  
       
    82   fi
       
    83 else  
       
    84   t2=$(( 0 ))
       
    85 fi
       
    86 
       
    87 if [ $t1 -ne $t2 ]
       
    88 then
       
    89   echo "disagree"
       
    90   pwd
       
    91 fi
       
    92