Exemplo n.º 1
0
    def test_num_divide_num_plus(self):
        dsp.process('4', self.operandstack, self.operatorstack)
        dsp.process('/', self.operandstack, self.operatorstack)
        dsp.process('2', self.operandstack, self.operatorstack)
        dsp.process('+', self.operandstack, self.operatorstack)

        self.assertEquals([2], dsp._dump(self.operandstack))
        self.assertEquals(['+'], dsp._dump(self.operatorstack))
Exemplo n.º 2
0
    def test_num_subtract_num_divide(self):
        dsp.process('4', self.operandstack, self.operatorstack)
        dsp.process('-', self.operandstack, self.operatorstack)
        dsp.process('2', self.operandstack, self.operatorstack)
        dsp.process('/', self.operandstack, self.operatorstack)

        self.assertEquals([4, 2], dsp._dump(self.operandstack))
        self.assertEquals(['-', '/'], dsp._dump(self.operatorstack))
Exemplo n.º 3
0
    def test_num_subtract_num_plus(self):
        dsp.process('3', self.operandstack, self.operatorstack)
        dsp.process('-', self.operandstack, self.operatorstack)
        dsp.process('2', self.operandstack, self.operatorstack)
        dsp.process('+', self.operandstack, self.operatorstack)

        self.assertEquals([1], dsp._dump(self.operandstack))
        self.assertEquals(['+'], dsp._dump(self.operatorstack))
Exemplo n.º 4
0
    def test_num_multiply_num_plus(self):
        dsp.process('3', self.operandstack, self.operatorstack)
        dsp.process('*', self.operandstack, self.operatorstack)
        dsp.process('2', self.operandstack, self.operatorstack)
        dsp.process('+', self.operandstack, self.operatorstack)

        self.assertEquals([6], dsp._dump(self.operandstack))
        self.assertEquals(['+'], dsp._dump(self.operatorstack))
Exemplo n.º 5
0
    def test_result_calc_once(self):
        dsp.process('1', self.operandstack, self.operatorstack)
        dsp.process('+', self.operandstack, self.operatorstack)
        dsp.process('2', self.operandstack, self.operatorstack)

        self.assertEquals(3, dsp.result(self.operandstack, self.operatorstack))
        self.assertEquals([], dsp._dump(self.operandstack))
        self.assertEquals([], dsp._dump(self.operatorstack))
Exemplo n.º 6
0
    def test_result_num(self):
        dsp.process('3', self.operandstack, self.operatorstack)

        self.assertEquals(3, dsp.result(self.operandstack, self.operatorstack))
        self.assertEquals([], dsp._dump(self.operandstack))
        self.assertEquals([], dsp._dump(self.operatorstack))