main_testing3/re_test.sh
changeset 433 6af86ba1208f
parent 426 b51467741af2
child 445 b73e7ce91c10
equal deleted inserted replaced
432:de701b64a4e0 433:6af86ba1208f
    51 then
    51 then
    52     echo -e "re.scala does not contain vars, returns etc?" >> $out
    52     echo -e "re.scala does not contain vars, returns etc?" >> $out
    53 
    53 
    54     if (scala_vars re.scala)
    54     if (scala_vars re.scala)
    55     then
    55     then
    56 	echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out 
    56 	echo -e "  --> FAIL (make triple-sure your program conforms to the required format)" >> $out 
    57 	tsts=$(( 1 ))
    57 	tsts=$(( 1 ))
    58     else
    58     else
    59 	echo -e "  --> passed" >> $out
    59 	echo -e "  --> passed" >> $out
    60 	tsts=$(( 0 )) 
    60 	tsts=$(( 0 )) 
    61     fi
    61     fi
    87   echo -e " nullable(ZERO | ONE) == true" >> $out
    87   echo -e " nullable(ZERO | ONE) == true" >> $out
    88   echo -e " nullable(ZERO | CHAR('a')) == false" >> $out
    88   echo -e " nullable(ZERO | CHAR('a')) == false" >> $out
    89   echo -e " nullable(ONE ~  ONE) == true" >> $out
    89   echo -e " nullable(ONE ~  ONE) == true" >> $out
    90   echo -e " nullable(ONE ~ CHAR('a')) == false" >> $out
    90   echo -e " nullable(ONE ~ CHAR('a')) == false" >> $out
    91   echo -e " nullable(STAR(ZERO)) == true" >> $out
    91   echo -e " nullable(STAR(ZERO)) == true" >> $out
       
    92   echo -e " nullable(ALTs(List(ONE, CHAR('a'), ZERO))) == true" >> $out
       
    93   echo -e " nullable(SEQs(List(ONE, ALTs(List(ONE, CHAR('a'), ZERO)), STAR(ZERO)))) == true" >> $out
    92   
    94   
    93   if (scala_assert "re.scala" "re_test1.scala")
    95   if (scala_assert "re.scala" "re_test1.scala")
    94   then
    96   then
    95     echo -e "  --> success" >> $out
    97     echo -e "  --> success" >> $out
    96   else
    98   else
    97     echo -e "  --> \n ONE TEST FAILED\n" >> $out
    99     echo -e "  --> \n ONE TEST FAILED\n" >> $out
    98   fi
   100   fi
    99 fi
   101 fi
   100 
       
   101 
   102 
   102 
   103 
   103 if [ $tsts -eq 0 ]
   104 if [ $tsts -eq 0 ]
   104 then
   105 then
   105   echo -e " der('a', ZERO | ONE) == (ZERO | ZERO)" >> $out
   106   echo -e " der('a', ZERO | ONE) == (ZERO | ZERO)" >> $out
   106   echo -e " der('a', (CHAR('a') | ONE) ~ CHAR('a')) ==" >> $out
   107   echo -e " der('a', (CHAR('a') | ONE) ~ CHAR('a')) ==" >> $out
   107   echo -e "                 ALT((ONE | ZERO) ~ CHAR('a'), ONE)" >> $out
   108   echo -e "                 ALT((ONE | ZERO) ~ CHAR('a'), ONE)" >> $out
       
   109   echo -e " der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')" >> $out
   108   echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" >> $out
   110   echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" >> $out
   109   echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" >> $out
   111   echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" >> $out
   110   
   112   
   111   if (scala_assert "re.scala" "re_test2.scala")
   113   if (scala_assert "re.scala" "re_test2.scala")
   112   then
   114   then
   113     echo -e "  --> success" >> $out
   115     echo -e "  --> success" >> $out
   114   else
   116   else
   115     echo -e "  --> \n ONE TEST FAILED\n" >> $out
   117     echo -e "  --> \n ONE TEST FAILED\n" >> $out
   116   fi
   118   fi
   117 fi
   119 fi
   118 
       
   119 
   120 
   120 
   121 
   121 if [ $tsts -eq 0 ]
   122 if [ $tsts -eq 0 ]
   122 then
   123 then
   123   echo -e " simp(ZERO | ONE) == ONE" >> $out
   124   echo -e " simp(ZERO | ONE) == ONE" >> $out
   134   echo -e "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" >> $out
   135   echo -e "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" >> $out
   135   echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" >> $out
   136   echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" >> $out
   136   echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" >> $out
   137   echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" >> $out
   137   echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" >> $out
   138   echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" >> $out
   138   echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE, CHAR('a'))" >> $out
   139   echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE, CHAR('a'))" >> $out
       
   140   echo -e " simp(ALTs(Nil)) == ZERO" >> $out
       
   141   echo -e " simp(SEQs(CHAR('a'))) == CHAR('a')" >> $out
   139   if (scala_assert "re.scala" "re_test3.scala")
   142   if (scala_assert "re.scala" "re_test3.scala")
   140   then
   143   then
   141     echo -e "  --> success" >> $out
   144     echo -e "  --> success" >> $out
   142   else
   145   else
   143     echo -e "  --> \n ONE TEST FAILED\n" >> $out
   146     echo -e "  --> \n ONE TEST FAILED\n" >> $out
       
   147   fi
       
   148 fi
       
   149 
       
   150 
       
   151 if [ $tsts -eq 0 ]
       
   152 then
       
   153     echo -e " denest(List(ONE, ZERO, ALTs(List(ONE, CHAR('a'))))) == List(ONE, ONE, CHAR('a'))" >> $out
       
   154     echo -e " denest(List(ONE ~ ONE, ZERO, ZERO | ONE)) == List(ONE ~ ONE, ZERO, ONE)" >> $out
       
   155   
       
   156   if (scala_assert "re.scala" "re_test4.scala")
       
   157   then
       
   158     echo -e "  --> success" >> $out
       
   159   else
       
   160     echo -e "  --> \n ONE TEST FAILED\n" >> $out   
       
   161   fi
       
   162 fi
       
   163 
       
   164 
       
   165 if [ $tsts -eq 0 ]
       
   166 then
       
   167     echo -e " flts(List(CHAR('a'), ZERO, ONE), Nil) == List(ZERO)" >> $out
       
   168     echo -e " flts(List(CHAR('a'), ONE, ONE, CHAR('b')), Nil) == List(CHAR('a'), CHAR('b'))" >> $out
       
   169     echo -e " flts(List(ONE ~ CHAR('a'), CHAR('b') ~ ONE), Nil) == List(ONE, CHAR('a'), CHAR('b'), ONE)" >> $out
       
   170   
       
   171   if (scala_assert "re.scala" "re_test5.scala")
       
   172   then
       
   173     echo -e "  --> success" >> $out
       
   174   else
       
   175     echo -e "  --> \n ONE TEST FAILED\n" >> $out   
       
   176   fi
       
   177 fi
       
   178 
       
   179 
       
   180 if [ $tsts -eq 0 ]
       
   181 then
       
   182     echo -e " SEQs_smart(Nil) == ONE" >> $out
       
   183     echo -e " SEQs_smart(List(ZERO)) == ZERO" >> $out
       
   184     echo -e " SEQs_smart(List(CHAR('a'))) == CHAR('a')" >> $out
       
   185     echo -e " SEQs_smart(List(ONE ~ ONE)) == ONE ~ ONE" >> $out
       
   186     echo -e " SEQs_smart(List(ONE, ONE)) == SEQs(List(ONE, ONE))" >> $out
       
   187     echo -e " ALTs_smart(Nil) == ZERO" >> $out
       
   188     echo -e " ALTs_smart(List(ONE ~ ONE)) == ONE ~ ONE)" >> $out
       
   189     echo -e " ALTs_smart(List(ZERO, ZERO)) == ALTs(List(ZERO, ZERO))" >> $out
       
   190   
       
   191   if (scala_assert "re.scala" "re_test6.scala")
       
   192   then
       
   193     echo -e "  --> success" >> $out
       
   194   else
       
   195     echo -e "  --> \n ONE TEST FAILED\n" >> $out   
   144   fi
   196   fi
   145 fi
   197 fi
   146 
   198 
   147 
   199 
   148 if [ $tsts -eq 0 ]
   200 if [ $tsts -eq 0 ]
   159   echo -e " matcher(ONE, \"\") == true" >> $out
   211   echo -e " matcher(ONE, \"\") == true" >> $out
   160   echo -e " matcher(ZERO, \"\") == false" >> $out
   212   echo -e " matcher(ZERO, \"\") == false" >> $out
   161   echo -e " matcher(ONE | CHAR('a'), \"\") == true" >> $out
   213   echo -e " matcher(ONE | CHAR('a'), \"\") == true" >> $out
   162   echo -e " matcher(ONE | CHAR('a'), \"a\") == true" >> $out
   214   echo -e " matcher(ONE | CHAR('a'), \"a\") == true" >> $out
   163   
   215   
   164   if (scala_assert "re.scala" "re_test4.scala")
   216   if (scala_assert "re.scala" "re_test7.scala")
   165   then
   217   then
   166     echo -e "  --> success" >> $out
   218     echo -e "  --> success" >> $out
   167   else
   219   else
   168     echo -e "  --> \n ONE TEST FAILED\n" >> $out  
   220     echo -e "  --> \n ONE TEST FAILED\n" >> $out  
   169   fi
   221   fi
   171 
   223 
   172 
   224 
   173 if [ $tsts -eq 0 ]
   225 if [ $tsts -eq 0 ]
   174 then
   226 then
   175   echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" >> $out  
   227   echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" >> $out  
   176   echo -e " size(der('a', der('a', EVIL))) == 28" >> $out
   228   echo -e " size(der('a', der('a', EVIL))) == 36" >> $out
   177   echo -e " size(der('a', der('a', der('a', EVIL)))) == 58" >> $out
   229   echo -e " size(der('a', der('a', der('a', EVIL)))) == 83" >> $out
   178   echo -e " size(ders(\"aaaaaa\".toList, EVIL)) == 8" >> $out
   230   echo -e " size(ders(\"aaaaaa\".toList, EVIL)) == 7" >> $out
   179   
   231   echo -e " size(ders((\"a\" * 50).toList, EVIL)) == 7" >> $out
   180   if (scala_assert "re.scala" "re_test5.scala")
   232   
   181   then
   233   if (scala_assert "re.scala" "re_test8.scala")
   182     echo -e "  --> success" >> $out
   234   then
   183   else
   235     echo -e "  --> success" >> $out
   184     echo -e "  --> \n ONE TEST FAILED\n" >> $out   
   236   else
   185   fi
   237     echo -e "  --> \n ONE TEST FAILED\n" >> $out   
   186 fi
   238   fi
   187 
   239 fi
   188 
   240 
       
   241