Ticket #14058: trac_14058-doctest.patch

File trac_14058-doctest.patch, 1.2 KB (added by nbruin, 9 years ago)

Doctest proposal

  • sage/structure/coerce.pyx

    # HG changeset patch
    # User Nils Bruin <nbruin@sfu.ca>
    # Date 1360085725 28800
    # Node ID f88f593d2716aeacd018cd34bd90614c5ad9316b
    # Parent  cce32582da60acf9bbb74628e4c090c84bb6d67f
    #14058: Add doctest
    
    diff --git a/sage/structure/coerce.pyx b/sage/structure/coerce.pyx
    a b cdef class CoercionModel_cache_maps(Coer 
    10021002            True
    10031003            sage: parent(w+v) is W
    10041004            True
     1005
     1006        TESTS:
     1007
     1008        We check that with :trac:`14058`, parents are still eligible for
     1009        garbage collection after being involved in binary operations::
     1010
     1011            sage: import gc
     1012            sage: T=type(GF(2))
     1013            sage: N0=len(list(o for o in gc.get_objects() if type(o) is T))
     1014            sage: L=[ZZ(1)+GF(p)(1) for p in prime_range(2,50)]
     1015            sage: N1=len(list(o for o in gc.get_objects() if type(o) is T))
     1016            sage: print N1 > N0
     1017            True
     1018            sage: del L
     1019            sage: gc.collect() #random
     1020            3939
     1021            sage: N2=len(list(o for o in gc.get_objects() if type(o) is T))
     1022            sage: print N2-N0
     1023            0
     1024
    10051025        """
    10061026        try:
    10071027            result = self._coercion_maps.get(R, S, None)