| OLD | NEW |
| 1 #library('IndexedDB1Test'); | 1 #library('IndexedDB1Test'); |
| 2 #import('../../pkg/unittest/unittest.dart'); | 2 #import('../../pkg/unittest/unittest.dart'); |
| 3 #import('../../pkg/unittest/html_config.dart'); | 3 #import('../../pkg/unittest/html_config.dart'); |
| 4 #import('dart:html'); | 4 #import('dart:html'); |
| 5 #import('dart:coreimpl'); | 5 #import('dart:coreimpl'); |
| 6 #import('utils.dart'); | 6 #import('utils.dart'); |
| 7 | 7 |
| 8 // Write and re-read Maps: simple Maps; Maps with DAGs; Maps with cycles. | 8 // Write and re-read Maps: simple Maps; Maps with DAGs; Maps with cycles. |
| 9 | 9 |
| 10 final String DB_NAME = 'Test'; | 10 final String DB_NAME = 'Test'; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 var request = window.indexedDB.open(dbName); | 71 var request = window.indexedDB.open(dbName); |
| 72 Expect.isNotNull(request); | 72 Expect.isNotNull(request); |
| 73 request.on.success.add(expectAsync1(initDb)); | 73 request.on.success.add(expectAsync1(initDb)); |
| 74 request.on.error.add(fail); | 74 request.on.error.add(fail); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 | 77 |
| 78 tests_dynamic() { | 78 main() { |
| 79 useHtmlConfiguration(); |
| 80 |
| 79 var obj1 = {'a': 100, 'b': 's'}; | 81 var obj1 = {'a': 100, 'b': 's'}; |
| 80 var obj2 = {'x': obj1, 'y': obj1}; // DAG. | 82 var obj2 = {'x': obj1, 'y': obj1}; // DAG. |
| 81 | 83 |
| 82 var obj3 = {}; | 84 var obj3 = {}; |
| 83 obj3['a'] = 100; | 85 obj3['a'] = 100; |
| 84 obj3['b'] = obj3; // Cycle. | 86 obj3['b'] = obj3; // Cycle. |
| 85 | 87 |
| 86 var obj4 = new SplayTreeMap<String, Dynamic>(); // Different implementation. | 88 var obj4 = new SplayTreeMap<String, Dynamic>(); // Different implementation. |
| 87 obj4['a'] = 100; | 89 obj4['a'] = 100; |
| 88 obj4['b'] = 's'; | 90 obj4['b'] = 's'; |
| 89 | 91 |
| 90 test('test_simple', testReadWrite(123, obj1, verifyGraph)); | 92 var cyclic_list = [1, 2, 3]; |
| 91 test('test_DAG', testReadWrite(123, obj2, verifyGraph)); | 93 cyclic_list[1] = cyclic_list; |
| 92 test('test_cycle', testReadWrite(123, obj3, verifyGraph)); | 94 |
| 93 test('test_simple_splay', testReadWrite(123, obj4, verifyGraph)); | 95 go(name, data) => test(name, testReadWrite(123, data, verifyGraph)); |
| 96 |
| 97 test('test_verifyGraph', () { |
| 98 // Nice to know verifyGraph is working before we rely on it. |
| 99 Expect.mapEquals(obj4, obj4); |
| 100 verifyGraph(obj4, obj4); |
| 101 verifyGraph(obj1, new Map.from(obj1)); |
| 102 verifyGraph(obj4, new Map.from(obj4)); |
| 103 |
| 104 var l1 = [1,2,3]; |
| 105 var l2 = [const [1, 2, 3], const [1, 2, 3]]; |
| 106 verifyGraph([l1, l1], l2); |
| 107 Expect.throws(() => verifyGraph([[1, 2, 3], [1, 2, 3]], l2)); |
| 108 |
| 109 verifyGraph(cyclic_list, cyclic_list); |
| 110 }); |
| 111 |
| 112 go('test_simple', obj1); |
| 113 go('test_DAG', obj2); |
| 114 go('test_cycle', obj3); |
| 115 go('test_simple_splay', obj4); |
| 116 go('const_array_1', const [const [1], const [2]]); |
| 117 go('const_array_dag', const [const [1], const [1]]); |
| 118 go('array_deferred_copy', [1,2,3, obj3, obj3, 6]); |
| 119 go('array_deferred_copy_2', [1,2,3, [4, 5, obj3], [obj3, 6]]); |
| 120 go('cyclic_list', cyclic_list); |
| 94 } | 121 } |
| 95 | |
| 96 main() { | |
| 97 useHtmlConfiguration(); | |
| 98 | |
| 99 tests_dynamic(); | |
| 100 } | |
| OLD | NEW |