Пример #1
0
    def setUp(self):
        zxbpp.init()
        self.t = TYPECAST(Type.float_, NUMBER(3, lineno=1), lineno=2)

        if 'stderr' in OPTIONS:
            del OPTIONS.stderr
        OPTIONS(Action.ADD, name='stderr', default=StringIO())
        OPTIONS.hide_warning_codes = True
Пример #2
0
    def setUp(self):
        zxbpp.init()
        self.t = TYPECAST(Type.float_, NUMBER(3, lineno=1), lineno=2)

        if 'stderr' in OPTIONS:
            del OPTIONS.stderr
        OPTIONS.add_option('stderr', type_=None, default_value=StringIO())
        OPTIONS.hide_warning_codes = True
Пример #3
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)
Пример #4
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")
Пример #5
0
 def test_make_node_loose_byte3(self):
     TYPECAST.make_node(Type.ubyte, NUMBER(-3, lineno=1), lineno=2)
     self.assertEqual(self.OUTPUT, '')
Пример #6
0
 def test_make_node_None(self):
     """ None is allowed as operand
     """
     self.assertIsNone(TYPECAST.make_node(Type.float_, None, lineno=2))
Пример #7
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)
Пример #8
0
 def test_make_node__nochange(self):
     n = NUMBER(3, 1, type_=Type.float_)
     self.assertIs(TYPECAST.make_node(Type.float_, n, 1), n)