function testpresentValue() { // various random calculations $this->assertTrue(abs(-4909.073704 - Math_Finance::presentValue(0.08, 20, 500)) < FINANCE_PRECISION); $this->assertTrue(abs(-915.941437 - Math_Finance::presentValue(0.03, 5, 200)) < FINANCE_PRECISION); $this->assertTrue(abs(-286.821438 - Math_Finance::presentValue(0.29, 7, 100)) < FINANCE_PRECISION); $this->assertTrue(abs(-700.0 - Math_Finance::presentValue(0, 7, 100)) < FINANCE_PRECISION); // cannot pass negative number of periods $this->assertType('object', Math_Finance::presentValue(0.29, -7, 100)); // cannot pass a type different from 0 and 1 $this->assertType('object', Math_Finance::presentValue(0.29, 7, 100, 0, 3)); }