Back to index

python3.2  3.2.2
Public Member Functions
test.test_unary.UnaryOpTestCase Class Reference

List of all members.

Public Member Functions

def test_negative
def test_positive
def test_invert
def test_no_overflow
def test_negation_of_exponentiation
def test_bad_types

Detailed Description

Definition at line 6 of file test_unary.py.


Member Function Documentation

Definition at line 44 of file test_unary.py.

00044 
00045     def test_bad_types(self):
00046         for op in '+', '-', '~':
00047             self.assertRaises(TypeError, eval, op + "b'a'")
00048             self.assertRaises(TypeError, eval, op + "'a'")
00049 
00050         self.assertRaises(TypeError, eval, "~2j")
00051         self.assertRaises(TypeError, eval, "~2.0")
00052 

Here is the call graph for this function:

Definition at line 24 of file test_unary.py.

00024 
00025     def test_invert(self):
00026         self.assertTrue(-2 == 0 - 2)
00027         self.assertEqual(-0, 0)
00028         self.assertEqual(--2, 2)
00029         self.assertTrue(-2 == 0 - 2)

Here is the call graph for this function:

Definition at line 36 of file test_unary.py.

00036 
00037     def test_negation_of_exponentiation(self):
00038         # Make sure '**' does the right thing; these form a
00039         # regression test for SourceForge bug #456756.
00040         self.assertEqual(-2 ** 3, -8)
00041         self.assertEqual((-2) ** 3, -8)
00042         self.assertEqual(-2 ** 4, -16)
00043         self.assertEqual((-2) ** 4, 16)

Here is the call graph for this function:

Definition at line 8 of file test_unary.py.

00008 
00009     def test_negative(self):
00010         self.assertTrue(-2 == 0 - 2)
00011         self.assertEqual(-0, 0)
00012         self.assertEqual(--2, 2)
00013         self.assertTrue(-2 == 0 - 2)
00014         self.assertTrue(-2.0 == 0 - 2.0)
00015         self.assertTrue(-2j == 0 - 2j)

Here is the call graph for this function:

Definition at line 30 of file test_unary.py.

00030 
00031     def test_no_overflow(self):
00032         nines = "9" * 32
00033         self.assertTrue(eval("+" + nines) == 10**32-1)
00034         self.assertTrue(eval("-" + nines) == -(10**32-1))
00035         self.assertTrue(eval("~" + nines) == ~(10**32-1))

Here is the call graph for this function:

Definition at line 16 of file test_unary.py.

00016 
00017     def test_positive(self):
00018         self.assertEqual(+2, 2)
00019         self.assertEqual(+0, 0)
00020         self.assertEqual(++2, 2)
00021         self.assertEqual(+2, 2)
00022         self.assertEqual(+2.0, 2.0)
00023         self.assertEqual(+2j, 2j)

Here is the call graph for this function:


The documentation for this class was generated from the following file: