def test_cmx_smx(self):
     parse(
         mkiter(
             [
                 lit("CMX"),
                 ("POS_INT", "31"),
                 ("POS_INT", "3"),
                 ("POS_INT", "3"),
                 lit("SMXF"),
                 ("POS_INT", "31"),
                 ("FILENAME", '"a/random/file name"'),
             ]
         )
     ) == [Cmx(31, 2, 3), Smxf(31, "a/random/file name")]
 def test_missing_arg(self):
     with raises(ParseError) as exc_info:
         parse(
             mkiter(
                 [
                     lit("STO"),
                     ("POS_INT", "37"),
                     ("POS_INT", "45"),
                     lit("PR"),
                     # PR is missing a POS_INT argument
                     lit("PR"),
                     ("POS_INT", "37"),
                 ]
             )
         )
     assert_exc_info_msg(exc_info, "Unexpected `PR'")
        def test_pr_cmx_add(self):
            code = '''CMX 32 11 7
PR 11
ADD 1 2.2
'''
            assert_lex_token_list(code, [
                lit('CMX'),
                ('POS_INT', '32'),
                ('POS_INT', '11'),
                ('POS_INT', '7'),
                lit('PR'),
                ('POS_INT', '11'),
                lit('ADD'),
                ('POS_INT', '1'),
                ('REAL', '2.2'),
            ])
        def test_sto_pr(self):
            code = '''STO 1 32.3
PR 2
STO 10 -0.1
PR 32
'''
            assert_lex_token_list(code, [
                lit('STO'),
                ('POS_INT', '1'),
                ('REAL', '32.3'),
                lit('PR'),
                ('POS_INT', '2'),
                lit('STO'),
                ('POS_INT', '10'),
                ('REAL', '-0.1'),
                lit('PR'),
                ('POS_INT', '32'),
            ])
 def test_cmx_smx(self):
     parse(
         mkiter(
             [
                 lit("CMX"),
                 ("POS_INT", "31"),
                 ("POS_INT", "2"),
                 ("POS_INT", "3"),
                 lit("SMX"),
                 ("POS_INT", "31"),
                 # Contents
                 ("REAL", "-13.4"),
                 ("POS_INT", "9876"),
                 ("REAL_SCI", "45.234e4"),
                 ("POS_INT", "-42"),
                 ("REAL", "34.8"),
                 ("REAL_SCI", "-88.2e-2"),
             ]
         )
     ) == [Cmx(31, 2, 3), Smx(31, [-13.4, 9876, 45.234e4, -42, 34.8, -88.2e-2])]
 def test_end_of_one_line_program(self):
     with raises(ParseError) as exc_info:
         parse(
             mkiter(
                 [
                     lit("STO"),
                     ("POS_INT", "37"),
                     # STO is missing a REAL argument
                 ]
             )
         )
     assert_exc_info_msg(exc_info, "Unexpected `$end'")
 def test_sto_neg_index(self):
     with raises(ParseError) as exc_info:
         parse(
             mkiter(
                 [
                     lit("STO"),
                     # STO should only take a POS_INT argument here.
                     ("NEG_INT", "-37"),
                     ("REAL", "42.4"),
                 ]
             )
         )
     assert_exc_info_msg(exc_info, "Unexpected `NEG_INT'")
 def test_bne_real_offset(self):
     with raises(ParseError) as exc_info:
         parse(mkiter([lit("BNE"), ("POS_INT", "81"), ("POS_INT", "32"), ("REAL", "-21.2")]))
     assert_exc_info_msg(exc_info, "Unexpected `REAL'")
 def test_pos_int(self):
     assert parse(mkiter([lit("STO"), ("POS_INT", "10"), ("POS_INT", "32")])) == [Sto(10, 32)]
 def test_bne_pos_offset(self):
     parse(mkiter([lit("BNE"), ("POS_INT", "1"), ("POS_INT", "72"), ("POS_INT", "10")])) == [Bne(1, 72, 10)]
 def test_smx(self):
     assert_lex_token_list('SMX', [lit('SMX')])
 def test_sto_add(self):
     assert parse(
         mkiter(
             [lit("STO"), ("POS_INT", "10"), ("NEG_INT", "-88"), lit("ADD"), ("POS_INT", "10"), ("POS_INT", "22")]
         )
     ) == [Sto(10, -88), Add(10, 22)]
 def test_sto_pr(self, capsys):
     assert parse(
         mkiter([lit("STO"), ("POS_INT", "37"), ("NEG_INT", "-452"), lit("PR"), ("POS_INT", "37")])
     ) == [Sto(37, -452), Pr(37)]
 def test_pmx(self, capsys):
     assert parse(
         mkiter([lit("CMX"), ("POS_INT", "40"), ("POS_INT", "22"), ("POS_INT", "78"), lit("PMX"), ("POS_INT", "40")])
     ) == [Cmx(40, 22, 78), Pmx(40)]
 def test_neg_dimension(self):
     with raises(ParseError) as exc_info:
         parse(mkiter([lit("CMX"), ("POS_INT", "11"), ("POS_INT", "12"), ("NEG_INT", "-13")]))
     assert_exc_info_msg(exc_info, "Unexpected `NEG_INT'")
 def test_negative_matrix_index(self):
     with raises(ParseError) as exc_info:
         parse(mkiter([lit("CMX"), ("NEG_INT", "-22"), ("POS_INT", "20"), ("POS_INT", "20")]))
     assert_exc_info_msg(exc_info, "Unexpected `NEG_INT'")
 def test_cmx(self):
     assert_lex_token_list('CMX', [lit('CMX')])
 def test_bne(self):
     assert_lex_token_list('BNE', [lit('BNE')])
 def test_pde(self):
     assert_lex_token_list('PDE', [lit('PDE')])
 def test_smxf(self):
     assert_lex_token_list('SMXF', [lit('SMXF')])
 def test_neg_int(self):
     assert parse(mkiter([lit("STO"), ("POS_INT", "10"), ("NEG_INT", "-88")])) == [Sto(10, -88)]
 def test_sto(self):
     assert_lex_token_list('STO', [lit('STO')])
 def test_add(self):
     assert_lex_token_list('ADD', [lit('ADD')])
 def test_small_integer(self):
     # This doesn't test RPython's capabilities, since it's not running
     # translated.
     int_str = "-9%d" % sys.maxint
     assert parse(mkiter([lit("STO"), ("POS_INT", "31"), ("POS_INT", int_str)])) == [Sto(31, int(int_str))]
 def test_pde(self):
     parse(mkiter([lit("PDE"), ("POS_INT", "10"), ("POS_INT", "20")])) == [Pde(10, 20)]
 def test_pr(self):
     assert_lex_token_list('PR', [lit('PR')])
 def test_bne_neg_offset(self):
     parse(mkiter([lit("BNE"), ("POS_INT", "1"), ("POS_INT", "72"), ("NEG_INT", "-10")])) == [Bne(1, 72, -10)]
 def test_positive_matrix_index(self):
     assert parse(mkiter([lit("CMX"), ("POS_INT", "22"), ("POS_INT", "33"), ("POS_INT", "11")])) == [Cmx(22, 33, 11)]
 def test_pmx(self):
     assert_lex_token_list('PMX', [lit('PMX')])