Beispiel #1
0
    def setUp(self):
        zxbpp.init()
        self.t = TYPECAST(Type.float_, NUMBER(3, lineno=1), lineno=2)

        if OPTIONS.has_option('stderr'):
            OPTIONS.remove_option('stderr')
        OPTIONS.add_option('stderr', type_=None, default_value=StringIO())
Beispiel #2
0
 def test_make_const(self):
     """ Must return a number
     """
     v = VAR('a', lineno=1, type_=Type.byte_)
     v.default_value = 3
     v.class_ = CLASS.const
     t = TYPECAST.make_node(Type.float_, v, lineno=2)
     self.assertIsInstance(t, NUMBER)
     self.assertEqual(t, 3)
Beispiel #3
0
 def test_make_node_loose_byte4(self):
     TYPECAST.make_node(Type.ubyte, NUMBER(-257, lineno=1), lineno=2)
     self.assertEqual(self.OUTPUT, "(stdin):1: warning: Conversion may lose significant digits\n")
Beispiel #4
0
 def test_make_node_loose_byte3(self):
     TYPECAST.make_node(Type.ubyte, NUMBER(-3, lineno=1), lineno=2)
     self.assertEqual(self.OUTPUT, '')
Beispiel #5
0
 def test_make_node_None(self):
     """ None is allowed as operand
     """
     self.assertIsNone(TYPECAST.make_node(Type.float_, None, lineno=2))
Beispiel #6
0
 def test_make_node(self):
     t = TYPECAST.make_node(Type.float_, NUMBER(3, lineno=1), lineno=2)
     # t is a constant, so typecast is done on the fly
     self.assertEqual(t.type_, Type.float_)
     self.assertEqual(t, self.t.operand)
Beispiel #7
0
 def test_make_node__nochange(self):
     n = NUMBER(3, 1, type_=Type.float_)
     self.assertIs(TYPECAST.make_node(Type.float_, n, 1), n)