Skip to content

Commit 72c2b5a

Browse files
authored
Enable test_numtypes (#1424)
* Convert with 2to3 * Remove obsolete code * Fix validate_constructors * Update test to include BigInteger * Patch gaps in integer operators * Enable test_numtypes * Increase timeout for test_numtypes to 5 min * Update after review
1 parent 0529bde commit 72c2b5a

6 files changed

Lines changed: 111 additions & 88 deletions

File tree

Src/IronPython/Runtime/Operations/BoolOps.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ public static int BitwiseAnd(bool x, int y) {
4747
return Int32Ops.BitwiseAnd(x ? 1 : 0, y);
4848
}
4949

50+
[SpecialName]
51+
public static BigInteger BitwiseAnd(BigInteger x, bool y) {
52+
return BigIntegerOps.BitwiseAnd(y ? 1 : 0, x);
53+
}
54+
55+
[SpecialName]
56+
public static BigInteger BitwiseAnd(bool x, BigInteger y) {
57+
return BigIntegerOps.BitwiseAnd(x ? 1 : 0, y);
58+
}
59+
5060
[SpecialName]
5161
public static int BitwiseOr(int x, bool y) {
5262
return Int32Ops.BitwiseOr(y ? 1 : 0, x);
@@ -57,6 +67,16 @@ public static int BitwiseOr(bool x, int y) {
5767
return Int32Ops.BitwiseOr(x ? 1 : 0, y);
5868
}
5969

70+
[SpecialName]
71+
public static BigInteger BitwiseOr(BigInteger x, bool y) {
72+
return BigIntegerOps.BitwiseOr(y ? 1 : 0, x);
73+
}
74+
75+
[SpecialName]
76+
public static BigInteger BitwiseOr(bool x, BigInteger y) {
77+
return BigIntegerOps.BitwiseOr(x ? 1 : 0, y);
78+
}
79+
6080
[SpecialName]
6181
public static int ExclusiveOr(int x, bool y) {
6282
return Int32Ops.ExclusiveOr(y ? 1 : 0, x);
@@ -67,6 +87,16 @@ public static int ExclusiveOr(bool x, int y) {
6787
return Int32Ops.ExclusiveOr(x ? 1 : 0, y);
6888
}
6989

90+
[SpecialName]
91+
public static BigInteger ExclusiveOr(BigInteger x, bool y) {
92+
return BigIntegerOps.ExclusiveOr(y ? 1 : 0, x);
93+
}
94+
95+
[SpecialName]
96+
public static BigInteger ExclusiveOr(bool x, BigInteger y) {
97+
return BigIntegerOps.ExclusiveOr(x ? 1 : 0, y);
98+
}
99+
70100
public static string/*!*/ __repr__(bool self) {
71101
return self ? "True" : "False";
72102
}

Src/IronPython/Runtime/Operations/IntOps.Generated.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,12 +2330,12 @@ public static object Add(UInt64 x, UInt64 y) {
23302330
}
23312331

23322332
[SpecialName]
2333-
public static object Add(UInt64 x, Int64 y) {
2333+
public static object Add(UInt64 x, BigInteger y) {
23342334
return BigIntegerOps.Add((BigInteger)x, (BigInteger)y);
23352335
}
23362336

23372337
[SpecialName]
2338-
public static object Add(Int64 x, UInt64 y) {
2338+
public static object Add(BigInteger x, UInt64 y) {
23392339
return BigIntegerOps.Add((BigInteger)x, (BigInteger)y);
23402340
}
23412341

@@ -2349,12 +2349,12 @@ public static object Subtract(UInt64 x, UInt64 y) {
23492349
}
23502350

23512351
[SpecialName]
2352-
public static object Subtract(UInt64 x, Int64 y) {
2352+
public static object Subtract(UInt64 x, BigInteger y) {
23532353
return BigIntegerOps.Subtract((BigInteger)x, (BigInteger)y);
23542354
}
23552355

23562356
[SpecialName]
2357-
public static object Subtract(Int64 x, UInt64 y) {
2357+
public static object Subtract(BigInteger x, UInt64 y) {
23582358
return BigIntegerOps.Subtract((BigInteger)x, (BigInteger)y);
23592359
}
23602360

@@ -2368,12 +2368,12 @@ public static object Multiply(UInt64 x, UInt64 y) {
23682368
}
23692369

23702370
[SpecialName]
2371-
public static object Multiply(UInt64 x, Int64 y) {
2371+
public static object Multiply(UInt64 x, BigInteger y) {
23722372
return BigIntegerOps.Multiply((BigInteger)x, (BigInteger)y);
23732373
}
23742374

23752375
[SpecialName]
2376-
public static object Multiply(Int64 x, UInt64 y) {
2376+
public static object Multiply(BigInteger x, UInt64 y) {
23772377
return BigIntegerOps.Multiply((BigInteger)x, (BigInteger)y);
23782378
}
23792379

@@ -2383,12 +2383,12 @@ public static double TrueDivide(UInt64 x, UInt64 y) {
23832383
}
23842384

23852385
[SpecialName]
2386-
public static double TrueDivide(UInt64 x, Int64 y) {
2386+
public static double TrueDivide(UInt64 x, BigInteger y) {
23872387
return BigIntegerOps.TrueDivide((BigInteger)x, (BigInteger)y);
23882388
}
23892389

23902390
[SpecialName]
2391-
public static double TrueDivide(Int64 x, UInt64 y) {
2391+
public static double TrueDivide(BigInteger x, UInt64 y) {
23922392
return BigIntegerOps.TrueDivide((BigInteger)x, (BigInteger)y);
23932393
}
23942394

@@ -2398,12 +2398,12 @@ public static UInt64 FloorDivide(UInt64 x, UInt64 y) {
23982398
}
23992399

24002400
[SpecialName]
2401-
public static object FloorDivide(UInt64 x, Int64 y) {
2401+
public static object FloorDivide(UInt64 x, BigInteger y) {
24022402
return BigIntegerOps.FloorDivide((BigInteger)x, (BigInteger)y);
24032403
}
24042404

24052405
[SpecialName]
2406-
public static object FloorDivide(Int64 x, UInt64 y) {
2406+
public static object FloorDivide(BigInteger x, UInt64 y) {
24072407
return BigIntegerOps.FloorDivide((BigInteger)x, (BigInteger)y);
24082408
}
24092409

@@ -2413,12 +2413,12 @@ public static UInt64 Mod(UInt64 x, UInt64 y) {
24132413
}
24142414

24152415
[SpecialName]
2416-
public static BigInteger Mod(UInt64 x, Int64 y) {
2416+
public static BigInteger Mod(UInt64 x, BigInteger y) {
24172417
return BigIntegerOps.Mod((BigInteger)x, (BigInteger)y);
24182418
}
24192419

24202420
[SpecialName]
2421-
public static BigInteger Mod(Int64 x, UInt64 y) {
2421+
public static BigInteger Mod(BigInteger x, UInt64 y) {
24222422
return BigIntegerOps.Mod((BigInteger)x, (BigInteger)y);
24232423
}
24242424

@@ -2428,12 +2428,12 @@ public static object Power(UInt64 x, UInt64 y) {
24282428
}
24292429

24302430
[SpecialName]
2431-
public static object Power(UInt64 x, Int64 y) {
2431+
public static object Power(UInt64 x, BigInteger y) {
24322432
return BigIntegerOps.Power((BigInteger)x, (BigInteger)y);
24332433
}
24342434

24352435
[SpecialName]
2436-
public static object Power(Int64 x, UInt64 y) {
2436+
public static object Power(BigInteger x, UInt64 y) {
24372437
return BigIntegerOps.Power((BigInteger)x, (BigInteger)y);
24382438
}
24392439

@@ -2457,12 +2457,12 @@ public static UInt64 BitwiseAnd(UInt64 x, UInt64 y) {
24572457
}
24582458

24592459
[SpecialName]
2460-
public static BigInteger BitwiseAnd(UInt64 x, Int64 y) {
2460+
public static BigInteger BitwiseAnd(UInt64 x, BigInteger y) {
24612461
return BigIntegerOps.BitwiseAnd((BigInteger)x, (BigInteger)y);
24622462
}
24632463

24642464
[SpecialName]
2465-
public static BigInteger BitwiseAnd(Int64 x, UInt64 y) {
2465+
public static BigInteger BitwiseAnd(BigInteger x, UInt64 y) {
24662466
return BigIntegerOps.BitwiseAnd((BigInteger)x, (BigInteger)y);
24672467
}
24682468

@@ -2472,12 +2472,12 @@ public static UInt64 BitwiseOr(UInt64 x, UInt64 y) {
24722472
}
24732473

24742474
[SpecialName]
2475-
public static BigInteger BitwiseOr(UInt64 x, Int64 y) {
2475+
public static BigInteger BitwiseOr(UInt64 x, BigInteger y) {
24762476
return BigIntegerOps.BitwiseOr((BigInteger)x, (BigInteger)y);
24772477
}
24782478

24792479
[SpecialName]
2480-
public static BigInteger BitwiseOr(Int64 x, UInt64 y) {
2480+
public static BigInteger BitwiseOr(BigInteger x, UInt64 y) {
24812481
return BigIntegerOps.BitwiseOr((BigInteger)x, (BigInteger)y);
24822482
}
24832483

@@ -2487,12 +2487,12 @@ public static UInt64 ExclusiveOr(UInt64 x, UInt64 y) {
24872487
}
24882488

24892489
[SpecialName]
2490-
public static BigInteger ExclusiveOr(UInt64 x, Int64 y) {
2490+
public static BigInteger ExclusiveOr(UInt64 x, BigInteger y) {
24912491
return BigIntegerOps.ExclusiveOr((BigInteger)x, (BigInteger)y);
24922492
}
24932493

24942494
[SpecialName]
2495-
public static BigInteger ExclusiveOr(Int64 x, UInt64 y) {
2495+
public static BigInteger ExclusiveOr(BigInteger x, UInt64 y) {
24962496
return BigIntegerOps.ExclusiveOr((BigInteger)x, (BigInteger)y);
24972497
}
24982498

@@ -2503,27 +2503,27 @@ public static BigInteger ExclusiveOr(Int64 x, UInt64 y) {
25032503
[SpecialName]
25042504
public static bool LessThan(UInt64 x, UInt64 y) => x < y;
25052505
[SpecialName]
2506-
public static bool LessThan(UInt64 x, Int64 y) => BigIntegerOps.LessThan((BigInteger)x, (BigInteger)y);
2506+
public static bool LessThan(UInt64 x, BigInteger y) => BigIntegerOps.LessThan((BigInteger)x, (BigInteger)y);
25072507
[SpecialName]
25082508
public static bool LessThanOrEqual(UInt64 x, UInt64 y) => x <= y;
25092509
[SpecialName]
2510-
public static bool LessThanOrEqual(UInt64 x, Int64 y) => BigIntegerOps.LessThanOrEqual((BigInteger)x, (BigInteger)y);
2510+
public static bool LessThanOrEqual(UInt64 x, BigInteger y) => BigIntegerOps.LessThanOrEqual((BigInteger)x, (BigInteger)y);
25112511
[SpecialName]
25122512
public static bool GreaterThan(UInt64 x, UInt64 y) => x > y;
25132513
[SpecialName]
2514-
public static bool GreaterThan(UInt64 x, Int64 y) => BigIntegerOps.GreaterThan((BigInteger)x, (BigInteger)y);
2514+
public static bool GreaterThan(UInt64 x, BigInteger y) => BigIntegerOps.GreaterThan((BigInteger)x, (BigInteger)y);
25152515
[SpecialName]
25162516
public static bool GreaterThanOrEqual(UInt64 x, UInt64 y) => x >= y;
25172517
[SpecialName]
2518-
public static bool GreaterThanOrEqual(UInt64 x, Int64 y) => BigIntegerOps.GreaterThanOrEqual((BigInteger)x, (BigInteger)y);
2518+
public static bool GreaterThanOrEqual(UInt64 x, BigInteger y) => BigIntegerOps.GreaterThanOrEqual((BigInteger)x, (BigInteger)y);
25192519
[SpecialName]
25202520
public static bool Equals(UInt64 x, UInt64 y) => x == y;
25212521
[SpecialName]
2522-
public static bool Equals(UInt64 x, Int64 y) => BigIntegerOps.Equals((BigInteger)x, (BigInteger)y);
2522+
public static bool Equals(UInt64 x, BigInteger y) => BigIntegerOps.Equals((BigInteger)x, (BigInteger)y);
25232523
[SpecialName]
25242524
public static bool NotEquals(UInt64 x, UInt64 y) => x != y;
25252525
[SpecialName]
2526-
public static bool NotEquals(UInt64 x, Int64 y) => BigIntegerOps.NotEquals((BigInteger)x, (BigInteger)y);
2526+
public static bool NotEquals(UInt64 x, BigInteger y) => BigIntegerOps.NotEquals((BigInteger)x, (BigInteger)y);
25272527

25282528
#endregion
25292529

Src/IronPythonTest/Cases/IronPythonCasesManifest.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ Reason=Fails intermittently - https://github.com/IronLanguages/ironpython3/issue
6464
Timeout=300000 # 5 minute timeout - slow on macOS
6565

6666
[IronPython.test_numtypes]
67-
Ignore=true
68-
Reason=Takes way too long
67+
Timeout=300000 # 5 minute timeout - slow in general, but should finish within 3 min
6968

7069
[IronPython.test_peverify]
7170
Ignore=true

Src/Scripts/generate_alltypes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ def write_binop1_general(func, cw, body, name, ty, **kws):
285285
func(cw, body, name, ty, **kws)
286286

287287
if not ty.is_signed:
288-
oty = ty.get_signed()
288+
if ty.name in ["UInt64"]:
289+
oty = bigint
290+
else:
291+
oty = ty.get_signed()
289292
if 'return_type' not in kws or kws['return_type'] == ty.name:
290293
if name == 'FloorDivide':
291294
kws['return_type'] = 'object'
@@ -313,7 +316,10 @@ def write_rich_comp_general(func, cw, body, name, ty, **kws):
313316
func(cw, body, name, ty, **kws)
314317

315318
if not ty.is_signed:
316-
oty = ty.get_signed()
319+
if ty.name in ["UInt64"]:
320+
oty = bigint
321+
else:
322+
oty = ty.get_signed()
317323
kws['ltype'] = oty.name
318324
if cw.kws.get('bigger_signed') == "BigInteger":
319325
func(cw, unsigned_signed_body, name, ty, **kws)

Tests/test_complex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test(v, expected):
185185
test(complex(-0., +0.), "(-0+0j)")
186186
test(complex(-0., -0.), "(-0-0j)")
187187

188-
# NOTE: -0j not a complex literal in Python code but negated 0j, which is == -(0+0j) == (-0-0j)
188+
# NOTE: -0j is not a complex literal in Python code but negated 0j, which is == -(0+0j) == (-0-0j)
189189
test(0j, "0j")
190190
test(complex(0j), "0j")
191191
test(-0j, "(-0-0j)")

0 commit comments

Comments
 (0)