1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-29 02:29:06 -05:00
denoland-deno/js/util_test.ts

27 lines
786 B
TypeScript
Raw Normal View History

// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEqual } from "./test_util.ts";
import { CreateIterableIterator } from "./util";
test(function CreateIterableIteratorSuccess() {
const list = [1, 2, 3, 4, 5];
const listIterators = new CreateIterableIterator(list.values());
let idx = 0;
for (const it of listIterators) {
assertEqual(it, list[idx++]);
}
const obj = {
a: "foo",
b: "bar",
c: "baz"
};
const list1 = [];
const keys = Object.keys(obj);
keys.forEach(key => list1.push([key, obj[key]]));
const objectIterators = new CreateIterableIterator(list1.values());
for (const it of objectIterators) {
const [key, value] = it;
assert(key in obj);
assertEqual(value, obj[key]);
}
2018-10-19 19:15:27 -04:00
});