pre_marking3/postfix_test.sh
changeset 386 e2170c91a9f2
parent 384 6e1237691307
child 387 6282b88511d8
equal deleted inserted replaced
385:44383203970f 386:e2170c91a9f2
    28 }
    28 }
    29 
    29 
    30 # functional tests
    30 # functional tests
    31 
    31 
    32 function scala_assert {
    32 function scala_assert {
    33   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
    33   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
    34 }
    34 }
    35 
    35 
    36 # purity test
    36 # purity test
    37 
    37 
    38 function scala_vars {
    38 function scala_vars {
    56 
    56 
    57 # var, return, ListBuffer test
    57 # var, return, ListBuffer test
    58 #
    58 #
    59 if  [ $tsts -eq 0 ]
    59 if  [ $tsts -eq 0 ]
    60   then   
    60   then   
    61   echo -e "postfix.scala does not contain VARS, RETURNS etc??" | tee -a $out
    61   echo -e "postfix.scala does not contain VARS, RETURNS etc?" | tee -a $out
    62 
    62 
    63   if (scala_vars postfix.scala)
    63   if (scala_vars postfix.scala)
    64   then
    64   then
    65     echo -e "  --> FAIL\n" | tee -a $out  
    65     echo -e "  --> FAIL\n" | tee -a $out  
    66     tsts=$(( 1 ))
    66     tsts=$(( 1 ))
    67   else
    67   else
    68     echo -e "  --> success" | tee -a $out  
    68     echo -e "  --> success" | tee -a $out  
    69     tsts=$(( 0 )) 
    69     tsts=$(( 0 )) 
    70   fi
    70   fi
    71 else
    71 else
    72    tsts=$(( 1 ))  
    72   tsts=$(( 1 ))  
    73 fi  
    73 fi  
    74 
    74 
    75 
    75 
    76 
    76 
    77 ### postfix tests
    77 ### postfix tests
   183   echo -e " compute(syard(split(\"4 ^ 3 ^ 2\"))) == 262144" | tee -a $out
   183   echo -e " compute(syard(split(\"4 ^ 3 ^ 2\"))) == 262144" | tee -a $out
   184   echo -e " compute(syard(split(\"4 ^ ( 3 ^ 2 )\"))) == 262144" | tee -a $out
   184   echo -e " compute(syard(split(\"4 ^ ( 3 ^ 2 )\"))) == 262144" | tee -a $out
   185   echo -e " compute(syard(split(\"( 4 ^ 3 ) ^ 2\"))) == 4096" | tee -a $out
   185   echo -e " compute(syard(split(\"( 4 ^ 3 ) ^ 2\"))) == 4096" | tee -a $out
   186   echo -e " compute(syard(split(\"( 3 + 1 ) ^ 2 ^ 3\"))) == 65536" | tee -a $out
   186   echo -e " compute(syard(split(\"( 3 + 1 ) ^ 2 ^ 3\"))) == 65536" | tee -a $out
   187   
   187   
   188   if (scala_assert "postfix2.scala" "postfix_test10.scala")
   188   if (scala_assert "postfix2.scala" "postfix_test4.scala")
   189   then
   189   then
   190       echo -e "  --> success" | tee -a $out
   190       echo -e "  --> success" | tee -a $out
   191       marks=$(( marks + 0.5 ))
   191       marks=$(( marks + 0.5 ))
   192   else
   192   else
   193       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   193       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out