コード例 #1
0
 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));
 }
コード例 #2
0
ファイル: Calculator.php プロジェクト: theki/Calculator
 private function preparePostfixNotation()
 {
     $converter = new InfixToRPNconverter();
     return $converter->convert($this->formula);
 }