Beispiel #1
0
    def test_basic(self):
        app = AppLogic(ViewStub())
        app.stack = [1, 2]
        app.cmdPlus()
        self.assertEqual(app.stack, [3.0])

        app.stack = [1, 2]
        app.cmdMinus()
        self.assertEqual(app.stack, [-1.0])

        app.stack = [1, 2]
        app.cmdTimes()
        self.assertEqual(app.stack, [2.0])

        app.stack = [1, 2]
        app.cmdDiv()
        self.assertEqual(app.stack, [0.5])
Beispiel #2
0
    def test_stack(self):
        app = AppLogic(ViewStub())

        app.stack = [1, 2, 3, 4]
        app.cmdRotateLeft()
        self.assertEqual(app.stack, [2, 3, 4, 1])

        app.stack = [1, 2, 3, 4]
        app.cmdRotateRight()
        self.assertEqual(app.stack, [4, 1, 2, 3])

        app.stack = [1, 2, 3, 4]
        app.cmdSwapTop2()
        self.assertEqual(app.stack, [1, 2, 4, 3])

        app.stack = [1, 2, 3, 4]
        app.cmdDropTop()
        self.assertEqual(app.stack, [1, 2, 3])
Beispiel #3
0
    def test_line(self):
        app = AppLogic(ViewStub())

        app.processLine("2 2 +")
        self.assertEqual(app.stack, [4])

        app.stack = []
        app.processLine("2:2 +")
        self.assertEqual(app.stack, [4])

        app.stack = []
        app.processLine("2:2 6:3 +:1 *:3")
        self.assertEqual(app.stack, [288.0])

        # simulate the delta changed function
        app.stack = []
        app.processLine("100.0:2 15.76 14.12 <> / * <> -")
        self.assertEqual(app.stack, [-10.406091370558386])
Beispiel #4
0
 def test_standard_deviation(self):
     app = AppLogic(ViewStub())
     app.stack = [10, 12, 23, 23, 16, 23, 21, 16]
     app.cmdStandardDeviation()
     self.assertEqual(app.stack, [4.898979485566356])
Beispiel #5
0
 def test_average(self):
     app = AppLogic(ViewStub())
     app.stack = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
     app.cmdAvg()
     self.assertEqual(app.stack, [4.0])