Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_augassign.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | e58a71a8550e |
| children | 51102abdec50 6768b2350c57 |
| rev | line source |
|---|---|
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1 # Augmented assignment test. |
|
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
3 from test.test_support import run_unittest |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
4 import unittest |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
5 |
|
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
7 class AugAssignTest(unittest.TestCase): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
8 def testBasic(self): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
9 x = 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
10 x += 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
11 x *= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
12 x **= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
13 x -= 8 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
14 x //= 5 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
15 x %= 3 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
16 x &= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
17 x |= 5 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
18 x ^= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
19 x /= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
20 if 1/2 == 0: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
21 # classic division |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
22 self.assertEquals(x, 3) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
23 else: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
24 # new-style division (with -Qnew) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
25 self.assertEquals(x, 3.0) |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
26 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
27 def testInList(self): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
28 x = [2] |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
29 x[0] += 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
30 x[0] *= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
31 x[0] **= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
32 x[0] -= 8 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
33 x[0] //= 5 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
34 x[0] %= 3 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
35 x[0] &= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
36 x[0] |= 5 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
37 x[0] ^= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
38 x[0] /= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
39 if 1/2 == 0: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
40 self.assertEquals(x[0], 3) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
41 else: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
42 self.assertEquals(x[0], 3.0) |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
43 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
44 def testInDict(self): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
45 x = {0: 2} |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
46 x[0] += 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
47 x[0] *= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
48 x[0] **= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
49 x[0] -= 8 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
50 x[0] //= 5 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
51 x[0] %= 3 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
52 x[0] &= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
53 x[0] |= 5 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
54 x[0] ^= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
55 x[0] /= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
56 if 1/2 == 0: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
57 self.assertEquals(x[0], 3) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
58 else: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
59 self.assertEquals(x[0], 3.0) |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
60 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
61 def testSequences(self): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
62 x = [1,2] |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
63 x += [3,4] |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
64 x *= 2 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
65 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
66 self.assertEquals(x, [1, 2, 3, 4, 1, 2, 3, 4]) |
|
37307
e58a71a8550e
whitespace normalisation
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37279
diff
changeset
|
67 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
68 x = [1, 2, 3] |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
69 y = x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
70 x[1:2] *= 2 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
71 y[1:2] += [1] |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
72 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
73 self.assertEquals(x, [1, 2, 1, 2, 3]) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
74 self.assert_(x is y) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
75 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
76 def testCustomMethods1(self): |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
77 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
78 class aug_test: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
79 def __init__(self, value): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
80 self.val = value |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
81 def __radd__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
82 return self.val + val |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
83 def __add__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
84 return aug_test(self.val + val) |
|
37307
e58a71a8550e
whitespace normalisation
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37279
diff
changeset
|
85 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
86 class aug_test2(aug_test): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
87 def __iadd__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
88 self.val = self.val + val |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
89 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
90 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
91 class aug_test3(aug_test): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
92 def __iadd__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
93 return aug_test3(self.val + val) |
|
37307
e58a71a8550e
whitespace normalisation
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37279
diff
changeset
|
94 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
95 x = aug_test(1) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
96 y = x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
97 x += 10 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
98 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
99 self.assert_(isinstance(x, aug_test)) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
100 self.assert_(y is not x) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
101 self.assertEquals(x.val, 11) |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
102 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
103 x = aug_test2(2) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
104 y = x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
105 x += 10 |
|
37307
e58a71a8550e
whitespace normalisation
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37279
diff
changeset
|
106 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
107 self.assert_(y is x) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
108 self.assertEquals(x.val, 12) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
109 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
110 x = aug_test3(3) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
111 y = x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
112 x += 10 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
113 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
114 self.assert_(isinstance(x, aug_test3)) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
115 self.assert_(y is not x) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
116 self.assertEquals(x.val, 13) |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
117 |
|
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
118 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
119 def testCustomMethods2(test_self): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
120 output = [] |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
121 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
122 class testall: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
123 def __add__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
124 output.append("__add__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
125 def __radd__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
126 output.append("__radd__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
127 def __iadd__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
128 output.append("__iadd__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
129 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
130 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
131 def __sub__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
132 output.append("__sub__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
133 def __rsub__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
134 output.append("__rsub__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
135 def __isub__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
136 output.append("__isub__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
137 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
138 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
139 def __mul__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
140 output.append("__mul__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
141 def __rmul__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
142 output.append("__rmul__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
143 def __imul__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
144 output.append("__imul__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
145 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
146 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
147 def __div__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
148 output.append("__div__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
149 def __rdiv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
150 output.append("__rdiv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
151 def __idiv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
152 output.append("__idiv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
153 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
154 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
155 def __floordiv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
156 output.append("__floordiv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
157 return self |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
158 def __ifloordiv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
159 output.append("__ifloordiv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
160 return self |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
161 def __rfloordiv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
162 output.append("__rfloordiv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
163 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
164 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
165 def __truediv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
166 output.append("__truediv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
167 return self |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
168 def __itruediv__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
169 output.append("__itruediv__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
170 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
171 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
172 def __mod__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
173 output.append("__mod__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
174 def __rmod__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
175 output.append("__rmod__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
176 def __imod__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
177 output.append("__imod__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
178 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
179 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
180 def __pow__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
181 output.append("__pow__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
182 def __rpow__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
183 output.append("__rpow__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
184 def __ipow__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
185 output.append("__ipow__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
186 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
187 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
188 def __or__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
189 output.append("__or__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
190 def __ror__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
191 output.append("__ror__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
192 def __ior__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
193 output.append("__ior__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
194 return self |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
195 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
196 def __and__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
197 output.append("__and__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
198 def __rand__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
199 output.append("__rand__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
200 def __iand__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
201 output.append("__iand__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
202 return self |
|
19555
ea76dea6440f
Add tests for augmented floor division
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15305
diff
changeset
|
203 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
204 def __xor__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
205 output.append("__xor__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
206 def __rxor__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
207 output.append("__rxor__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
208 def __ixor__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
209 output.append("__ixor__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
210 return self |
|
19555
ea76dea6440f
Add tests for augmented floor division
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15305
diff
changeset
|
211 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
212 def __rshift__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
213 output.append("__rshift__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
214 def __rrshift__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
215 output.append("__rrshift__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
216 def __irshift__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
217 output.append("__irshift__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
218 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
219 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
220 def __lshift__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
221 output.append("__lshift__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
222 def __rlshift__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
223 output.append("__rlshift__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
224 def __ilshift__(self, val): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
225 output.append("__ilshift__ called") |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
226 return self |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
227 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
228 x = testall() |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
229 x + 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
230 1 + x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
231 x += 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
232 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
233 x - 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
234 1 - x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
235 x -= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
236 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
237 x * 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
238 1 * x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
239 x *= 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
240 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
241 if 1/2 == 0: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
242 x / 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
243 1 / x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
244 x /= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
245 else: |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
246 # True division is in effect, so "/" doesn't map to __div__ etc; |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
247 # but the canned expected-output file requires that those get called. |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
248 x.__div__(1) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
249 x.__rdiv__(1) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
250 x.__idiv__(1) |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
251 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
252 x // 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
253 1 // x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
254 x //= 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
255 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
256 x % 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
257 1 % x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
258 x %= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
259 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
260 x ** 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
261 1 ** x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
262 x **= 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
263 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
264 x | 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
265 1 | x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
266 x |= 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
267 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
268 x & 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
269 1 & x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
270 x &= 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
271 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
272 x ^ 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
273 1 ^ x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
274 x ^= 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
275 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
276 x >> 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
277 1 >> x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
278 x >>= 1 |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
279 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
280 x << 1 |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
281 1 << x |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
282 x <<= 1 |
|
19555
ea76dea6440f
Add tests for augmented floor division
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15305
diff
changeset
|
283 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
284 test_self.assertEquals(output, '''\ |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
285 __add__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
286 __radd__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
287 __iadd__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
288 __sub__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
289 __rsub__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
290 __isub__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
291 __mul__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
292 __rmul__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
293 __imul__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
294 __div__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
295 __rdiv__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
296 __idiv__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
297 __floordiv__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
298 __rfloordiv__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
299 __ifloordiv__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
300 __mod__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
301 __rmod__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
302 __imod__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
303 __pow__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
304 __rpow__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
305 __ipow__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
306 __or__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
307 __ror__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
308 __ior__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
309 __and__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
310 __rand__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
311 __iand__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
312 __xor__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
313 __rxor__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
314 __ixor__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
315 __rshift__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
316 __rrshift__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
317 __irshift__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
318 __lshift__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
319 __rlshift__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
320 __ilshift__ called |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
321 '''.splitlines()) |
|
37307
e58a71a8550e
whitespace normalisation
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37279
diff
changeset
|
322 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
323 def test_main(): |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
324 run_unittest(AugAssignTest) |
|
14164
dba4aec970e6
Support for augmented assignment in the UserList, UserDict, UserString and
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
325 |
|
37279
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
326 if __name__ == '__main__': |
|
4e1aff0e20d1
Make test_augassign pass with -Qnew and convert to unittest.
Georg Brandl <georg@python.org>
parents:
37183
diff
changeset
|
327 test_main() |
