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 | 7 // The conversion rule prefers string over double, hence a value which |
8 // is neither double nor string will be converted using ToString(). | 8 // is neither double nor string will be converted using ToString(). |
9 | 9 |
10 var unionTypesTest = internals.unionTypesTest(); | 10 var unionTypesTest = internals.unionTypesTest(); |
(...skipping 18 matching lines...) Expand all Loading... |
29 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(3.14)', 'double is p
assed: 3.14'); | 29 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(3.14)', 'double is p
assed: 3.14'); |
30 shouldBeEqualToString('unionTypesTest.doubleOrStringArg("foo")', 'string is
passed: foo'); | 30 shouldBeEqualToString('unionTypesTest.doubleOrStringArg("foo")', 'string is
passed: foo'); |
31 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(undefined)', 'string
is passed: undefined'); | 31 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(undefined)', 'string
is passed: undefined'); |
32 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(null)', 'string is p
assed: null'); | 32 shouldBeEqualToString('unionTypesTest.doubleOrStringArg(null)', 'string is p
assed: null'); |
33 shouldBeEqualToString('unionTypesTest.doubleOrStringArg({})', 'string is pas
sed: [object Object]'); | 33 shouldBeEqualToString('unionTypesTest.doubleOrStringArg({})', 'string is pas
sed: [object Object]'); |
34 shouldBeEqualToString('unionTypesTest.doubleOrStringArg([])', 'string is pas
sed: '); | 34 shouldBeEqualToString('unionTypesTest.doubleOrStringArg([])', 'string is pas
sed: '); |
35 // 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. |
36 // Just check that doubleOrStringArg() doesn't throw an exception. | 36 // Just check that doubleOrStringArg() doesn't throw an exception. |
37 shouldBeEqualToString('typeof unionTypesTest.doubleOrStringArg(new Date)', '
string'); | 37 shouldBeEqualToString('typeof unionTypesTest.doubleOrStringArg(new Date)', '
string'); |
38 shouldThrow('unionTypesTest.doubleOrStringArg()'); | 38 shouldThrow('unionTypesTest.doubleOrStringArg()'); |
| 39 debug(''); |
| 40 |
| 41 debug('Tests for method arguments with defaults'); |
| 42 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultDoubleArg()', 'do
uble is passed: 3.14'); |
| 43 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultDoubleArg(undefin
ed)', 'double is passed: 3.14'); |
| 44 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultDoubleArg("foo")'
, 'string is passed: foo'); |
| 45 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultStringArg()', 'st
ring is passed: foo'); |
| 46 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultStringArg(undefin
ed)', 'string is passed: foo'); |
| 47 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultStringArg(3.14)',
'double is passed: 3.14'); |
| 48 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultNullArg()', 'null
is passed'); |
| 49 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultNullArg(undefined
)', 'null is passed'); |
| 50 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultNullArg(null)', '
null is passed'); |
| 51 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultNullArg(3.14)', '
double is passed: 3.14'); |
| 52 shouldBeEqualToString('unionTypesTest.doubleOrStringDefaultNullArg("foo")',
'string is passed: foo'); |
| 53 |
39 } | 54 } |
40 </script> | 55 </script> |
OLD | NEW |