deno.land / std@0.224.0 / collections / unzip_test.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../assert/mod.ts";import { unzip } from "./unzip.ts";
function unzipTest<T, U>( input: [Array<[T, U]>], expected: [Array<T>, Array<U>], message?: string,) { const actual = unzip(...input); assertEquals(actual, expected, message);}
Deno.test({ name: "unzip() handles no mutation", fn() { const zipped: Array<[number, boolean]> = [ [1, true], [2, false], [3, true], ]; unzip(zipped);
assertEquals(zipped, [ [1, true], [2, false], [3, true], ]); },});
Deno.test({ name: "unzip() handles empty input", fn() { unzipTest( [[]], [[], []], ); },});
Deno.test({ name: "unzip() handles unzips", fn() { unzipTest( [ [ [1, "foo"], [4, "bar"], [5, "lorem"], ], ], [ [1, 4, 5], ["foo", "bar", "lorem"], ], ); unzipTest( [ [ [true, false], ], ], [ [true], [false], ], ); unzipTest( [ [ [undefined, "foo"], [5, null], [undefined, "asdf"], [null, false], [1.2, ""], ], ], [ [undefined, 5, undefined, null, 1.2], ["foo", null, "asdf", false, ""], ], ); },});
Version Info