|
1 | 1 | import { |
| 2 | + none, |
2 | 3 | isFinalValue, |
3 | 4 | finalValue, |
4 | 5 | getFinalValue, |
5 | | - |
6 | 6 | isMany, |
7 | 7 | many, |
8 | 8 | getManyValues, |
9 | | - |
10 | 9 | isFlushable, |
11 | 10 | flushable, |
12 | | - |
13 | 11 | isFunctionList, |
14 | 12 | getFunctionList, |
15 | 13 | setFunctionList, |
16 | | - clearFunctionList |
| 14 | + clearFunctionList, |
| 15 | + toMany, |
| 16 | + normalizeMany, |
| 17 | + combineMany, |
| 18 | + combineManyMut |
17 | 19 | } from 'stream-chain/defs.js'; |
18 | 20 |
|
19 | 21 | { |
@@ -94,3 +96,77 @@ import { |
94 | 96 |
|
95 | 97 | void w; |
96 | 98 | } |
| 99 | + |
| 100 | +{ |
| 101 | + const x1 = toMany(none), |
| 102 | + t1 = getManyValues(x1); |
| 103 | + console.assert(t1.length === 0); |
| 104 | + |
| 105 | + const x2 = toMany(1), |
| 106 | + t2 = getManyValues(x2); |
| 107 | + console.assert(t2.length === 1); |
| 108 | + |
| 109 | + const x3 = toMany(many([1, 2, 3])), |
| 110 | + t3 = getManyValues(x3); |
| 111 | + console.assert(t3.length === 3); |
| 112 | +} |
| 113 | + |
| 114 | +{ |
| 115 | + const x1 = normalizeMany(many([])); |
| 116 | + console.assert(x1 === none); |
| 117 | + |
| 118 | + const x2 = normalizeMany(many([1])); |
| 119 | + console.assert(x2 === 1); |
| 120 | + |
| 121 | + const x3 = normalizeMany(many([1, 2, 3])); |
| 122 | + if (isMany(x3)) { |
| 123 | + console.assert(getManyValues(x3).length === 3); |
| 124 | + } |
| 125 | + console.assert(isMany(x3)); |
| 126 | +} |
| 127 | + |
| 128 | +{ |
| 129 | + const x1 = combineMany(none, none); |
| 130 | + console.assert(getManyValues(x1).length === 0); |
| 131 | + |
| 132 | + const x2 = combineMany(none, many([1, 2, 3])); |
| 133 | + console.assert(getManyValues(x2).length === 3); |
| 134 | + |
| 135 | + const x3 = combineMany(many([1, 2, 3]), none); |
| 136 | + console.assert(getManyValues(x3).length === 3); |
| 137 | + |
| 138 | + const x4 = combineMany(many([1, 2, 3]), many([4, 5, 6])); |
| 139 | + console.assert(getManyValues(x4).length === 6); |
| 140 | + |
| 141 | + const x5 = combineMany(0, many([1, 2, 3])); |
| 142 | + console.assert(getManyValues(x5).length === 4); |
| 143 | + |
| 144 | + const x6 = combineMany(many([1, 2, 3]), 4); |
| 145 | + console.assert(getManyValues(x6).length === 4); |
| 146 | + |
| 147 | + const x7 = combineMany(1, 2); |
| 148 | + console.assert(getManyValues(x7).length === 2); |
| 149 | +} |
| 150 | + |
| 151 | +{ |
| 152 | + const x1 = combineManyMut(none, none); |
| 153 | + console.assert(getManyValues(x1).length === 0); |
| 154 | + |
| 155 | + const x2 = combineManyMut(none, many([1, 2, 3])); |
| 156 | + console.assert(getManyValues(x2).length === 3); |
| 157 | + |
| 158 | + const x3 = combineManyMut(many([1, 2, 3]), none); |
| 159 | + console.assert(getManyValues(x3).length === 3); |
| 160 | + |
| 161 | + const x4 = combineManyMut(many([1, 2, 3]), many([4, 5, 6])); |
| 162 | + console.assert(getManyValues(x4).length === 6); |
| 163 | + |
| 164 | + const x5 = combineManyMut(0, many([1, 2, 3])); |
| 165 | + console.assert(getManyValues(x5).length === 4); |
| 166 | + |
| 167 | + const x6 = combineManyMut(many([1, 2, 3]), 4); |
| 168 | + console.assert(getManyValues(x6).length === 4); |
| 169 | + |
| 170 | + const x7 = combineManyMut(1, 2); |
| 171 | + console.assert(getManyValues(x7).length === 2); |
| 172 | +} |
0 commit comments