decompile_py_simple.py 705 B

1234567891011121314151617181920212223242526
  1. from evaluator import *
  2. DESCRIPTION = "Test if the model can disassemble a simple Python function from its bytecode."
  3. TAGS = ['code', 'python']
  4. question = """
  5. Disassemble the following python into a function called foo:
  6. 56 0 LOAD_FAST 0 (a)
  7. 2 LOAD_FAST 1 (b)
  8. 4 LOAD_FAST 0 (a)
  9. 6 BINARY_MULTIPLY
  10. 8 BINARY_ADD
  11. 10 RETURN_VALUE
  12. """
  13. test_case, answer = make_python_test([("foo(5, 7)", "5+7*5")])
  14. TestDisas1 = question >> LLMRun() >> ExtractCode(keep_main=False) >> PythonRun(test_case) >> SubstringEvaluator(answer)
  15. if __name__ == "__main__":
  16. print(run_test(TestDisas1))