def test_eventually_with_pastify(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = eventually(req)'

        spec.parse()

        self.assertRaises(rtamt.LTLPastifyException, spec.pastify)
    def test_always_with_pastify(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('gnt', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = req until gnt'

        spec.parse()

        self.assertRaises(rtamt.LTLPastifyException, spec.pastify)
    def test_eventually_without_pastify(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = eventually(req)'

        spec.parse()

        self.assertRaises(rtamt.LTLNotImplementedException, spec.update, 0,
                          [('req', self.left1)])
    def test_until_without_pastify(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('gnt', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = req until gnt'

        spec.parse()

        self.assertRaises(rtamt.LTLNotImplementedException, spec.update, 0,
                          [('req', self.left1), ('gnt', self.right1)])
    def test_constant(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('out', 'float')
        spec.spec = 'out = 5'

        spec.parse()
        out1 = spec.update(0, [])
        out2 = spec.update(1, [])

        self.assertEqual(out1, 5, "input 1")
        self.assertEqual(out2, 5, "input 2")
    def test_fall(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = fall(req)'

        spec.parse()

        out1 = spec.update(0, [('req', self.left1)])
        out2 = spec.update(1, [('req', self.left2)])
        out3 = spec.update(2, [('req', self.left3)])
        out4 = spec.update(3, [('req', self.left4)])
        out5 = spec.update(4, [('req', self.left5)])

        self.assertEqual(out1, -100, "input 1")
        self.assertEqual(out2, 1, "input 2")
        self.assertEqual(out3, -1, "input 3")
        self.assertEqual(out4, -5, "input 4")
        self.assertEqual(out5, 1, "input 5")
    def test_sqrt(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = sqrt(abs(req))'

        spec.parse()

        out1 = spec.update(0, [('req', self.left1)])
        out2 = spec.update(1, [('req', self.left2)])
        out3 = spec.update(2, [('req', self.left3)])
        out4 = spec.update(3, [('req', self.left4)])
        out5 = spec.update(4, [('req', self.left5)])

        self.assertEqual(out1, math.sqrt(100), "input 1")
        self.assertEqual(out2, math.sqrt(1), "input 2")
        self.assertEqual(out3, math.sqrt(2), "input 3")
        self.assertEqual(out4, math.sqrt(5), "input 4")
        self.assertEqual(out5, math.sqrt(1), "input 5")
    def test_multiplication(self):
        spec = rtamt.LTLDiscreteTimeSpecification()
        spec.declare_var('req', 'float')
        spec.declare_var('gnt', 'float')
        spec.declare_var('out', 'float')
        spec.spec = 'out = req * gnt'

        spec.parse()

        out1 = spec.update(0, [('req', self.left1), ('gnt', self.right1)])
        out2 = spec.update(1, [('req', self.left2), ('gnt', self.right2)])
        out3 = spec.update(2, [('req', self.left3), ('gnt', self.right3)])
        out4 = spec.update(3, [('req', self.left4), ('gnt', self.right4)])
        out5 = spec.update(4, [('req', self.left5), ('gnt', self.right5)])

        self.assertEqual(out1, 2000, "input 1")
        self.assertEqual(out2, 2, "input 2")
        self.assertEqual(out3, -20, "input 3")
        self.assertEqual(out4, 20, "input 4")
        self.assertEqual(out5, 1, "input 5")