Skip to content

Commit bb19e7b

Browse files
committed
tests/basics/special_methods: Enable tests for extra special methods.
These additional special methods are enabled on most ports so we can test them in this test.
1 parent f003310 commit bb19e7b

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

tests/basics/special_methods.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,35 @@ def __div__(self, other):
8585
def __xor__(self, other):
8686
print("__xor__ called")
8787

88+
def __iadd__(self, other):
89+
print("__iadd__ called")
90+
return self
91+
92+
def __isub__(self, other):
93+
print("__isub__ called")
94+
return self
95+
8896
cud1 = Cud()
8997
cud2 = Cud()
98+
9099
str(cud1)
91100
cud1 < cud2
92101
cud1 <= cud2
93102
cud1 == cud2
94103
cud1 >= cud2
95104
cud1 > cud2
96105
cud1 + cud2
106+
cud1 - cud2
107+
108+
# the following require MICROPY_PY_ALL_SPECIAL_METHODS
109+
+cud1
110+
-cud1
111+
~cud1
112+
cud1 * cud2
113+
cud1 / cud2
114+
cud2 // cud1
115+
cud1 += cud2
116+
cud1 -= cud2
97117

98118
# TODO: the following operations are not supported on every ports
99119
#
@@ -103,48 +123,21 @@ def __xor__(self, other):
103123
# binary and is not supported
104124
# cud1 & cud2
105125
#
106-
# floor div is not supported on the qemu arm port
107-
# cud2 // cud1
108-
#
109-
# inv is not supported on the qemu arm port
110-
# ~cud1
111-
#
112126
# binary lshift is not supported
113127
# cud1<<1
114128
#
115129
# modulus is not supported
116130
# cud1 % 2
117131
#
118-
# mult is not supported on the qemu arm port
119-
# cud1 * cud2
120-
#
121-
# mult is not supported on the qemu arm port
122-
# cud1 * 2
123-
#
124-
# inv is not supported on the qemu arm port
125-
# -cud1
126-
#
127132
# binary or is not supported
128133
# cud1 | cud2
129134
#
130-
# pos is not supported on the qemu arm port
131-
# +cud1
132-
#
133135
# pow is not supported
134136
# cud1**2
135137
#
136138
# rshift is not suported
137139
# cud1>>1
138140
#
139-
# sub is not supported on the qemu arm port
140-
# cud1 - cud2
141-
#
142-
# div is not supported on the qemu arm port
143-
# cud1 / cud2
144-
#
145-
# div is not supported on the qemu arm port
146-
# cud1 / 2
147-
#
148141
# xor is not supported
149142
# cud1^cud2
150143
#

0 commit comments

Comments
 (0)