Esempio n. 1
0
def main (*args):
    import sys
    from parse_rws import ASRLParser
    test_triples = (('"buildme"', "buildme", {}),
                    )
    if args:
        print "Ignoring arguments!"
    for rwexpstr, target_obj, build_env in test_triples:
        asrl_cst = ASRLParser.parse_string(rwexpstr, 'rwexp')
        asrl_ast = ASRLParser.cst_to_ast(asrl_cst)
        built_obj = build(asrl_ast, build_env)
        print repr(built_obj)
        assert built_obj == target_obj
Esempio n. 2
0
def main (*args):
    import sys
    from parse_rws import ASRLParser
    base_env = build_rwenv_from_module_class(ASRL)
    test_pairs = (('"matchme"', "matchme", {}),
                  ('[1,2,3]', [1,2,3], {}),
                  ('(1.,2.,3.)', (1.,2.,3.), {}),
                  ('(a,a,b)', ("fred", "fred", "barney"), {"b":"barney"}),
                  ('Constructor("Constructor", args)',
                   ASRL.Constructor("Constructor", []), base_env),
                  )
    if args:
        print >>sys.stderr, "Ignoring arguments..."
    for rwexpstr, testobj, base_env in test_pairs:
        asrl_cst = ASRLParser.parse_string(rwexpstr, 'rwexp')
        asrl_ast = ASRLParser.cst_to_ast(asrl_cst)
        print match(asrl_ast, testobj, base_env)
Esempio n. 3
0
def test_asrl_file (asrl_filename):
    from parse_rws import ASRLParser
    for unit in ASRLParser.parse_file(asrl_filename,
                                      environment = test_base_env):
        test_asrl_unit(unit)
Esempio n. 4
0
def test_asrl_string (asrl_string):
    from parse_rws import ASRLParser
    for unit in ASRLParser.parse_string(asrl_string,
                                        environment = test_base_env):
        test_asrl_unit(unit)