program_pipes_cpp.py 631 B

12345678910111213141516171819202122232425
  1. from evaluator import *
  2. DESCRIPTION = "Test if the model can generate a C++ program that defines dataflow DSL."
  3. TAGS = ['code', 'c']
  4. question = """
  5. Write a C++ 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 = """int main() {
  10. Const(2) >> Square() >> Inc() >> Square() >> Square() >> Print();
  11. return 0;
  12. }"""
  13. TestMakeShiftOpC = question >> LLMRun() >> ExtractCode() >> CppRun(test_case) >> SubstringEvaluator("625")
  14. if __name__ == "__main__":
  15. print(run_test(TestMakeShiftOpC))