Debian Codegraph @

js/src/jit-test/lib/iteration.js

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
6 load(libdir + "asserts.js");
7
8 if (typeof assertIteratorResult === 'undefined') {
9 var assertIteratorResult = function assertIteratorResult(result, value, done) {
10 assertEq(typeof result, "object");
11 var expectedProps = ['done', 'value'];
12 var actualProps = Object.getOwnPropertyNames(result);
13 actualProps.sort(), expectedProps.sort();
14 assertDeepEq(actualProps, expectedProps);
15 assertDeepEq(result.value, value);
16 assertDeepEq(result.done, done);
17 }
18 }
19
20 if (typeof assertIteratorNext === 'undefined') {
21 var assertIteratorNext = function assertIteratorNext(iter, value) {
22 assertIteratorResult(iter.next(), value, false);
23 }
24 }
25
26 if (typeof assertIteratorDone === 'undefined') {
27 var assertIteratorDone = function assertIteratorDone(iter, value) {
28 assertIteratorResult(iter.next(), value, true);
29 }
30 }