MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_repr_str

Method test_repr_str

Lib/test/test_complex.py:791–817  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

789 self.assertRaises(OverflowError, abs, complex(DBL_MAX, DBL_MAX))
790
791 def test_repr_str(self):
792 def test(v, expected, test_fn=self.assertEqual):
793 test_fn(repr(v), expected)
794 test_fn(str(v), expected)
795
796 test(1+6j, '(1+6j)')
797 test(1-6j, '(1-6j)')
798
799 test(-(1+0j), '(-1+-0j)', test_fn=self.assertNotEqual)
800
801 test(complex(1., INF), "(1+infj)")
802 test(complex(1., -INF), "(1-infj)")
803 test(complex(INF, 1), "(inf+1j)")
804 test(complex(-INF, INF), "(-inf+infj)")
805 test(complex(NAN, 1), "(nan+1j)")
806 test(complex(1, NAN), "(1+nanj)")
807 test(complex(NAN, NAN), "(nan+nanj)")
808 test(complex(-NAN, -NAN), "(nan+nanj)")
809
810 test(complex(0, INF), "infj")
811 test(complex(0, -INF), "-infj")
812 test(complex(0, NAN), "nanj")
813
814 self.assertEqual(1-6j,complex(repr(1-6j)))
815 self.assertEqual(1+6j,complex(repr(1+6j)))
816 self.assertEqual(-6j,complex(repr(-6j)))
817 self.assertEqual(6j,complex(repr(6j)))
818
819 @support.requires_IEEE_754
820 def test_negative_zero_repr_str(self):

Callers

nothing calls this directly

Calls 3

reprFunction · 0.85
testFunction · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected