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 # Generated files | 8 # Generated files |
9 # pylint: disable=F0401 | 9 # pylint: disable=F0401 |
10 import sample_service_mojom | 10 import sample_service_mojom |
11 | 11 |
12 | 12 |
13 class ConstantBindingsTest(unittest.TestCase): | 13 class ConstantBindingsTest(unittest.TestCase): |
14 | 14 |
15 def testConstantGeneration(self): | 15 def testConstantGeneration(self): |
16 self.assertEquals(sample_service_mojom.TWELVE, 12) | 16 self.assertEquals(sample_service_mojom.TWELVE, 12) |
17 self.assertEquals(sample_service_mojom.TOO_BIG_FOR_SIGNED_INT64, | 17 self.assertEquals(sample_service_mojom.TOO_BIG_FOR_SIGNED_INT64, |
18 9999999999999999999) | 18 9999999999999999999) |
19 self.assertEquals(sample_service_mojom.DOUBLE_INFINITY, | 19 self.assertEquals(sample_service_mojom.DOUBLE_INFINITY, |
20 float('inf')) | 20 float('inf')) |
21 self.assertEquals(sample_service_mojom.DOUBLE_NEGATIVE_INFINITY, | 21 self.assertEquals(sample_service_mojom.DOUBLE_NEGATIVE_INFINITY, |
22 float('-inf')) | 22 float('-inf')) |
23 self.assertTrue(math.isnan(sample_service_mojom.DOUBLE_NA_N)) | 23 self.assertTrue(math.isnan(sample_service_mojom.DOUBLE_NA_N)) |
24 self.assertEquals(sample_service_mojom.FLOAT_INFINITY, | 24 self.assertEquals(sample_service_mojom.FLOAT_INFINITY, |
25 float('inf')) | 25 float('inf')) |
26 self.assertEquals(sample_service_mojom.FLOAT_NEGATIVE_INFINITY, | 26 self.assertEquals(sample_service_mojom.FLOAT_NEGATIVE_INFINITY, |
27 float('-inf')) | 27 float('-inf')) |
28 self.assertTrue(math.isnan(sample_service_mojom.FLOAT_NA_N)) | 28 self.assertTrue(math.isnan(sample_service_mojom.FLOAT_NA_N)) |
29 | |
30 def testConstantOnStructGeneration(self): | |
31 self.assertEquals(sample_service_mojom.Foo.FOOBY, "Fooby") | |
32 | |
33 def testStructImmutability(self): | |
34 with self.assertRaises(AttributeError): | |
35 sample_service_mojom.Foo.FOOBY = 0 | |
36 with self.assertRaises(AttributeError): | |
37 del sample_service_mojom.Foo.FOOBY | |
38 with self.assertRaises(AttributeError): | |
39 sample_service_mojom.Foo.BAR = 1 | |
sdefresne
2014/09/09 08:51:57
Q: just to be sure, but this is testing that user
qsr
2014/09/09 08:55:10
Exactly.
| |
OLD | NEW |