t is the testset. At this stage the testset contains the following tuples: t.op: original operands t.cop: C.Decimal operands (see convert for details) t.pop: P.Decimal operands (see convert for details) t.rc: C result t.rp: Python
(t, stat)
| 823 | t.maxex.append(e.__class__) |
| 824 | |
| 825 | def verify(t, stat): |
| 826 | """ t is the testset. At this stage the testset contains the following |
| 827 | tuples: |
| 828 | |
| 829 | t.op: original operands |
| 830 | t.cop: C.Decimal operands (see convert for details) |
| 831 | t.pop: P.Decimal operands (see convert for details) |
| 832 | t.rc: C result |
| 833 | t.rp: Python result |
| 834 | |
| 835 | t.rc and t.rp can have various types. |
| 836 | """ |
| 837 | t.cresults.append(str(t.rc)) |
| 838 | t.presults.append(str(t.rp)) |
| 839 | if t.with_maxcontext: |
| 840 | t.maxresults.append(str(t.rmax)) |
| 841 | |
| 842 | if isinstance(t.rc, C.Decimal) and isinstance(t.rp, P.Decimal): |
| 843 | # General case: both results are Decimals. |
| 844 | t.cresults.append(t.rc.to_eng_string()) |
| 845 | t.cresults.append(t.rc.as_tuple()) |
| 846 | t.cresults.append(str(t.rc.imag)) |
| 847 | t.cresults.append(str(t.rc.real)) |
| 848 | t.presults.append(t.rp.to_eng_string()) |
| 849 | t.presults.append(t.rp.as_tuple()) |
| 850 | t.presults.append(str(t.rp.imag)) |
| 851 | t.presults.append(str(t.rp.real)) |
| 852 | |
| 853 | if t.with_maxcontext and isinstance(t.rmax, C.Decimal): |
| 854 | t.maxresults.append(t.rmax.to_eng_string()) |
| 855 | t.maxresults.append(t.rmax.as_tuple()) |
| 856 | t.maxresults.append(str(t.rmax.imag)) |
| 857 | t.maxresults.append(str(t.rmax.real)) |
| 858 | |
| 859 | nc = t.rc.number_class().lstrip('+-s') |
| 860 | stat[nc] += 1 |
| 861 | else: |
| 862 | # Results from e.g. __divmod__ can only be compared as strings. |
| 863 | if not isinstance(t.rc, tuple) and not isinstance(t.rp, tuple): |
| 864 | if t.rc != t.rp: |
| 865 | raise_error(t) |
| 866 | if t.with_maxcontext and not isinstance(t.rmax, tuple): |
| 867 | if t.rmax != t.rc: |
| 868 | raise_error(t) |
| 869 | stat[type(t.rc).__name__] += 1 |
| 870 | |
| 871 | # The return value lists must be equal. |
| 872 | if t.cresults != t.presults: |
| 873 | raise_error(t) |
| 874 | # The Python exception lists (TypeError, etc.) must be equal. |
| 875 | if t.cex != t.pex: |
| 876 | raise_error(t) |
| 877 | # The context flags must be equal. |
| 878 | if not t.context.assert_eq_status(): |
| 879 | raise_error(t) |
| 880 | |
| 881 | if t.with_maxcontext: |
| 882 | # NaN payloads etc. depend on precision and clamp. |
searching dependent graphs…