| 82 | compare_fn(r, e) |
| 83 | |
| 84 | def get_param(cases, idx): |
| 85 | case = cases[idx] |
| 86 | inp = case.get("input", None) |
| 87 | outp = case.get("output", None) |
| 88 | if inp is None: |
| 89 | raise ValueError("the test case should have input") |
| 90 | if not isinstance(inp, (tuple, list)): |
| 91 | inp = (inp,) |
| 92 | if ref_fn is not None and callable(ref_fn): |
| 93 | outp = ref_fn(*inp) |
| 94 | if outp is None: |
| 95 | raise ValueError("the test case should have output or reference function") |
| 96 | if not isinstance(outp, (tuple, list)): |
| 97 | outp = (outp,) |
| 98 | |
| 99 | return inp, outp |
| 100 | |
| 101 | def run_index(index): |
| 102 | inp, outp = get_param(cases, index) |