michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: load(libdir + "asserts.js"); michael@0: michael@0: // FIXME: Import from std::iteration. michael@0: const std_iterator = '@@iterator'; michael@0: michael@0: if (typeof assertIteratorResult === 'undefined') { michael@0: var assertIteratorResult = function assertIteratorResult(result, value, done) { michael@0: assertEq(typeof result, "object"); michael@0: var expectedProps = ['done', 'value']; michael@0: var actualProps = Object.getOwnPropertyNames(result); michael@0: actualProps.sort(), expectedProps.sort(); michael@0: assertDeepEq(actualProps, expectedProps); michael@0: assertDeepEq(result.value, value); michael@0: assertDeepEq(result.done, done); michael@0: } michael@0: } michael@0: michael@0: if (typeof assertIteratorNext === 'undefined') { michael@0: var assertIteratorNext = function assertIteratorNext(iter, value) { michael@0: assertIteratorResult(iter.next(), value, false); michael@0: } michael@0: } michael@0: michael@0: if (typeof assertIteratorDone === 'undefined') { michael@0: var assertIteratorDone = function assertIteratorDone(iter, value) { michael@0: assertIteratorResult(iter.next(), value, true); michael@0: } michael@0: }