program_pipes_python.py 643 B

123456789101112131415161718192021
  1. from evaluator import *
  2. DESCRIPTION = "Test if the model can generate a python program that defines dataflow DSL."
  3. TAGS = ['code', 'python']
  4. question = """
  5. Write a python class Const, Square, Print so that I can write, for example,
  6. Cost(5) >> Square() >> Inc() >> Inc() >> Print()
  7. and the resulting python program will print 27 to the screen.
  8. """
  9. test_case, answer = make_python_test([("Const(2) >> Square() >> Inc() >> Square() >> Square() >> Print()", "0")])
  10. TestMakeShiftOp = question >> LLMRun() >> ExtractCode() >> PythonRun(test_case) >> SubstringEvaluator("625")
  11. if __name__ == "__main__":
  12. print(run_test(TestMakeShiftOp))