1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/lib/iteration.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 + 1.9 +load(libdir + "asserts.js"); 1.10 + 1.11 +// FIXME: Import from std::iteration. 1.12 +const std_iterator = '@@iterator'; 1.13 + 1.14 +if (typeof assertIteratorResult === 'undefined') { 1.15 + var assertIteratorResult = function assertIteratorResult(result, value, done) { 1.16 + assertEq(typeof result, "object"); 1.17 + var expectedProps = ['done', 'value']; 1.18 + var actualProps = Object.getOwnPropertyNames(result); 1.19 + actualProps.sort(), expectedProps.sort(); 1.20 + assertDeepEq(actualProps, expectedProps); 1.21 + assertDeepEq(result.value, value); 1.22 + assertDeepEq(result.done, done); 1.23 + } 1.24 +} 1.25 + 1.26 +if (typeof assertIteratorNext === 'undefined') { 1.27 + var assertIteratorNext = function assertIteratorNext(iter, value) { 1.28 + assertIteratorResult(iter.next(), value, false); 1.29 + } 1.30 +} 1.31 + 1.32 +if (typeof assertIteratorDone === 'undefined') { 1.33 + var assertIteratorDone = function assertIteratorDone(iter, value) { 1.34 + assertIteratorResult(iter.next(), value, true); 1.35 + } 1.36 +}