summaryrefslogtreecommitdiff
path: root/js/util_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/util_test.ts')
-rw-r--r--js/util_test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/js/util_test.ts b/js/util_test.ts
new file mode 100644
index 000000000..b7111fd0d
--- /dev/null
+++ b/js/util_test.ts
@@ -0,0 +1,26 @@
+// 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]);
+ }
+}); \ No newline at end of file