Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/keyorder.htm

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!-- Submitted from TestTWF Paris -->
3 <meta charset="utf-8">
4 <title>Key sort order</title>
5 <link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html# key-construct">
6 <link rel=assert title="For purposes of comparison, all Arrays are greater than all DOMString, Date and float values; all DOMString values are greater than all Date and float values; and all Date values are greater than all float values. Va lues of type float are compared to other float values numerically. Values of typ e Date are compared to other Date values chronologically. Values of type DOMStri ng are compared to other values of type DOMString by using the algorithm defined by step 4 of section 11.8.5, The Abstract Relational Comparison Algorithm, of t he ECMAScript Language Specification [ECMA-262]. Values of type Array are compar ed to other values of type Array as follows:
7
8 1. Let A be the first Array value and B be the second Array value.
9 2. Let length be the lesser of A's length and B's length.
10 3. Let i be 0.
11 4. If the ith value of A is less than the ith value of B, then A is less than B. Skip the remaining steps.
12 5. If the ith value of A is greater than the ith value of B, then A is greater t han B. Skip the remaining steps.
13 6. Increase i by 1.
14 7. If i is not equal to length, go back to step 4. Otherwise continue to next st ep.
15 8. If A's length is less than B's length, then A is less than B. If A's length i s greater than B's length, then A is greater than B. Otherwise A and B are equal .">
16 <script src="../../../resources/testharness.js"></script>
17 <script src="../../../resources/testharnessreport.js"></script>
18 <script src="support.js"></script>
19
20 <script>
21 var global_db = createdb_for_multiple_tests();
22
23 function keysort(desc, unsorted, expected) {
24 var db,
25 t = async_test("Database readback sort - " + desc, { timeout: 10000 }),
26 store_name = 'store-' + Date.now() + Math.random();
27
28 // The database test
29 var open_rq = global_db.setTest(t);
30 open_rq.onupgradeneeded = function(e) {
31 db = e.target.result;
32 var objStore = db.createObjectStore(store_name);
33
34 for (var i = 0; i < unsorted.length; i++)
35 objStore.add("value", unsorted[i]);
36 };
37
38 open_rq.onsuccess = function(e) {
39 var actual_keys = [],
40 rq = db.transaction(store_name)
41 .objectStore(store_name)
42 .openCursor();
43
44 rq.onsuccess = t.step_func(function(e) {
45 var cursor = e.target.result;
46
47 if (cursor) {
48 actual_keys.push(cursor.key.valueOf());
49 cursor.continue();
50 }
51 else {
52 assert_object_equals(actual_keys, expected, "keyorder array" );
53 assert_equals(actual_keys.length, expected.length, "array le ngth");
54
55 t.done();
56 }
57 });
58 };
59
60 // The IDBKey.cmp test
61 test(function () {
62 var sorted = unsorted.slice(0).sort(function(a, b) { return indexedD B.cmp(a, b)});
63
64 for (var i in sorted)
65 if (typeof sorted[i] === "object" && 'valueOf' in sorted[i])
66 sorted[i] = sorted[i].valueOf();
67
68 assert_object_equals(sorted, expected, "sorted array");
69
70 }, "IDBKey.cmp sorted - " + desc);
71 }
72
73 var now = new Date(),
74 one_sec_ago = new Date(now - 1000),
75 one_min_future = new Date(now.getTime() + (1000*60));
76
77 keysort('String < Array',
78 [ [0], "yo", "", [] ],
79 [ "", "yo", [], [0] ]);
80
81 keysort('float < String',
82 [ Infinity, "yo", 0, "", 100 ],
83 [ 0, 100, Infinity, "", "yo" ]);
84
85 keysort('float < Date',
86 [ now, 0, 9999999999999, -0.22 ],
87 [ -0.22, 0, 9999999999999, now.valueOf() ]);
88
89 keysort('float < Date < String < Array',
90 [ [], "", now, [0], "-1", 0, 9999999999999, ],
91 [ 0, 9999999999999, now.valueOf(), "", "-1", [], [0] ]);
92
93
94 keysort('Date(1 sec ago) < Date(now) < Date(1 minute in future)',
95 [ now, one_sec_ago, one_min_future ],
96 [ one_sec_ago.valueOf(), now.valueOf(), one_min_future.valueOf() ]);
97
98 keysort('-1.1 < 1 < 1.01337 < 1.013373 < 2',
99 [ 1.013373, 2, 1.01337, -1.1, 1 ],
100 [ -1.1, 1, 1.01337, 1.013373, 2 ]);
101
102 keysort('-Infinity < -0.01 < 0 < Infinity',
103 [ 0, -0.01, -Infinity, Infinity ],
104 [ -Infinity, -0.01, 0, Infinity ]);
105
106 keysort('"" < "a" < "ab" < "b" < "ba"',
107 [ "a", "ba", "", "b", "ab" ],
108 [ "", "a", "ab", "b", "ba" ]);
109
110 keysort('Arrays',
111 [ [[0]], [0], [], [0, 0], [0, [0]] ],
112 [ [], [0], [0, 0], [0, [0]], [[0]] ]);
113
114 var big_array = [], bigger_array = [];
115 for (var i=0; i < 10000; i++) {
116 big_array.push(i);
117 bigger_array.push(i);
118 }
119 bigger_array.push(0);
120
121 keysort('Array.length: 10,000 < Array.length: 10,001',
122 [ bigger_array, [0, 2, 3], [0], [9], big_array ],
123 [ [0], big_array, bigger_array, [0, 2, 3], [9] ]);
124
125 keysort('Infinity inside arrays',
126 [ [Infinity, 1], [Infinity, Infinity], [1, 1],
127 [1, Infinity], [1, -Infinity], [-Infinity, Infinity] ],
128 [ [-Infinity, Infinity], [1, -Infinity], [1, 1],
129 [1, Infinity], [Infinity, 1], [Infinity, Infinity] ]);
130
131
132 keysort('Test different stuff at once',
133 [
134 now,
135 [0, []],
136 "test",
137 1,
138 ["a", [1, [-1]]],
139 ["b", "a"],
140 [ 0, 2, "c"],
141 ["a", [1, 2]],
142 [],
143 [0, [], 3],
144 ["a", "b"],
145 [ 1, 2 ],
146 ["a", "b", "c"],
147 one_sec_ago,
148 [ 0, "b", "c"],
149 Infinity,
150 -Infinity,
151 2.55,
152 [ 0, now ],
153 [1]
154 ],
155 [
156 -Infinity,
157 1,
158 2.55,
159 Infinity,
160 one_sec_ago.valueOf(),
161 now.valueOf(),
162 "test",
163 [],
164 [0 ,2, "c"],
165 [0, now.valueOf()],
166 [0, "b", "c"],
167 [0, []],
168 [0, [], 3],
169 [1],
170 [1, 2],
171 ["a", "b"],
172 ["a", "b", "c"],
173 ["a", [1, 2]],
174 ["a", [1, [-1]]],
175 ["b", "a"]
176 ]);
177
178 </script>
179
180 <div id="log"></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698