| OLD | NEW |
| 1 library SerializedScriptValueTest; | 1 library SerializedScriptValueTest; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 import 'utils.dart'; | 5 import 'utils.dart'; |
| 6 | 6 |
| 7 serializationTest(name, value) => test(name, () { | 7 serializationTest(name, value) => test(name, () { |
| 8 // To check how value is serialized and deserialized, we create a MessageE
vent. | 8 // To check how value is serialized and deserialized, we create a MessageE
vent. |
| 9 final event = document.$dom_createEvent('MessageEvent'); | 9 final event = new MessageEvent('', data:value); |
| 10 event.initMessageEvent('', false, false, value, '', '', window, []); | |
| 11 verifyGraph(value, event.data); | 10 verifyGraph(value, event.data); |
| 12 }); | 11 }); |
| 13 | 12 |
| 14 | 13 |
| 15 main() { | 14 main() { |
| 16 useHtmlConfiguration(); | 15 useHtmlConfiguration(); |
| 17 | 16 |
| 18 serializationTest('null', null); | 17 serializationTest('null', null); |
| 19 serializationTest('int', 1); | 18 serializationTest('int', 1); |
| 20 serializationTest('double', 2.39); | 19 serializationTest('double', 2.39); |
| 21 serializationTest('string', 'hey!'); | 20 serializationTest('string', 'hey!'); |
| 22 | 21 |
| 23 final simpleMap = {'a': 100, 'b': 's'}; | 22 final simpleMap = {'a': 100, 'b': 's'}; |
| 24 final dagMap = { 'x': simpleMap, 'y': simpleMap }; | 23 final dagMap = { 'x': simpleMap, 'y': simpleMap }; |
| 25 final cyclicMap = { 'b': dagMap }; | 24 final cyclicMap = { 'b': dagMap }; |
| 26 cyclicMap['a'] = cyclicMap; | 25 cyclicMap['a'] = cyclicMap; |
| 27 serializationTest('simple map', simpleMap); | 26 serializationTest('simple map', simpleMap); |
| 28 serializationTest('dag map', dagMap); | 27 serializationTest('dag map', dagMap); |
| 29 serializationTest('cyclic map', cyclicMap); | 28 serializationTest('cyclic map', cyclicMap); |
| 30 | 29 |
| 31 final simpleList = [ 100, 's']; | 30 final simpleList = [ 100, 's']; |
| 32 final dagList = [ simpleList, simpleList ]; | 31 final dagList = [ simpleList, simpleList ]; |
| 33 final cyclicList = [ dagList ]; | 32 final cyclicList = [ dagList ]; |
| 34 cyclicList.add(cyclicList); | 33 cyclicList.add(cyclicList); |
| 35 serializationTest('simple list', simpleList); | 34 serializationTest('simple list', simpleList); |
| 36 serializationTest('dag list', dagList); | 35 serializationTest('dag list', dagList); |
| 37 serializationTest('cyclic list', cyclicList); | 36 serializationTest('cyclic list', cyclicList); |
| 38 } | 37 } |
| OLD | NEW |