marking/drumb_test3.scala
changeset 281 87b9e3e2c1a7
parent 280 a057dc4457fc
child 282 ec9773fe1dc0
equal deleted inserted replaced
280:a057dc4457fc 281:87b9e3e2c1a7
     1 
       
     2 val test_data = List(List(Some(71.539941), None), List(Some(76.974614), None), 
       
     3                      List(Some(65.226685), Some(6.35)), List(Some(78.354649), Some(12.241)), 
       
     4                      List(Some(85.517645), Some(38.188)))
       
     5 
       
     6 val test_deltas = List(List(Some(0.07596697626574789), None), 
       
     7                        List(Some(-0.152620823795232), None), 
       
     8                        List(Some(0.20126676681483952), Some(0.9277165354330709)), 
       
     9                        List(Some(0.09141762603007778), Some(2.119679764725104)))
       
    10 
       
    11 assert((yearly_yield(test_deltas, 100, 0) - 107).abs <= 2)
       
    12 assert((yearly_yield(test_deltas, 100, 1) - 85).abs <= 2)
       
    13 assert((yearly_yield(test_deltas, 100, 2) - 156).abs <= 2)
       
    14 assert((yearly_yield(test_deltas, 100, 3) - 210).abs <= 2)
       
    15 assert((investment(List("IBM", "BIDU"), 2004 to 2008, 100) - 298).abs <= 10)
       
    16