| 14 | from textwrap import indent, dedent |
| 15 | |
| 16 | def extract_test_cases(path): |
| 17 | with open(path, encoding="utf8", errors='ignore', mode='r', newline='') as file: |
| 18 | lines = file.read().splitlines() |
| 19 | |
| 20 | inside = False |
| 21 | delimiter = '' |
| 22 | tests = [] |
| 23 | |
| 24 | for l in lines: |
| 25 | if inside: |
| 26 | if l.strip().endswith(')' + delimiter + '";'): |
| 27 | inside = False |
| 28 | else: |
| 29 | tests[-1] += l + '\n' |
| 30 | else: |
| 31 | m = re.search(r'R"([^(]*)\($', l.strip()) |
| 32 | if m: |
| 33 | inside = True |
| 34 | delimiter = m.group(1) |
| 35 | tests += [''] |
| 36 | |
| 37 | return tests |
| 38 | |
| 39 | def extract_solidity_docs_cases(path): |
| 40 | tests = extract_docs_cases(path, [".. code-block:: solidity", '::']) |