public function testMultiplications()
 {
     $converter = new InfixToRPNconverter();
     $formula = '2*3*2';
     $result = $converter->convert($formula);
     $expected = array('2', '3', '*', '2', '*');
     $this->assertEquals(implode('', $expected), implode('', $result));
     $formula = '2*3*2-1';
     $result = $converter->convert($formula);
     $expected = array('2', '3', '*', '2', '*', '1', '-');
     $this->assertEquals(implode('', $expected), implode('', $result));
     $formula = '1+2*3*2';
     $result = $converter->convert($formula);
     $expected = array('1', '2', '3', '*', '2', '*', '+');
     $this->assertEquals(implode('', $expected), implode('', $result));
 }
Esempio n. 2
0
 private function preparePostfixNotation()
 {
     $converter = new InfixToRPNconverter();
     return $converter->convert($this->formula);
 }