Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import math | 5 import math |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 # pylint: disable=F0401 | 8 # pylint: disable=F0401 |
| 9 import mojo.bindings.reflection as reflection | 9 import mojo.bindings.reflection as reflection |
| 10 import mojo.system | 10 import mojo.system |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 if x == y: | 24 if x == y: |
| 25 return True | 25 return True |
| 26 | 26 |
| 27 if type(x) != type(y): | 27 if type(x) != type(y): |
| 28 print '\n%r != %r. Element are not of the same type.' % (x, y) | 28 print '\n%r != %r. Element are not of the same type.' % (x, y) |
| 29 return False | 29 return False |
| 30 | 30 |
| 31 if isinstance(x, float) and math.isnan(x) and math.isnan(y): | 31 if isinstance(x, float) and math.isnan(x) and math.isnan(y): |
| 32 return True | 32 return True |
| 33 | 33 |
| 34 if isinstance(x, dict): | |
| 35 x = x.items() | |
|
sdefresne
2014/10/10 15:10:27
I not sure whether python guarantee that dict1.ite
qsr
2014/10/10 15:36:06
Done.
| |
| 36 y = y.items() | |
| 37 | |
| 34 if hasattr(x, '__len__'): | 38 if hasattr(x, '__len__'): |
| 35 if len(x) != len(y): | 39 if len(x) != len(y): |
| 36 print '\n%r != %r. Iterables are not of the same size.' % (x, y) | 40 print '\n%r != %r. Iterables are not of the same size.' % (x, y) |
| 37 return False | 41 return False |
| 38 for (x1, y1) in zip(x, y): | 42 for (x1, y1) in zip(x, y): |
| 39 if not _TestEquality(x1, y1): | 43 if not _TestEquality(x1, y1): |
| 40 return False | 44 return False |
| 41 return True | 45 return True |
| 42 | 46 |
| 43 if (hasattr(x, '__metaclass__') and | 47 if (hasattr(x, '__metaclass__') and |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 v1.a21 = sample_import_mojom.Point() | 125 v1.a21 = sample_import_mojom.Point() |
| 122 v1.a22.location = sample_import_mojom.Point() | 126 v1.a22.location = sample_import_mojom.Point() |
| 123 v1.a22.size = sample_import2_mojom.Size() | 127 v1.a22.size = sample_import2_mojom.Size() |
| 124 (data, handles) = v1.Serialize() | 128 (data, handles) = v1.Serialize() |
| 125 v2 = sample_service_mojom.DefaultsTest.Deserialize(data, handles) | 129 v2 = sample_service_mojom.DefaultsTest.Deserialize(data, handles) |
| 126 self.assertTrue(_TestEquality(v1, v2)) | 130 self.assertTrue(_TestEquality(v1, v2)) |
| 127 | 131 |
| 128 def testFooDeserializationError(self): | 132 def testFooDeserializationError(self): |
| 129 with self.assertRaises(Exception): | 133 with self.assertRaises(Exception): |
| 130 sample_service_mojom.Foo.Deserialize("", []) | 134 sample_service_mojom.Foo.Deserialize("", []) |
| OLD | NEW |