コード例 #1
0
 function testfutureValue()
 {
     // various random calculations
     $this->assertTrue(abs(-22880.982149 - Math_Finance::futureValue(0.08, 20, 500)) < FINANCE_PRECISION);
     $this->assertTrue(abs(-1061.827162 - Math_Finance::futureValue(0.03, 5, 200)) < FINANCE_PRECISION);
     $this->assertTrue(abs(-1705.059664 - Math_Finance::futureValue(0.29, 7, 100)) < FINANCE_PRECISION);
     $this->assertTrue(abs(-700.0 - Math_Finance::futureValue(0, 7, 100)) < FINANCE_PRECISION);
     // cannot pass negative number of periods
     $this->assertType('object', Math_Finance::futureValue(0.29, -7, 100));
     // cannot pass a type differenet from 0 and 1
     $this->assertType('object', Math_Finance::futureValue(0.29, 7, 100, 0, 3));
 }