diff -r d59c7995bcb2 -r 54befaf23648 testing1/drumb_test.sh --- a/testing1/drumb_test.sh Wed Nov 07 12:08:01 2018 +0000 +++ b/testing1/drumb_test.sh Thu Nov 08 23:42:03 2018 +0000 @@ -11,13 +11,13 @@ # compilation tests function scala_compile { - (ulimit -t 30 -m 1024000 ; scala "$1" 2>> $out 1>> $out) + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out) } # functional tests function scala_assert { - (ulimit -t 30 -m 1024000 ; scala -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null) + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null) } # purity test @@ -33,8 +33,8 @@ if (scala_vars drumb.scala) then - echo " --> fail" >> $out - tsts0=$(( 1 )) + echo " --> fail (make tripply-sure your program conforms to the required format)" >> $out + tsts0=$(( 0 )) else echo " --> success" >> $out tsts0=$(( 0 )) @@ -58,18 +58,46 @@ tsts=$(( 1 )) fi +### get january data +if [ $tsts -eq 0 ] +then + echo " get_january_data(\"GOOG\", 1980) == List()" >> $out + echo " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,311.349976\"" >> $out + + if (scala_assert "drumb.scala" "drumb_test1.scala") + then + echo " --> success" >> $out + else + echo " --> test failed" >> $out + fi +fi + +### get first price + +if [ $tsts -eq 0 ] +then + echo " get_first_price(\"GOOG\", 1980) == None" >> $out + echo " get_first_price(\"GOOG\", 2010) == Some(311.349976)" >> $out + + if (scala_assert "drumb.scala" "drumb_test2.scala") + then + echo " --> success" >> $out + else + echo " --> test failed" >> $out + fi +fi ### get prices tests if [ $tsts -eq 0 ] then echo " get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" >> $out - echo " List(List(Some(311.349976), Some(27.505054))," >> $out - echo " List(Some(300.222351), Some(42.357094))," >> $out - echo " List(Some(330.555054), Some(52.852215)))" >> $out + echo " List(List(Some(311.349976), Some(20.544939))," >> $out + echo " List(Some(300.222351), Some(31.638695))," >> $out + echo " List(Some(330.555054), Some(39.478039)))" >> $out - if (scala_assert "drumb.scala" "drumb_test1.scala") + if (scala_assert "drumb.scala" "drumb_test3.scala") then echo " --> success" >> $out else @@ -79,35 +107,35 @@ ### get_deltas_test -if [ $tsts -eq 0 ] -then - echo " get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " >> $out - echo " List(List(Some(-0.03573992567129673), Some(0.5399749442411563)), " >> $out - echo " List(Some(0.10103412653643493), Some(0.2477771728154912)))" >> $out - - if (scala_assert "drumb.scala" "drumb_test2.scala") - then - echo " --> success" >> $out - else - echo " --> test failed" >> $out - fi -fi +#if [ $tsts -eq 0 ] +#then +# echo " get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " >> $out +# echo " List(List(Some(-0.03573992567129673), Some(0.5399749442411563)), " >> $out +# echo " List(Some(0.10103412653643493), Some(0.2477771728154912)))" >> $out +# +# if (scala_assert "drumb.scala" "drumb_test2.scala") +# then +# echo " --> success" >> $out +# else +# echo " --> test failed" >> $out +# fi +#fi ### yield_tests, investment_test -if [ $tsts -eq 0 ] -then - echo " yearly_yield(get_deltas(<>), 100, 0) == 125" >> $out - echo "" >> $out - echo " investment(rstate_portfolio, 1978 to 2017, 100) == 30895" >> $out - echo " investment(bchips_portfolio, 1978 to 2017, 100) == 349597" >> $out - - if (scala_assert "drumb.scala" "drumb_test3.scala") - then - echo " --> success" >> $out - else - echo " --> test failed" >> $out - fi -fi +#if [ $tsts -eq 0 ] +#then +# echo " yearly_yield(get_deltas(<>), 100, 0) == 125" >> $out +# echo "" >> $out +# echo " investment(rstate_portfolio, 1978 to 2017, 100) == 30895" >> $out +# echo " investment(bchips_portfolio, 1978 to 2017, 100) == 349597" >> $out +# +# if (scala_assert "drumb.scala" "drumb_test3.scala") +# then +# echo " --> success" >> $out +# else +# echo " --> test failed" >> $out +# fi +#fi