From 6cbba50a43cdb4c8584d418153d8e0c2683107cb Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Wed, 10 Mar 2004 17:30:03 +0000 Subject: Make test_coercion.py less sensitive to platform fp quirks. Closes SF bug #678265. --- Lib/test/output/test_coercion | 658 +++++++++++++++++++++--------------------- Lib/test/test_coercion.py | 23 +- 2 files changed, 348 insertions(+), 333 deletions(-) diff --git a/Lib/test/output/test_coercion b/Lib/test/output/test_coercion index dc74b37..ad35b60 100644 --- a/Lib/test/output/test_coercion +++ b/Lib/test/output/test_coercion @@ -35,18 +35,18 @@ test_coercion 2 **= 2 => 4 2 % 2 = 0 2 %= 2 => 0 -2 + (2+0j) = (4+0j) -2 += (2+0j) => (4+0j) -2 - (2+0j) = 0j -2 -= (2+0j) => 0j -2 * (2+0j) = (4+0j) -2 *= (2+0j) => (4+0j) -2 / (2+0j) = (1+0j) -2 /= (2+0j) => (1+0j) -2 ** (2+0j) = (4+0j) -2 **= (2+0j) => (4+0j) -2 % (2+0j) = 0j -2 %= (2+0j) => 0j +2 + (2+0j) = (4.0 + 0.0j) +2 += (2+0j) => (4.0 + 0.0j) +2 - (2+0j) = (0.0 + 0.0j) +2 -= (2+0j) => (0.0 + 0.0j) +2 * (2+0j) = (4.0 + 0.0j) +2 *= (2+0j) => (4.0 + 0.0j) +2 / (2+0j) = (1.0 + 0.0j) +2 /= (2+0j) => (1.0 + 0.0j) +2 ** (2+0j) = (4.0 + 0.0j) +2 **= (2+0j) => (4.0 + 0.0j) +2 % (2+0j) = (0.0 + 0.0j) +2 %= (2+0j) => (0.0 + 0.0j) 2 + [1] ... exceptions.TypeError 2 += [1] ... exceptions.TypeError 2 - [1] ... exceptions.TypeError @@ -83,18 +83,18 @@ test_coercion 2 **= None ... exceptions.TypeError 2 % None ... exceptions.TypeError 2 %= None ... exceptions.TypeError -2 + = 3 -2 += => 3 -2 - = 1 -2 -= => 1 -2 * = 2 -2 *= => 2 -2 / = 2 -2 /= => 2 -2 ** = 2 -2 **= => 2 -2 % = 0 -2 %= => 0 +2 + = 4 +2 += => 4 +2 - = 0 +2 -= => 0 +2 * = 4 +2 *= => 4 +2 / = 1 +2 /= => 1 +2 ** = 4 +2 **= => 4 +2 % = 0 +2 %= => 0 2 + = 4 2 += => 4 2 - = 0 @@ -143,18 +143,18 @@ test_coercion 4.0 **= 2 => 16.0 4.0 % 2 = 0.0 4.0 %= 2 => 0.0 -4.0 + (2+0j) = (6+0j) -4.0 += (2+0j) => (6+0j) -4.0 - (2+0j) = (2+0j) -4.0 -= (2+0j) => (2+0j) -4.0 * (2+0j) = (8+0j) -4.0 *= (2+0j) => (8+0j) -4.0 / (2+0j) = (2+0j) -4.0 /= (2+0j) => (2+0j) -4.0 ** (2+0j) = (16+0j) -4.0 **= (2+0j) => (16+0j) -4.0 % (2+0j) = 0j -4.0 %= (2+0j) => 0j +4.0 + (2+0j) = (6.0 + 0.0j) +4.0 += (2+0j) => (6.0 + 0.0j) +4.0 - (2+0j) = (2.0 + 0.0j) +4.0 -= (2+0j) => (2.0 + 0.0j) +4.0 * (2+0j) = (8.0 + 0.0j) +4.0 *= (2+0j) => (8.0 + 0.0j) +4.0 / (2+0j) = (2.0 + 0.0j) +4.0 /= (2+0j) => (2.0 + 0.0j) +4.0 ** (2+0j) = (16.0 + 0.0j) +4.0 **= (2+0j) => (16.0 + 0.0j) +4.0 % (2+0j) = (0.0 + 0.0j) +4.0 %= (2+0j) => (0.0 + 0.0j) 4.0 + [1] ... exceptions.TypeError 4.0 += [1] ... exceptions.TypeError 4.0 - [1] ... exceptions.TypeError @@ -191,18 +191,18 @@ test_coercion 4.0 **= None ... exceptions.TypeError 4.0 % None ... exceptions.TypeError 4.0 %= None ... exceptions.TypeError -4.0 + = 5.0 -4.0 += => 5.0 -4.0 - = 3.0 -4.0 -= => 3.0 -4.0 * = 4.0 -4.0 *= => 4.0 -4.0 / = 4.0 -4.0 /= => 4.0 -4.0 ** = 4.0 -4.0 **= => 4.0 -4.0 % = 0.0 -4.0 %= => 0.0 +4.0 + = 6.0 +4.0 += => 6.0 +4.0 - = 2.0 +4.0 -= => 2.0 +4.0 * = 8.0 +4.0 *= => 8.0 +4.0 / = 2.0 +4.0 /= => 2.0 +4.0 ** = 16.0 +4.0 **= => 16.0 +4.0 % = 0.0 +4.0 %= => 0.0 4.0 + = 6.0 4.0 += => 6.0 4.0 - = 2.0 @@ -251,18 +251,18 @@ test_coercion 2 **= 2 => 4 2 % 2 = 0 2 %= 2 => 0 -2 + (2+0j) = (4+0j) -2 += (2+0j) => (4+0j) -2 - (2+0j) = 0j -2 -= (2+0j) => 0j -2 * (2+0j) = (4+0j) -2 *= (2+0j) => (4+0j) -2 / (2+0j) = (1+0j) -2 /= (2+0j) => (1+0j) -2 ** (2+0j) = (4+0j) -2 **= (2+0j) => (4+0j) -2 % (2+0j) = 0j -2 %= (2+0j) => 0j +2 + (2+0j) = (4.0 + 0.0j) +2 += (2+0j) => (4.0 + 0.0j) +2 - (2+0j) = (0.0 + 0.0j) +2 -= (2+0j) => (0.0 + 0.0j) +2 * (2+0j) = (4.0 + 0.0j) +2 *= (2+0j) => (4.0 + 0.0j) +2 / (2+0j) = (1.0 + 0.0j) +2 /= (2+0j) => (1.0 + 0.0j) +2 ** (2+0j) = (4.0 + 0.0j) +2 **= (2+0j) => (4.0 + 0.0j) +2 % (2+0j) = (0.0 + 0.0j) +2 %= (2+0j) => (0.0 + 0.0j) 2 + [1] ... exceptions.TypeError 2 += [1] ... exceptions.TypeError 2 - [1] ... exceptions.TypeError @@ -299,18 +299,18 @@ test_coercion 2 **= None ... exceptions.TypeError 2 % None ... exceptions.TypeError 2 %= None ... exceptions.TypeError -2 + = 3 -2 += => 3 -2 - = 1 -2 -= => 1 -2 * = 2 -2 *= => 2 -2 / = 2 -2 /= => 2 -2 ** = 2 -2 **= => 2 -2 % = 0 -2 %= => 0 +2 + = 4 +2 += => 4 +2 - = 0 +2 -= => 0 +2 * = 4 +2 *= => 4 +2 / = 1 +2 /= => 1 +2 ** = 4 +2 **= => 4 +2 % = 0 +2 %= => 0 2 + = 4 2 += => 4 2 - = 0 @@ -323,54 +323,54 @@ test_coercion 2 **= => 4 2 % = 0 2 %= => 0 -(2+0j) + 2 = (4+0j) -(2+0j) += 2 => (4+0j) -(2+0j) - 2 = 0j -(2+0j) -= 2 => 0j -(2+0j) * 2 = (4+0j) -(2+0j) *= 2 => (4+0j) -(2+0j) / 2 = (1+0j) -(2+0j) /= 2 => (1+0j) -(2+0j) ** 2 = (4+0j) -(2+0j) **= 2 => (4+0j) -(2+0j) % 2 = 0j -(2+0j) %= 2 => 0j -(2+0j) + 4.0 = (6+0j) -(2+0j) += 4.0 => (6+0j) -(2+0j) - 4.0 = (-2+0j) -(2+0j) -= 4.0 => (-2+0j) -(2+0j) * 4.0 = (8+0j) -(2+0j) *= 4.0 => (8+0j) -(2+0j) / 4.0 = (0.5+0j) -(2+0j) /= 4.0 => (0.5+0j) -(2+0j) ** 4.0 = (16+0j) -(2+0j) **= 4.0 => (16+0j) -(2+0j) % 4.0 = (2+0j) -(2+0j) %= 4.0 => (2+0j) -(2+0j) + 2 = (4+0j) -(2+0j) += 2 => (4+0j) -(2+0j) - 2 = 0j -(2+0j) -= 2 => 0j -(2+0j) * 2 = (4+0j) -(2+0j) *= 2 => (4+0j) -(2+0j) / 2 = (1+0j) -(2+0j) /= 2 => (1+0j) -(2+0j) ** 2 = (4+0j) -(2+0j) **= 2 => (4+0j) -(2+0j) % 2 = 0j -(2+0j) %= 2 => 0j -(2+0j) + (2+0j) = (4+0j) -(2+0j) += (2+0j) => (4+0j) -(2+0j) - (2+0j) = 0j -(2+0j) -= (2+0j) => 0j -(2+0j) * (2+0j) = (4+0j) -(2+0j) *= (2+0j) => (4+0j) -(2+0j) / (2+0j) = (1+0j) -(2+0j) /= (2+0j) => (1+0j) -(2+0j) ** (2+0j) = (4+0j) -(2+0j) **= (2+0j) => (4+0j) -(2+0j) % (2+0j) = 0j -(2+0j) %= (2+0j) => 0j +(2+0j) + 2 = (4.0 + 0.0j) +(2+0j) += 2 => (4.0 + 0.0j) +(2+0j) - 2 = (0.0 + 0.0j) +(2+0j) -= 2 => (0.0 + 0.0j) +(2+0j) * 2 = (4.0 + 0.0j) +(2+0j) *= 2 => (4.0 + 0.0j) +(2+0j) / 2 = (1.0 + 0.0j) +(2+0j) /= 2 => (1.0 + 0.0j) +(2+0j) ** 2 = (4.0 + 0.0j) +(2+0j) **= 2 => (4.0 + 0.0j) +(2+0j) % 2 = (0.0 + 0.0j) +(2+0j) %= 2 => (0.0 + 0.0j) +(2+0j) + 4.0 = (6.0 + 0.0j) +(2+0j) += 4.0 => (6.0 + 0.0j) +(2+0j) - 4.0 = (-2.0 + 0.0j) +(2+0j) -= 4.0 => (-2.0 + 0.0j) +(2+0j) * 4.0 = (8.0 + 0.0j) +(2+0j) *= 4.0 => (8.0 + 0.0j) +(2+0j) / 4.0 = (0.5 + 0.0j) +(2+0j) /= 4.0 => (0.5 + 0.0j) +(2+0j) ** 4.0 = (16.0 + 0.0j) +(2+0j) **= 4.0 => (16.0 + 0.0j) +(2+0j) % 4.0 = (2.0 + 0.0j) +(2+0j) %= 4.0 => (2.0 + 0.0j) +(2+0j) + 2 = (4.0 + 0.0j) +(2+0j) += 2 => (4.0 + 0.0j) +(2+0j) - 2 = (0.0 + 0.0j) +(2+0j) -= 2 => (0.0 + 0.0j) +(2+0j) * 2 = (4.0 + 0.0j) +(2+0j) *= 2 => (4.0 + 0.0j) +(2+0j) / 2 = (1.0 + 0.0j) +(2+0j) /= 2 => (1.0 + 0.0j) +(2+0j) ** 2 = (4.0 + 0.0j) +(2+0j) **= 2 => (4.0 + 0.0j) +(2+0j) % 2 = (0.0 + 0.0j) +(2+0j) %= 2 => (0.0 + 0.0j) +(2+0j) + (2+0j) = (4.0 + 0.0j) +(2+0j) += (2+0j) => (4.0 + 0.0j) +(2+0j) - (2+0j) = (0.0 + 0.0j) +(2+0j) -= (2+0j) => (0.0 + 0.0j) +(2+0j) * (2+0j) = (4.0 + 0.0j) +(2+0j) *= (2+0j) => (4.0 + 0.0j) +(2+0j) / (2+0j) = (1.0 + 0.0j) +(2+0j) /= (2+0j) => (1.0 + 0.0j) +(2+0j) ** (2+0j) = (4.0 + 0.0j) +(2+0j) **= (2+0j) => (4.0 + 0.0j) +(2+0j) % (2+0j) = (0.0 + 0.0j) +(2+0j) %= (2+0j) => (0.0 + 0.0j) (2+0j) + [1] ... exceptions.TypeError (2+0j) += [1] ... exceptions.TypeError (2+0j) - [1] ... exceptions.TypeError @@ -407,30 +407,30 @@ test_coercion (2+0j) **= None ... exceptions.TypeError (2+0j) % None ... exceptions.TypeError (2+0j) %= None ... exceptions.TypeError -(2+0j) + = (3+0j) -(2+0j) += => (3+0j) -(2+0j) - = (1+0j) -(2+0j) -= => (1+0j) -(2+0j) * = (2+0j) -(2+0j) *= => (2+0j) -(2+0j) / = (2+0j) -(2+0j) /= => (2+0j) -(2+0j) ** = (2+0j) -(2+0j) **= => (2+0j) -(2+0j) % = 0j -(2+0j) %= => 0j -(2+0j) + = (4+0j) -(2+0j) += => (4+0j) -(2+0j) - = 0j -(2+0j) -= => 0j -(2+0j) * = (4+0j) -(2+0j) *= => (4+0j) -(2+0j) / = (1+0j) -(2+0j) /= => (1+0j) -(2+0j) ** = (4+0j) -(2+0j) **= => (4+0j) -(2+0j) % = 0j -(2+0j) %= => 0j +(2+0j) + = (4.0 + 0.0j) +(2+0j) += => (4.0 + 0.0j) +(2+0j) - = (0.0 + 0.0j) +(2+0j) -= => (0.0 + 0.0j) +(2+0j) * = (4.0 + 0.0j) +(2+0j) *= => (4.0 + 0.0j) +(2+0j) / = (1.0 + 0.0j) +(2+0j) /= => (1.0 + 0.0j) +(2+0j) ** = (4.0 + 0.0j) +(2+0j) **= => (4.0 + 0.0j) +(2+0j) % = (0.0 + 0.0j) +(2+0j) %= => (0.0 + 0.0j) +(2+0j) + = (4.0 + 0.0j) +(2+0j) += => (4.0 + 0.0j) +(2+0j) - = (0.0 + 0.0j) +(2+0j) -= => (0.0 + 0.0j) +(2+0j) * = (4.0 + 0.0j) +(2+0j) *= => (4.0 + 0.0j) +(2+0j) / = (1.0 + 0.0j) +(2+0j) /= => (1.0 + 0.0j) +(2+0j) ** = (4.0 + 0.0j) +(2+0j) **= => (4.0 + 0.0j) +(2+0j) % = (0.0 + 0.0j) +(2+0j) %= => (0.0 + 0.0j) [1] + 2 ... exceptions.TypeError [1] += 2 ... exceptions.TypeError [1] - 2 ... exceptions.TypeError @@ -515,18 +515,18 @@ test_coercion [1] **= None ... exceptions.TypeError [1] % None ... exceptions.TypeError [1] %= None ... exceptions.TypeError -[1] + ... exceptions.TypeError -[1] += ... exceptions.TypeError -[1] - ... exceptions.TypeError -[1] -= ... exceptions.TypeError -[1] * = [1] -[1] *= => [1] -[1] / ... exceptions.TypeError -[1] /= ... exceptions.TypeError -[1] ** ... exceptions.TypeError -[1] **= ... exceptions.TypeError -[1] % ... exceptions.TypeError -[1] %= ... exceptions.TypeError +[1] + ... exceptions.TypeError +[1] += ... exceptions.TypeError +[1] - ... exceptions.TypeError +[1] -= ... exceptions.TypeError +[1] * = [1, 1] +[1] *= => [1, 1] +[1] / ... exceptions.TypeError +[1] /= ... exceptions.TypeError +[1] ** ... exceptions.TypeError +[1] **= ... exceptions.TypeError +[1] % ... exceptions.TypeError +[1] %= ... exceptions.TypeError [1] + ... exceptions.TypeError [1] += ... exceptions.TypeError [1] - ... exceptions.TypeError @@ -623,18 +623,18 @@ test_coercion (2,) **= None ... exceptions.TypeError (2,) % None ... exceptions.TypeError (2,) %= None ... exceptions.TypeError -(2,) + ... exceptions.TypeError -(2,) += ... exceptions.TypeError -(2,) - ... exceptions.TypeError -(2,) -= ... exceptions.TypeError -(2,) * = (2,) -(2,) *= => (2,) -(2,) / ... exceptions.TypeError -(2,) /= ... exceptions.TypeError -(2,) ** ... exceptions.TypeError -(2,) **= ... exceptions.TypeError -(2,) % ... exceptions.TypeError -(2,) %= ... exceptions.TypeError +(2,) + ... exceptions.TypeError +(2,) += ... exceptions.TypeError +(2,) - ... exceptions.TypeError +(2,) -= ... exceptions.TypeError +(2,) * = (2, 2) +(2,) *= => (2, 2) +(2,) / ... exceptions.TypeError +(2,) /= ... exceptions.TypeError +(2,) ** ... exceptions.TypeError +(2,) **= ... exceptions.TypeError +(2,) % ... exceptions.TypeError +(2,) %= ... exceptions.TypeError (2,) + ... exceptions.TypeError (2,) += ... exceptions.TypeError (2,) - ... exceptions.TypeError @@ -731,18 +731,18 @@ None ** None ... exceptions.TypeError None **= None ... exceptions.TypeError None % None ... exceptions.TypeError None %= None ... exceptions.TypeError -None + ... exceptions.TypeError -None += ... exceptions.TypeError -None - ... exceptions.TypeError -None -= ... exceptions.TypeError -None * ... exceptions.TypeError -None *= ... exceptions.TypeError -None / ... exceptions.TypeError -None /= ... exceptions.TypeError -None ** ... exceptions.TypeError -None **= ... exceptions.TypeError -None % ... exceptions.TypeError -None %= ... exceptions.TypeError +None + ... exceptions.TypeError +None += ... exceptions.TypeError +None - ... exceptions.TypeError +None -= ... exceptions.TypeError +None * ... exceptions.TypeError +None *= ... exceptions.TypeError +None / ... exceptions.TypeError +None /= ... exceptions.TypeError +None ** ... exceptions.TypeError +None **= ... exceptions.TypeError +None % ... exceptions.TypeError +None %= ... exceptions.TypeError None + ... exceptions.TypeError None += ... exceptions.TypeError None - ... exceptions.TypeError @@ -755,114 +755,114 @@ None ** ... exceptions.TypeError None **= ... exceptions.TypeError None % ... exceptions.TypeError None %= ... exceptions.TypeError - + 2 = 3 - += 2 => 3 - - 2 = -1 - -= 2 => -1 - * 2 = 2 - *= 2 => 2 - / 2 = 0 - /= 2 => 0 - ** 2 = 1 - **= 2 => 1 - % 2 = 1 - %= 2 => 1 - + 4.0 = 5.0 - += 4.0 => 5.0 - - 4.0 = -3.0 - -= 4.0 => -3.0 - * 4.0 = 4.0 - *= 4.0 => 4.0 - / 4.0 = 0.25 - /= 4.0 => 0.25 - ** 4.0 = 1.0 - **= 4.0 => 1.0 - % 4.0 = 1.0 - %= 4.0 => 1.0 - + 2 = 3 - += 2 => 3 - - 2 = -1 - -= 2 => -1 - * 2 = 2 - *= 2 => 2 - / 2 = 0 - /= 2 => 0 - ** 2 = 1 - **= 2 => 1 - % 2 = 1 - %= 2 => 1 - + (2+0j) = (3+0j) - += (2+0j) => (3+0j) - - (2+0j) = (-1+0j) - -= (2+0j) => (-1+0j) - * (2+0j) = (2+0j) - *= (2+0j) => (2+0j) - / (2+0j) = (0.5+0j) - /= (2+0j) => (0.5+0j) - ** (2+0j) = (1+0j) - **= (2+0j) => (1+0j) - % (2+0j) = (1+0j) - %= (2+0j) => (1+0j) - + [1] ... exceptions.TypeError - += [1] ... exceptions.TypeError - - [1] ... exceptions.TypeError - -= [1] ... exceptions.TypeError - * [1] = [1] - *= [1] => [1] - / [1] ... exceptions.TypeError - /= [1] ... exceptions.TypeError - ** [1] ... exceptions.TypeError - **= [1] ... exceptions.TypeError - % [1] ... exceptions.TypeError - %= [1] ... exceptions.TypeError - + (2,) ... exceptions.TypeError - += (2,) ... exceptions.TypeError - - (2,) ... exceptions.TypeError - -= (2,) ... exceptions.TypeError - * (2,) = (2,) - *= (2,) => (2,) - / (2,) ... exceptions.TypeError - /= (2,) ... exceptions.TypeError - ** (2,) ... exceptions.TypeError - **= (2,) ... exceptions.TypeError - % (2,) ... exceptions.TypeError - %= (2,) ... exceptions.TypeError - + None ... exceptions.TypeError - += None ... exceptions.TypeError - - None ... exceptions.TypeError - -= None ... exceptions.TypeError - * None ... exceptions.TypeError - *= None ... exceptions.TypeError - / None ... exceptions.TypeError - /= None ... exceptions.TypeError - ** None ... exceptions.TypeError - **= None ... exceptions.TypeError - % None ... exceptions.TypeError - %= None ... exceptions.TypeError - + = 2 - += => 2 - - = 0 - -= => 0 - * = 1 - *= => 1 - / = 1 - /= => 1 - ** = 1 - **= => 1 - % = 0 - %= => 0 - + = 3 - += => 3 - - = -1 - -= => -1 - * = 2 - *= => 2 - / = 0 - /= => 0 - ** = 1 - **= => 1 - % = 1 - %= => 1 + + 2 = 4 + += 2 => 4 + - 2 = 0 + -= 2 => 0 + * 2 = 4 + *= 2 => 4 + / 2 = 1 + /= 2 => 1 + ** 2 = 4 + **= 2 => 4 + % 2 = 0 + %= 2 => 0 + + 4.0 = 6.0 + += 4.0 => 6.0 + - 4.0 = -2.0 + -= 4.0 => -2.0 + * 4.0 = 8.0 + *= 4.0 => 8.0 + / 4.0 = 0.5 + /= 4.0 => 0.5 + ** 4.0 = 16.0 + **= 4.0 => 16.0 + % 4.0 = 2.0 + %= 4.0 => 2.0 + + 2 = 4 + += 2 => 4 + - 2 = 0 + -= 2 => 0 + * 2 = 4 + *= 2 => 4 + / 2 = 1 + /= 2 => 1 + ** 2 = 4 + **= 2 => 4 + % 2 = 0 + %= 2 => 0 + + (2+0j) = (4.0 + 0.0j) + += (2+0j) => (4.0 + 0.0j) + - (2+0j) = (0.0 + 0.0j) + -= (2+0j) => (0.0 + 0.0j) + * (2+0j) = (4.0 + 0.0j) + *= (2+0j) => (4.0 + 0.0j) + / (2+0j) = (1.0 + 0.0j) + /= (2+0j) => (1.0 + 0.0j) + ** (2+0j) = (4.0 + 0.0j) + **= (2+0j) => (4.0 + 0.0j) + % (2+0j) = (0.0 + 0.0j) + %= (2+0j) => (0.0 + 0.0j) + + [1] ... exceptions.TypeError + += [1] ... exceptions.TypeError + - [1] ... exceptions.TypeError + -= [1] ... exceptions.TypeError + * [1] = [1, 1] + *= [1] => [1, 1] + / [1] ... exceptions.TypeError + /= [1] ... exceptions.TypeError + ** [1] ... exceptions.TypeError + **= [1] ... exceptions.TypeError + % [1] ... exceptions.TypeError + %= [1] ... exceptions.TypeError + + (2,) ... exceptions.TypeError + += (2,) ... exceptions.TypeError + - (2,) ... exceptions.TypeError + -= (2,) ... exceptions.TypeError + * (2,) = (2, 2) + *= (2,) => (2, 2) + / (2,) ... exceptions.TypeError + /= (2,) ... exceptions.TypeError + ** (2,) ... exceptions.TypeError + **= (2,) ... exceptions.TypeError + % (2,) ... exceptions.TypeError + %= (2,) ... exceptions.TypeError + + None ... exceptions.TypeError + += None ... exceptions.TypeError + - None ... exceptions.TypeError + -= None ... exceptions.TypeError + * None ... exceptions.TypeError + *= None ... exceptions.TypeError + / None ... exceptions.TypeError + /= None ... exceptions.TypeError + ** None ... exceptions.TypeError + **= None ... exceptions.TypeError + % None ... exceptions.TypeError + %= None ... exceptions.TypeError + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 + 2 = 4 += 2 => 4 - 2 = 0 @@ -899,18 +899,18 @@ None %= ... exceptions.TypeError **= 2 => 4 % 2 = 0 %= 2 => 0 - + (2+0j) = (4+0j) - += (2+0j) => (4+0j) - - (2+0j) = 0j - -= (2+0j) => 0j - * (2+0j) = (4+0j) - *= (2+0j) => (4+0j) - / (2+0j) = (1+0j) - /= (2+0j) => (1+0j) - ** (2+0j) = (4+0j) - **= (2+0j) => (4+0j) - % (2+0j) = 0j - %= (2+0j) => 0j + + (2+0j) = (4.0 + 0.0j) + += (2+0j) => (4.0 + 0.0j) + - (2+0j) = (0.0 + 0.0j) + -= (2+0j) => (0.0 + 0.0j) + * (2+0j) = (4.0 + 0.0j) + *= (2+0j) => (4.0 + 0.0j) + / (2+0j) = (1.0 + 0.0j) + /= (2+0j) => (1.0 + 0.0j) + ** (2+0j) = (4.0 + 0.0j) + **= (2+0j) => (4.0 + 0.0j) + % (2+0j) = (0.0 + 0.0j) + %= (2+0j) => (0.0 + 0.0j) + [1] ... exceptions.TypeError += [1] ... exceptions.TypeError - [1] ... exceptions.TypeError @@ -947,18 +947,18 @@ None %= ... exceptions.TypeError **= None ... exceptions.TypeError % None ... exceptions.TypeError %= None ... exceptions.TypeError - + = 3 - += => 3 - - = 1 - -= => 1 - * = 2 - *= => 2 - / = 2 - /= => 2 - ** = 2 - **= => 2 - % = 0 - %= => 0 + + = 4 + += => 4 + - = 0 + -= => 0 + * = 4 + *= => 4 + / = 1 + /= => 1 + ** = 4 + **= => 4 + % = 0 + %= => 0 + = 4 += => 4 - = 0 @@ -978,7 +978,7 @@ divmod(2, (2+0j)) = ((1+0j), 0j) divmod(2, [1]) ... exceptions.TypeError divmod(2, (2,)) ... exceptions.TypeError divmod(2, None) ... exceptions.TypeError -divmod(2, ) ... exceptions.TypeError +divmod(2, ) ... exceptions.TypeError divmod(2, ) = (1, 0) divmod(4.0, 2) = (2.0, 0.0) divmod(4.0, 4.0) = (1.0, 0.0) @@ -987,7 +987,7 @@ divmod(4.0, (2+0j)) = ((2+0j), 0j) divmod(4.0, [1]) ... exceptions.TypeError divmod(4.0, (2,)) ... exceptions.TypeError divmod(4.0, None) ... exceptions.TypeError -divmod(4.0, ) ... exceptions.TypeError +divmod(4.0, ) ... exceptions.TypeError divmod(4.0, ) = (2.0, 0.0) divmod(2, 2) = (1L, 0L) divmod(2, 4.0) = (0.0, 2.0) @@ -996,7 +996,7 @@ divmod(2, (2+0j)) = ((1+0j), 0j) divmod(2, [1]) ... exceptions.TypeError divmod(2, (2,)) ... exceptions.TypeError divmod(2, None) ... exceptions.TypeError -divmod(2, ) ... exceptions.TypeError +divmod(2, ) ... exceptions.TypeError divmod(2, ) = (1L, 0L) divmod((2+0j), 2) = ((1+0j), 0j) divmod((2+0j), 4.0) = (0j, (2+0j)) @@ -1005,7 +1005,7 @@ divmod((2+0j), (2+0j)) = ((1+0j), 0j) divmod((2+0j), [1]) ... exceptions.TypeError divmod((2+0j), (2,)) ... exceptions.TypeError divmod((2+0j), None) ... exceptions.TypeError -divmod((2+0j), ) ... exceptions.TypeError +divmod((2+0j), ) ... exceptions.TypeError divmod((2+0j), ) = ((1+0j), 0j) divmod([1], 2) ... exceptions.TypeError divmod([1], 4.0) ... exceptions.TypeError @@ -1014,7 +1014,7 @@ divmod([1], (2+0j)) ... exceptions.TypeError divmod([1], [1]) ... exceptions.TypeError divmod([1], (2,)) ... exceptions.TypeError divmod([1], None) ... exceptions.TypeError -divmod([1], ) ... exceptions.TypeError +divmod([1], ) ... exceptions.TypeError divmod([1], ) ... exceptions.TypeError divmod((2,), 2) ... exceptions.TypeError divmod((2,), 4.0) ... exceptions.TypeError @@ -1023,7 +1023,7 @@ divmod((2,), (2+0j)) ... exceptions.TypeError divmod((2,), [1]) ... exceptions.TypeError divmod((2,), (2,)) ... exceptions.TypeError divmod((2,), None) ... exceptions.TypeError -divmod((2,), ) ... exceptions.TypeError +divmod((2,), ) ... exceptions.TypeError divmod((2,), ) ... exceptions.TypeError divmod(None, 2) ... exceptions.TypeError divmod(None, 4.0) ... exceptions.TypeError @@ -1032,17 +1032,17 @@ divmod(None, (2+0j)) ... exceptions.TypeError divmod(None, [1]) ... exceptions.TypeError divmod(None, (2,)) ... exceptions.TypeError divmod(None, None) ... exceptions.TypeError -divmod(None, ) ... exceptions.TypeError +divmod(None, ) ... exceptions.TypeError divmod(None, ) ... exceptions.TypeError -divmod(, 2) ... exceptions.TypeError -divmod(, 4.0) ... exceptions.TypeError -divmod(, 2) ... exceptions.TypeError -divmod(, (2+0j)) ... exceptions.TypeError -divmod(, [1]) ... exceptions.TypeError -divmod(, (2,)) ... exceptions.TypeError -divmod(, None) ... exceptions.TypeError -divmod(, ) ... exceptions.TypeError -divmod(, ) ... exceptions.TypeError +divmod(, 2) ... exceptions.TypeError +divmod(, 4.0) ... exceptions.TypeError +divmod(, 2) ... exceptions.TypeError +divmod(, (2+0j)) ... exceptions.TypeError +divmod(, [1]) ... exceptions.TypeError +divmod(, (2,)) ... exceptions.TypeError +divmod(, None) ... exceptions.TypeError +divmod(, ) ... exceptions.TypeError +divmod(, ) ... exceptions.TypeError divmod(, 2) = (1, 0) divmod(, 4.0) = (0.0, 2.0) divmod(, 2) = (1L, 0L) @@ -1050,5 +1050,5 @@ divmod(, (2+0j)) = ((1+0j), 0j) divmod(, [1]) ... exceptions.TypeError divmod(, (2,)) ... exceptions.TypeError divmod(, None) ... exceptions.TypeError -divmod(, ) ... exceptions.TypeError +divmod(, ) ... exceptions.TypeError divmod(, ) = (1, 0) diff --git a/Lib/test/test_coercion.py b/Lib/test/test_coercion.py index be5b744..331771f 100644 --- a/Lib/test/test_coercion.py +++ b/Lib/test/test_coercion.py @@ -67,11 +67,26 @@ class MethodNumber: candidates = [ 2, 4.0, 2L, 2+0j, [1], (2,), None, - MethodNumber(1), CoerceNumber(2)] + MethodNumber(2), CoerceNumber(2)] infix_binops = [ '+', '-', '*', '/', '**', '%' ] prefix_binops = [ 'divmod' ] +def format_float(value): + if abs(value) < 0.01: + return '0.0' + else: + return '%.1f' % value + +# avoid testing platform fp quirks +def format_result(value): + if isinstance(value, complex): + return '(%s + %sj)' % (format_float(value.real), + format_float(value.imag)) + elif isinstance(value, float): + return format_float(value) + return str(value) + def do_infix_binops(): for a in candidates: for b in candidates: @@ -83,7 +98,7 @@ def do_infix_binops(): error = sys.exc_info()[:2] print '... %s' % error[0] else: - print '=', x + print '=', format_result(x) try: z = copy.copy(a) except copy.Error: @@ -95,7 +110,7 @@ def do_infix_binops(): error = sys.exc_info()[:2] print '... %s' % error[0] else: - print '=>', z + print '=>', format_result(z) def do_prefix_binops(): for a in candidates: @@ -108,7 +123,7 @@ def do_prefix_binops(): error = sys.exc_info()[:2] print '... %s' % error[0] else: - print '=', x + print '=', format_result(x) warnings.filterwarnings("ignore", r'complex divmod\(\), // and % are deprecated', -- cgit v0.12