OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <script> | 3 <script> |
4 description('IDL union types unittests'); | 4 description('IDL union types unittests'); |
5 | 5 |
6 if (window.internals) { | 6 if (window.internals) { |
7 // The conversion rule prefers string over double, hence a value which | |
8 // is neither double nor string will be converted using ToString(). | |
9 | |
7 var unionTypesTest = internals.unionTypesTest(); | 10 var unionTypesTest = internals.unionTypesTest(); |
11 | |
12 debug('Tests for attributes'); | |
13 shouldBeNull('unionTypesTest.doubleOrStringAttribute'); | |
bashi
2014/11/05 00:17:32
I noticed this is wrong. This attribute is non-nul
| |
14 unionTypesTest.doubleOrStringAttribute = 3.14; | |
15 shouldBe('unionTypesTest.doubleOrStringAttribute', '3.14'); | |
16 unionTypesTest.doubleOrStringAttribute = "foo"; | |
17 shouldBeEqualToString('unionTypesTest.doubleOrStringAttribute', 'foo'); | |
18 unionTypesTest.doubleOrStringAttribute = undefined; | |
19 shouldBeEqualToString('unionTypesTest.doubleOrStringAttribute', 'undefined') ; | |
haraken
2014/11/04 23:50:09
Nit: shouldBeUndefined
bashi
2014/11/05 00:17:32
The expected result is "undefined" (of type string
| |
20 unionTypesTest.doubleOrStringAttribute = null; | |
21 shouldBeEqualToString('unionTypesTest.doubleOrStringAttribute', 'null'); | |
haraken
2014/11/04 23:50:09
Nit: shouldBeNull
bashi
2014/11/05 00:17:33
Same as above.
| |
22 unionTypesTest.doubleOrStringAttribute = {}; | |
23 shouldBeEqualToString('unionTypesTest.doubleOrStringAttribute', '[object Obj ect]'); | |
24 unionTypesTest.doubleOrStringAttribute = []; | |
25 shouldBeEqualToString('unionTypesTest.doubleOrStringAttribute', ''); | |
26 debug(''); | |
27 | |
8 debug('Tests for method arguments'); | 28 debug('Tests for method arguments'); |
9 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(3.14)', 'double is p assed: 3.14'); | 29 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(3.14)', 'double is p assed: 3.14'); |
10 shouldBeEqualToString('unionTypesTest.doubleOrStringArg("foo")', 'string is passed: foo'); | 30 shouldBeEqualToString('unionTypesTest.doubleOrStringArg("foo")', 'string is passed: foo'); |
11 // The conversion rule prefers string over double, hence a value which | |
12 // is neither double nor string will be converted using ToString(). | |
13 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(undefined)', 'string is passed: undefined'); | 31 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(undefined)', 'string is passed: undefined'); |
14 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(null)', 'string is p assed: null'); | 32 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(null)', 'string is p assed: null'); |
15 shouldBeEqualToString('unionTypesTest.doubleOrStringArg({})', 'string is pas sed: [object Object]'); | 33 shouldBeEqualToString('unionTypesTest.doubleOrStringArg({})', 'string is pas sed: [object Object]'); |
16 shouldBeEqualToString('unionTypesTest.doubleOrStringArg([])', 'string is pas sed: '); | 34 shouldBeEqualToString('unionTypesTest.doubleOrStringArg([])', 'string is pas sed: '); |
17 // ToString(Date) can contain timezone, so we can't specify the expectation. | 35 // ToString(Date) can contain timezone, so we can't specify the expectation. |
18 // Just check that doubleOrStringArg() doesn't throw an exception. | 36 // Just check that doubleOrStringArg() doesn't throw an exception. |
19 shouldBeEqualToString('typeof unionTypesTest.doubleOrStringArg(new Date)', ' string'); | 37 shouldBeEqualToString('typeof unionTypesTest.doubleOrStringArg(new Date)', ' string'); |
20 shouldThrow('unionTypesTest.doubleOrStringArg()'); | 38 shouldThrow('unionTypesTest.doubleOrStringArg()'); |
21 } | 39 } |
22 </script> | 40 </script> |
OLD | NEW |