MCPcopy Index your code
hub / github.com/python/cpython / verify

Function verify

Modules/_decimal/tests/deccheck.py:825–893  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

823 t.maxex.append(e.__class__)
824
825def 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.

Callers 7

test_unaryFunction · 0.70
test_binaryFunction · 0.70
test_ternaryFunction · 0.70
test_formatFunction · 0.70
test_roundFunction · 0.70
test_from_floatFunction · 0.70
test_quantize_apiFunction · 0.70

Calls 9

strFunction · 0.85
raise_errorFunction · 0.85
all_nanFunction · 0.85
assert_eq_statusMethod · 0.80
appendMethod · 0.45
to_eng_stringMethod · 0.45
as_tupleMethod · 0.45
lstripMethod · 0.45
number_classMethod · 0.45

Tested by 7

test_unaryFunction · 0.56
test_binaryFunction · 0.56
test_ternaryFunction · 0.56
test_formatFunction · 0.56
test_roundFunction · 0.56
test_from_floatFunction · 0.56
test_quantize_apiFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…