|
| 1 | +import { test } from "@cross/test"; |
1 | 2 | import { assertEquals } from "@std/assert"; |
2 | 3 | import { assertType, type IsExact } from "@std/testing/types"; |
3 | 4 | import { pipe } from "./mod.ts"; |
4 | 5 |
|
5 | | -Deno.test("pipe", async (t) => { |
6 | | - await t.step("with no operators", async (t) => { |
7 | | - await t.step("should return the input", () => { |
8 | | - assertEquals(pipe(1), 1); |
9 | | - }); |
10 | | - }); |
| 6 | +await test("pipe with no operators should return the input", () => { |
| 7 | + assertEquals(pipe(1), 1); |
| 8 | +}); |
11 | 9 |
|
12 | | - await t.step("with one operator", async (t) => { |
13 | | - await t.step("should return operator applied value", () => { |
14 | | - assertEquals(pipe(1, (v) => v * 2), 2); |
15 | | - }); |
| 10 | +await test("pipe with one operator should return operator applied value", () => { |
| 11 | + assertEquals(pipe(1, (v) => v * 2), 2); |
| 12 | +}); |
16 | 13 |
|
17 | | - await t.step("should resolve the type properly", () => { |
18 | | - pipe(1, (v) => { |
19 | | - assertType<IsExact<typeof v, number>>(true); |
20 | | - return v.toString(); |
21 | | - }); |
22 | | - }); |
| 14 | +await test("pipe with one operator should resolve the type properly", () => { |
| 15 | + pipe(1, (v) => { |
| 16 | + assertType<IsExact<typeof v, number>>(true); |
| 17 | + return v.toString(); |
23 | 18 | }); |
| 19 | +}); |
24 | 20 |
|
25 | | - await t.step("with two operators", async (t) => { |
26 | | - await t.step("should return operator applied value", () => { |
27 | | - assertEquals(pipe(1, (v) => v * 2, (v) => v * 2), 4); |
28 | | - }); |
| 21 | +await test("pipe with two operators should return operator applied value", () => { |
| 22 | + assertEquals(pipe(1, (v) => v * 2, (v) => v * 2), 4); |
| 23 | +}); |
29 | 24 |
|
30 | | - await t.step("should resolve the type properly", () => { |
31 | | - pipe(1, (v) => { |
32 | | - assertType<IsExact<typeof v, number>>(true); |
33 | | - return v.toString(); |
34 | | - }, (v) => { |
35 | | - assertType<IsExact<typeof v, string>>(true); |
36 | | - return v.length; |
37 | | - }); |
38 | | - }); |
| 25 | +await test("pipe with two operators should resolve the type properly", () => { |
| 26 | + pipe(1, (v) => { |
| 27 | + assertType<IsExact<typeof v, number>>(true); |
| 28 | + return v.toString(); |
| 29 | + }, (v) => { |
| 30 | + assertType<IsExact<typeof v, string>>(true); |
| 31 | + return v.length; |
39 | 32 | }); |
| 33 | +}); |
40 | 34 |
|
41 | | - await t.step("with three operators", async (t) => { |
42 | | - await t.step("should return operator applied value", () => { |
43 | | - assertEquals(pipe(1, (v) => v * 2, (v) => v * 2, (v) => v * 2), 8); |
44 | | - }); |
| 35 | +await test("pipe with three operators should return operator applied value", () => { |
| 36 | + assertEquals(pipe(1, (v) => v * 2, (v) => v * 2, (v) => v * 2), 8); |
| 37 | +}); |
45 | 38 |
|
46 | | - await t.step("should resolve the type properly", () => { |
47 | | - pipe(1, (v) => { |
48 | | - assertType<IsExact<typeof v, number>>(true); |
49 | | - return v.toString(); |
50 | | - }, (v) => { |
51 | | - assertType<IsExact<typeof v, string>>(true); |
52 | | - return v.length; |
53 | | - }, (v) => { |
54 | | - assertType<IsExact<typeof v, number>>(true); |
55 | | - return v.toString(); |
56 | | - }); |
57 | | - }); |
| 39 | +await test("pipe with three operators should resolve the type properly", () => { |
| 40 | + pipe(1, (v) => { |
| 41 | + assertType<IsExact<typeof v, number>>(true); |
| 42 | + return v.toString(); |
| 43 | + }, (v) => { |
| 44 | + assertType<IsExact<typeof v, string>>(true); |
| 45 | + return v.length; |
| 46 | + }, (v) => { |
| 47 | + assertType<IsExact<typeof v, number>>(true); |
| 48 | + return v.toString(); |
58 | 49 | }); |
| 50 | +}); |
59 | 51 |
|
60 | | - await t.step(`with twenty operators`, async (t) => { |
61 | | - await t.step("should return operator applied value", () => { |
62 | | - assertEquals(pipe(1, ...Array(20).fill((v: number) => v * 2)), 2 ** 20); |
63 | | - }); |
| 52 | +await test("pipe with twenty operators should return operator applied value", () => { |
| 53 | + assertEquals(pipe(1, ...Array(20).fill((v: number) => v * 2)), 2 ** 20); |
| 54 | +}); |
64 | 55 |
|
65 | | - await t.step("should resolve the type properly", () => { |
66 | | - pipe( |
67 | | - 1, |
68 | | - (v) => { |
69 | | - assertType<IsExact<typeof v, number>>(true); |
70 | | - return v; |
71 | | - }, |
72 | | - (v) => { |
73 | | - assertType<IsExact<typeof v, number>>(true); |
74 | | - return v; |
75 | | - }, |
76 | | - (v) => { |
77 | | - assertType<IsExact<typeof v, number>>(true); |
78 | | - return v; |
79 | | - }, |
80 | | - (v) => { |
81 | | - assertType<IsExact<typeof v, number>>(true); |
82 | | - return v; |
83 | | - }, |
84 | | - (v) => { |
85 | | - assertType<IsExact<typeof v, number>>(true); |
86 | | - return v; |
87 | | - }, |
88 | | - (v) => { |
89 | | - assertType<IsExact<typeof v, number>>(true); |
90 | | - return v; |
91 | | - }, |
92 | | - (v) => { |
93 | | - assertType<IsExact<typeof v, number>>(true); |
94 | | - return v; |
95 | | - }, |
96 | | - (v) => { |
97 | | - assertType<IsExact<typeof v, number>>(true); |
98 | | - return v; |
99 | | - }, |
100 | | - (v) => { |
101 | | - assertType<IsExact<typeof v, number>>(true); |
102 | | - return v; |
103 | | - }, |
104 | | - (v) => { |
105 | | - assertType<IsExact<typeof v, number>>(true); |
106 | | - return v; |
107 | | - }, |
108 | | - (v) => { |
109 | | - assertType<IsExact<typeof v, number>>(true); |
110 | | - return v; |
111 | | - }, |
112 | | - (v) => { |
113 | | - assertType<IsExact<typeof v, number>>(true); |
114 | | - return v; |
115 | | - }, |
116 | | - (v) => { |
117 | | - assertType<IsExact<typeof v, number>>(true); |
118 | | - return v; |
119 | | - }, |
120 | | - (v) => { |
121 | | - assertType<IsExact<typeof v, number>>(true); |
122 | | - return v; |
123 | | - }, |
124 | | - (v) => { |
125 | | - assertType<IsExact<typeof v, number>>(true); |
126 | | - return v; |
127 | | - }, |
128 | | - (v) => { |
129 | | - assertType<IsExact<typeof v, number>>(true); |
130 | | - return v; |
131 | | - }, |
132 | | - (v) => { |
133 | | - assertType<IsExact<typeof v, number>>(true); |
134 | | - return v; |
135 | | - }, |
136 | | - (v) => { |
137 | | - assertType<IsExact<typeof v, number>>(true); |
138 | | - return v; |
139 | | - }, |
140 | | - (v) => { |
141 | | - assertType<IsExact<typeof v, number>>(true); |
142 | | - return v; |
143 | | - }, |
144 | | - (v) => { |
145 | | - assertType<IsExact<typeof v, number>>(true); |
146 | | - return v; |
147 | | - }, |
148 | | - ); |
149 | | - }); |
150 | | - }); |
| 56 | +await test("pipe with twenty operators should resolve the type properly", () => { |
| 57 | + pipe( |
| 58 | + 1, |
| 59 | + (v) => { |
| 60 | + assertType<IsExact<typeof v, number>>(true); |
| 61 | + return v; |
| 62 | + }, |
| 63 | + (v) => { |
| 64 | + assertType<IsExact<typeof v, number>>(true); |
| 65 | + return v; |
| 66 | + }, |
| 67 | + (v) => { |
| 68 | + assertType<IsExact<typeof v, number>>(true); |
| 69 | + return v; |
| 70 | + }, |
| 71 | + (v) => { |
| 72 | + assertType<IsExact<typeof v, number>>(true); |
| 73 | + return v; |
| 74 | + }, |
| 75 | + (v) => { |
| 76 | + assertType<IsExact<typeof v, number>>(true); |
| 77 | + return v; |
| 78 | + }, |
| 79 | + (v) => { |
| 80 | + assertType<IsExact<typeof v, number>>(true); |
| 81 | + return v; |
| 82 | + }, |
| 83 | + (v) => { |
| 84 | + assertType<IsExact<typeof v, number>>(true); |
| 85 | + return v; |
| 86 | + }, |
| 87 | + (v) => { |
| 88 | + assertType<IsExact<typeof v, number>>(true); |
| 89 | + return v; |
| 90 | + }, |
| 91 | + (v) => { |
| 92 | + assertType<IsExact<typeof v, number>>(true); |
| 93 | + return v; |
| 94 | + }, |
| 95 | + (v) => { |
| 96 | + assertType<IsExact<typeof v, number>>(true); |
| 97 | + return v; |
| 98 | + }, |
| 99 | + (v) => { |
| 100 | + assertType<IsExact<typeof v, number>>(true); |
| 101 | + return v; |
| 102 | + }, |
| 103 | + (v) => { |
| 104 | + assertType<IsExact<typeof v, number>>(true); |
| 105 | + return v; |
| 106 | + }, |
| 107 | + (v) => { |
| 108 | + assertType<IsExact<typeof v, number>>(true); |
| 109 | + return v; |
| 110 | + }, |
| 111 | + (v) => { |
| 112 | + assertType<IsExact<typeof v, number>>(true); |
| 113 | + return v; |
| 114 | + }, |
| 115 | + (v) => { |
| 116 | + assertType<IsExact<typeof v, number>>(true); |
| 117 | + return v; |
| 118 | + }, |
| 119 | + (v) => { |
| 120 | + assertType<IsExact<typeof v, number>>(true); |
| 121 | + return v; |
| 122 | + }, |
| 123 | + (v) => { |
| 124 | + assertType<IsExact<typeof v, number>>(true); |
| 125 | + return v; |
| 126 | + }, |
| 127 | + (v) => { |
| 128 | + assertType<IsExact<typeof v, number>>(true); |
| 129 | + return v; |
| 130 | + }, |
| 131 | + (v) => { |
| 132 | + assertType<IsExact<typeof v, number>>(true); |
| 133 | + return v; |
| 134 | + }, |
| 135 | + (v) => { |
| 136 | + assertType<IsExact<typeof v, number>>(true); |
| 137 | + return v; |
| 138 | + }, |
| 139 | + ); |
151 | 140 | }); |
0 commit comments