marking4/re_test.sh
changeset 332 703c7e42bf46
parent 288 65731df141a5
child 333 24bc76d97db2
equal deleted inserted replaced
331:e3878cdd38bc 332:703c7e42bf46
    24 }
    24 }
    25 
    25 
    26 # functional tests
    26 # functional tests
    27 
    27 
    28 function scala_assert {
    28 function scala_assert {
    29     (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
    29     (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
    30 }
    30 }
    31 
    31 
    32 function scala_assert_long {
    32 function scala_assert_long {
    33     (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
    33     (ulimit -t 80; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 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 {
   102   echo -e " der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')" | tee -a $out
   102   echo -e " der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')" | tee -a $out
   103   echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" | tee -a $out
   103   echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" | tee -a $out
   104   echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
   104   echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
   105   echo -e "" | tee -a $out
   105   echo -e "" | tee -a $out
   106   echo -e " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
   106   echo -e " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
   107   echo -e " assert(der('a', r0) == (ONE ~ \"b\") ~ \"c\")" | tee -a $out
   107   echo -e " der('a', r0) == (ONE ~ \"b\") ~ \"c\"" | tee -a $out
   108   echo -e " assert(der('b', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
   108   echo -e " der('b', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
   109   echo -e " assert(der('c', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
   109   echo -e " der('c', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
   110   echo -e "" | tee -a $out
   110   echo -e "" | tee -a $out
   111   echo -e " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
   111   echo -e " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
   112   echo -e " assert(der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
   112   echo -e " der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\"" | tee -a $out
   113   echo -e " assert(der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\")" | tee -a $out
   113   echo -e " der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
   114   echo -e " assert(der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
   114   echo -e " der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\"" | tee -a $out
   115   echo -e "" | tee -a $out
   115   echo -e "" | tee -a $out
   116   echo -e " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
   116   echo -e " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
   117   echo -e " assert(der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
   117   echo -e " der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO)" | tee -a $out
   118   echo -e " assert(der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
   118   echo -e " der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO)" | tee -a $out
   119   echo -e " assert(der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE))" | tee -a $out
   119   echo -e " der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE)" | tee -a $out
   120 
   120 
   121   if (scala_assert "re.scala" "re_test2.scala")
   121   if (scala_assert "re.scala" "re_test2.scala")
   122   then
   122   then
   123       echo -e "  --> success" | tee -a $out
   123       echo -e "  --> success" | tee -a $out
   124       marks=$(( marks + 1 ))
   124       marks=$(( marks + 1 ))
   144   echo -e " simp(ALT((CHAR('a') | ZERO) ~ ONE," | tee -a $out
   144   echo -e " simp(ALT((CHAR('a') | ZERO) ~ ONE," | tee -a $out
   145   echo -e "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" | tee -a $out
   145   echo -e "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" | tee -a $out
   146   echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" | tee -a $out
   146   echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" | tee -a $out
   147   echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
   147   echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
   148   echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
   148   echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
   149   echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" tee -a $out
   149   echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" | tee -a $out
   150   
   150   
   151   if (scala_assert "re.scala" "re_test3.scala")
   151   if (scala_assert "re.scala" "re_test3.scala")
   152   then
   152   then
   153       echo -e "  --> success" | tee -a $out
   153       echo -e "  --> success" | tee -a $out
   154       marks=$(( marks + 1 ))
   154       marks=$(( marks + 1 ))
   224   echo -e "    ... the Iterator produces a rexp of size 2097151" | tee -a $out
   224   echo -e "    ... the Iterator produces a rexp of size 2097151" | tee -a $out
   225   echo -e "" | tee -a $out
   225   echo -e "" | tee -a $out
   226   echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
   226   echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
   227   echo -e " matcher(EVIL, \"a\" * 1000000 ++ \"b\") == true" | tee -a $out
   227   echo -e " matcher(EVIL, \"a\" * 1000000 ++ \"b\") == true" | tee -a $out
   228   echo -e " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
   228   echo -e " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
   229 
   229   START=$(date +%s)
   230   
   230   
   231   if (time scala_assert_long "re.scala" "re_test6.scala")
   231   if (scala_assert_long "re.scala" "re_test6.scala")
   232   then
   232   then
   233       echo -e "  --> success" | tee -a $out
   233       END=$(date +%s)
   234       marks=$(( marks + 1 ))
   234       DIFF=$(( $END - $START ))
   235   else
   235       echo "  It took $DIFF seconds" | tee -a $out
       
   236       echo -e "  --> success" | tee -a $out
       
   237       marks=$(( marks + 1 ))
       
   238   else
       
   239       END=$(date +%s)
       
   240       DIFF=$(( $END - $START ))
       
   241       echo "  It took $DIFF seconds" | tee -a $out
   236       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   242       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   237   fi
   243   fi
   238 fi
   244 fi
   239 
   245 
   240 
   246