示例#1
0
 def test_PREFIX_SIGNS(self):
     tree = parse(" + ( 0 - -2 % -3 )")
     assert tree == Module(
         body=(
             Operation(
                 op="+",
                 arguments=(
                     Operation(
                         op="-",
                         arguments=(
                             Int(value="0"),
                             Operation(
                                 op="-",
                                 arguments=(
                                     Operation(
                                         op="%",
                                         arguments=(
                                             Int(value="2"),
                                             Operation(
                                                 op="-",
                                                 arguments=(Int(value="3"),),
                                             ),
                                         ),
                                     ),
                                 ),
                             ),
                         ),
                     ),
                 ),
             ),
         )
     )
示例#2
0
 def test_IF_ELSE(self):
     tree = parse("if True {2} else {3} ")
     assert tree == Module(
         body=(
             IfStatement(
                 conditionals=((Bool(value="True"), (Int(value="2"),)),),
                 default=(Int(value="3"),),
             ),
         )
     )
示例#3
0
 def test_CHAR(self):
     tree = parse(r"'1'; '2'; 'a'; ' '; '\t' ")
     assert tree == Module(
         body=(
             Char(value="1"),
             Char(value="2"),
             Char(value="a"),
             Char(value=" "),
             Char(value="\t"),
         )
     )
示例#4
0
 def test_DOUBLE(self):
     tree = parse(
         "123456789123456789123456789123456789123456789.1234567891234567098765432123456789098765432; 0.0"
     )
     assert tree == Module(
         body=(
             Double(
                 value="123456789123456789123456789123456789123456789.1234567891234567098765432123456789098765432"
             ),
             Float(value="0.0"),
         )
     )
示例#5
0
 def test_BINNOT(self):
     tree = parse(" ! ( 1 && 2 - 10 % ~ 2 ) % 2")
     assert tree == Module(
         body=(
             Operation(
                 op="!",
                 arguments=(
                     Operation(
                         op="%",
                         arguments=(
                             Operation(
                                 op="&&",
                                 arguments=(
                                     Int(value="1"),
                                     Operation(
                                         op="-",
                                         arguments=(
                                             Int(value="2"),
                                             Operation(
                                                 op="%",
                                                 arguments=(
                                                     Int(value="10"),
                                                     Operation(
                                                         op="~",
                                                         arguments=(Int(value="2"),),
                                                     ),
                                                 ),
                                             ),
                                         ),
                                     ),
                                 ),
                             ),
                             Int(value="2"),
                         ),
                     ),
                 ),
             ),
         )
     )
示例#6
0
 def test_INT(self):
     tree = parse("1; 1; 1; 1")
     assert tree == Module(
         body=(Int(value="1"), Int(value="1"), Int(value="1"), Int(value="1"))
     )