Skip to content

Commit 073eabb

Browse files
authored
Fix test_methoddispatch.test_missing_value (#1487)
1 parent e2d1dc3 commit 073eabb

3 files changed

Lines changed: 15 additions & 119 deletions

File tree

Src/IronPythonTest/Enums.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -172,83 +172,33 @@ public enum EnumSByte : sbyte {
172172
MaxSByte = SByte.MaxValue,
173173
}
174174
public enum EnumByte : byte {
175-
Zero = 0,
176-
MaxSByte = (byte)SByte.MaxValue,
177175
MinByte = Byte.MinValue,
178176
MaxByte = Byte.MaxValue,
179177
}
180178
public enum EnumShort : short {
181179
Zero = 0,
182-
MinSByte = SByte.MinValue,
183-
MaxSByte = SByte.MaxValue,
184-
MinByte = Byte.MinValue,
185-
MaxByte = Byte.MaxValue,
186180
MinShort = Int16.MinValue,
187181
MaxShort = Int16.MaxValue,
188182
}
189183
public enum EnumUShort : ushort {
190-
Zero = 0,
191-
MaxSByte = (ushort)SByte.MaxValue,
192-
MinByte = Byte.MinValue,
193-
MaxByte = Byte.MaxValue,
194-
MaxShort = (ushort)Int16.MaxValue,
195184
MinUShort = UInt16.MinValue,
196185
MaxUShort = UInt16.MaxValue,
197186
}
198187
public enum EnumInt : int {
199188
Zero = 0,
200-
MinSByte = SByte.MinValue,
201-
MaxSByte = SByte.MaxValue,
202-
MinByte = Byte.MinValue,
203-
MaxByte = Byte.MaxValue,
204-
MinShort = Int16.MinValue,
205-
MaxShort = Int16.MaxValue,
206-
MinUShort = UInt16.MinValue,
207-
MaxUShort = UInt16.MaxValue,
208189
MinInt = Int32.MinValue,
209190
MaxInt = Int32.MaxValue,
210191
}
211192
public enum EnumUInt : uint {
212-
Zero = 0,
213-
MaxSByte = (uint)SByte.MaxValue,
214-
MinByte = Byte.MinValue,
215-
MaxByte = Byte.MaxValue,
216-
MaxShort = (uint)Int16.MaxValue,
217-
MinUShort = UInt16.MinValue,
218-
MaxUShort = UInt16.MaxValue,
219-
MaxInt = Int32.MaxValue,
220193
MinUInt = UInt32.MinValue,
221194
MaxUInt = UInt32.MaxValue,
222195
}
223196
public enum EnumLong : long {
224197
Zero = 0,
225-
MinSByte = SByte.MinValue,
226-
MaxSByte = SByte.MaxValue,
227-
MinByte = Byte.MinValue,
228-
MaxByte = Byte.MaxValue,
229-
MinShort = Int16.MinValue,
230-
MaxShort = Int16.MaxValue,
231-
MinUShort = UInt16.MinValue,
232-
MaxUShort = UInt16.MaxValue,
233-
MinInt = Int32.MinValue,
234-
MaxInt = Int32.MaxValue,
235-
MinUInt = UInt32.MinValue,
236-
MaxUInt = UInt32.MaxValue,
237198
MinLong = Int64.MinValue,
238199
MaxLong = Int64.MaxValue,
239200
}
240201
public enum EnumULong : ulong {
241-
Zero = 0,
242-
MaxSByte = (ulong)SByte.MaxValue,
243-
MinByte = Byte.MinValue,
244-
MaxByte = Byte.MaxValue,
245-
MaxShort = (ulong)Int16.MaxValue,
246-
MinUShort = UInt16.MinValue,
247-
MaxUShort = UInt16.MaxValue,
248-
MaxInt = Int32.MaxValue,
249-
MinUInt = UInt32.MinValue,
250-
MaxUInt = UInt32.MaxValue,
251-
MaxLong = Int64.MaxValue,
252202
MinULong = UInt64.MinValue,
253203
MaxULong = UInt64.MaxValue,
254204
}

Tests/test_methoddispatch.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -884,25 +884,20 @@ def test_missing_value(self):
884884
self.assertEqual(tst.Test_44(), "(Structure)IronPythonTest.Structure")
885885
self.assertEqual(tst.Test_45(), "(EnumSByte)Zero")
886886
self.assertEqual(tst.Test_46(), "(EnumSByte)Zero")
887-
# TODO: determine if this is a mono bug or not
888-
# both Zero and MinByte have the value of 0, Mono
889-
# https://github.com/IronLanguages/main/issues/1596
890-
if not is_mono:
891-
self.assertEqual(tst.Test_47(), "(EnumByte)Zero")
892-
self.assertEqual(tst.Test_48(), "(EnumByte)Zero")
893-
self.assertEqual(tst.Test_49(), "(EnumShort)Zero")
894-
self.assertEqual(tst.Test_50(), "(EnumShort)Zero")
895-
self.assertEqual(tst.Test_51(), "(EnumUShort)Zero")
896-
self.assertEqual(tst.Test_52(), "(EnumUShort)Zero")
897-
self.assertEqual(tst.Test_53(), "(EnumInt)MinUShort")
898-
self.assertEqual(tst.Test_54(), "(EnumInt)MinUShort")
899-
if not is_mono:
900-
self.assertEqual(tst.Test_55(), "(EnumUInt)MinUInt")
901-
self.assertEqual(tst.Test_56(), "(EnumUInt)MinUInt")
902-
self.assertEqual(tst.Test_57(), "(EnumLong)MinUInt")
903-
self.assertEqual(tst.Test_58(), "(EnumLong)MinUInt")
904-
self.assertEqual(tst.Test_59(), "(EnumULong)MinUInt")
905-
self.assertEqual(tst.Test_60(), "(EnumULong)MinUInt")
887+
self.assertEqual(tst.Test_47(), "(EnumByte)MinByte")
888+
self.assertEqual(tst.Test_48(), "(EnumByte)MinByte")
889+
self.assertEqual(tst.Test_49(), "(EnumShort)Zero")
890+
self.assertEqual(tst.Test_50(), "(EnumShort)Zero")
891+
self.assertEqual(tst.Test_51(), "(EnumUShort)MinUShort")
892+
self.assertEqual(tst.Test_52(), "(EnumUShort)MinUShort")
893+
self.assertEqual(tst.Test_53(), "(EnumInt)Zero")
894+
self.assertEqual(tst.Test_54(), "(EnumInt)Zero")
895+
self.assertEqual(tst.Test_55(), "(EnumUInt)MinUInt")
896+
self.assertEqual(tst.Test_56(), "(EnumUInt)MinUInt")
897+
self.assertEqual(tst.Test_57(), "(EnumLong)Zero")
898+
self.assertEqual(tst.Test_58(), "(EnumLong)Zero")
899+
self.assertEqual(tst.Test_59(), "(EnumULong)MinULong")
900+
self.assertEqual(tst.Test_60(), "(EnumULong)MinULong")
906901
self.assertEqual(tst.Test_61(), "(string)(null)")
907902
self.assertEqual(tst.Test_62(), "(string)(null)")
908903
self.assertEqual(tst.Test_63(), "(object)System.Reflection.Missing")

Tests/test_number.py

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def type_test(tx, ty):
165165
@skipUnlessIronPython()
166166
def test_conversions(self):
167167
"""implicit conversions (conversion defined on Derived)"""
168-
from IronPythonTest import Base, Base2, ConversionStorage, Derived, Derived2, EnumByte, EnumInt, EnumLong, EnumSByte, EnumShort, EnumTest, EnumUShort, EnumUInt, EnumULong
168+
from IronPythonTest import Base, Base2, ConversionStorage, Derived, Derived2
169169
a = ConversionStorage()
170170
b = Base(5)
171171
d = Derived(23)
@@ -245,55 +245,6 @@ def __pos__(self):
245245
a = None
246246
if a: self.assertEqual(False, True)
247247

248-
# Enum conversions
249-
250-
class EnumRec:
251-
def __init__(self, code, min, max, enum, test):
252-
self.code = code
253-
self.min = min
254-
self.max = max
255-
self.enum = enum
256-
self.test = test
257-
258-
enum_types = [
259-
EnumRec("SByte", -128, 127, EnumSByte, EnumTest.TestEnumSByte),
260-
EnumRec("Byte", 0, 255, EnumByte, EnumTest.TestEnumByte),
261-
EnumRec("Short", -32768, 32767, EnumShort, EnumTest.TestEnumShort),
262-
EnumRec("UShort", 0, 65535, EnumUShort, EnumTest.TestEnumUShort),
263-
EnumRec("Int", -2147483648, 2147483647, EnumInt, EnumTest.TestEnumInt),
264-
EnumRec("UInt", 0, 4294967295, EnumUInt, EnumTest.TestEnumUInt),
265-
EnumRec("Long", -9223372036854775808, 9223372036854775807, EnumLong, EnumTest.TestEnumLong),
266-
EnumRec("ULong", 0, 18446744073709551615, EnumULong, EnumTest.TestEnumULong),
267-
]
268-
269-
value_names = ["Zero"]
270-
value_values = {"Zero" : 0}
271-
for e in enum_types:
272-
value_names.append("Min" + e.code)
273-
value_names.append("Max" + e.code)
274-
value_values["Min" + e.code] = e.min
275-
value_values["Max" + e.code] = e.max
276-
277-
"""
278-
These tests are changed or obsoleted by new enum coercion rules
279-
for enum in enum_types:
280-
for name in value_names:
281-
val = value_values[name]
282-
if hasattr(enum.enum, name):
283-
for test in enum_types:
284-
func = test.test
285-
ev = getattr(enum.enum, name)
286-
if test.min <= val and val <= test.max:
287-
func(ev)
288-
else:
289-
try:
290-
func(ev)
291-
except:
292-
pass
293-
else:
294-
self.assertTrue(False)
295-
EnumTest.TestEnumBoolean(ev)
296-
"""
297248

298249
self.assertEqual(int(Single.Parse("3.14159")), 3)
299250

0 commit comments

Comments
 (0)