示例#1
0
def multipleTestCases():
    print("=" * 6, "multipleTestCases", "=" * 6)

    s = Syntax("testCases/target_test1/lex/out.lex", "none")
    s.go()
    result = evaluator(s.root.getChild(0).getChild(1))
    assertThat((5 - 3) * (8 / 2), result)

    s = Syntax("testCases/target_test2/lex/out.lex", "none")
    s.go()
    result = evaluator(s.root.getChild(0).getChild(1))
    assertThat(5 + 1 * 3 - 4 / 5 * 6 - 1 * 2 - 3 * 4, result)

    s = Syntax("testCases/target_test4/lex/out.lex", "none")
    s.go()
    result = evaluator(s.root.getChild(0).getChild(1))
    assertThat(24 + 4 - 1 * 3 / 2 + 34 - 1, result)

    s = Syntax("testCases/target_test3/lex/out.lex", "none")
    s.go()
    result = evaluator(s.root.getChild(0).getChild(1))
    assertThat(19 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1 * (2 + 3 + 4 + 3 + 2),
               result)
示例#2
0
def sintactic(file, outputType):
    syntax = Syntax(file, outputType)
    global syntaxTree
    syntaxTree = syntax.go(file)