From 22567f3d7b797deac4c3b9c4ff5bc4d82f02c894 Mon Sep 17 00:00:00 2001 From: Matt Land Date: Sat, 30 Jul 2016 20:54:16 -0400 Subject: [PATCH 1/4] float add float --- .gitignore | 1 + python/common/org/python/types/Float.java | 3 +++ tests/datatypes/test_float.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index df0ee1714a..1a72b1a015 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ tests/temp .project .pydevproject tests/tmp* +.cache/ diff --git a/python/common/org/python/types/Float.java b/python/common/org/python/types/Float.java index 7f439c36c4..7b38575c1e 100644 --- a/python/common/org/python/types/Float.java +++ b/python/common/org/python/types/Float.java @@ -249,6 +249,9 @@ public org.python.Object __add__(org.python.Object other) { return new org.python.types.Float(this.value + 1.0); } return new org.python.types.Float(this.value); + } else if (other instanceof org.python.types.Float) { + double other_val = ((org.python.types.Float) other).value; + return new org.python.types.Float(this.value + other_val); } throw new org.python.exceptions.TypeError("unsupported operand type(s) for +: 'float' and '" + other.typeName() + "'"); } diff --git a/tests/datatypes/test_float.py b/tests/datatypes/test_float.py index 02a166e3a5..9a4826d41f 100644 --- a/tests/datatypes/test_float.py +++ b/tests/datatypes/test_float.py @@ -90,7 +90,7 @@ class BinaryFloatOperationTests(BinaryOperationTestCase, TranspileTestCase): not_implemented = [ 'test_add_bytearray', 'test_add_class', - 'test_add_float', + 'test_add_complex', 'test_add_frozenset', 'test_add_slice', From 3bd49ec43ab0fdc0a52ac570cd276e995f6970a3 Mon Sep 17 00:00:00 2001 From: Matt Land Date: Sat, 30 Jul 2016 21:10:00 -0400 Subject: [PATCH 2/4] missing from last --- tests/datatypes/test_float.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/datatypes/test_float.py b/tests/datatypes/test_float.py index 9a4826d41f..0f264bfa44 100644 --- a/tests/datatypes/test_float.py +++ b/tests/datatypes/test_float.py @@ -242,7 +242,7 @@ class InplaceFloatOperationTests(InplaceOperationTestCase, TranspileTestCase): not_implemented = [ 'test_add_bytearray', - 'test_add_float', + 'test_add_class', 'test_add_complex', 'test_add_frozenset', From d450be6f2fc53b4cfbf2183a8695d2c84040f805 Mon Sep 17 00:00:00 2001 From: Matt Land Date: Sat, 30 Jul 2016 21:28:01 -0400 Subject: [PATCH 3/4] would help to actually implement --- python/common/org/python/types/Float.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/common/org/python/types/Float.java b/python/common/org/python/types/Float.java index 7b38575c1e..5cbd681b5a 100644 --- a/python/common/org/python/types/Float.java +++ b/python/common/org/python/types/Float.java @@ -514,6 +514,9 @@ public org.python.Object __iadd__(org.python.Object other) { return new org.python.types.Float(this.value += 1.0); } return new org.python.types.Float(this.value); + } else if (other instanceof org.python.types.Float) { + double other_val = ((org.python.types.Float) other).value; + return new org.python.types.Float(this.value + other_val); } throw new org.python.exceptions.TypeError("unsupported operand type(s) for +=: 'float' and '" + other.typeName() + "'"); } From 2d0b4d9b7176d9dd158eab246367ba44eb50459f Mon Sep 17 00:00:00 2001 From: Matt Land Date: Sat, 30 Jul 2016 23:32:27 -0400 Subject: [PATCH 4/4] unexpected success --- tests/builtins/test_sum.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/builtins/test_sum.py b/tests/builtins/test_sum.py index cb1eb16ef1..3221ed4657 100644 --- a/tests/builtins/test_sum.py +++ b/tests/builtins/test_sum.py @@ -21,7 +21,6 @@ def test_sum_iterator(self): print(sum(i)) """) - @expectedFailure # + not defined on float/float yet. def test_sum_mix_floats_and_ints(self): self.assertCodeExecution(""" print(sum([1, 1.414, 2, 3.14159]))