(s1, s2, array, signed_func, unsigned_func)
| 179 | const module = builder.instantiate(); |
| 180 | |
| 181 | function test_vector_add(s1, s2, array, signed_func, unsigned_func) { |
| 182 | for (let i = 0; i < array.length-2; i++) { |
| 183 | let a = BigInt(array[i]); |
| 184 | let b = BigInt(array[i+2]); |
| 185 | let ua = BigInt.asUintN(s1, a); |
| 186 | let ub = BigInt.asUintN(s1, b); |
| 187 | let sa = BigInt.asIntN(s1, a); |
| 188 | let sb = BigInt.asIntN(s1, b); |
| 189 | assertEquals( |
| 190 | BigInt.asUintN(s2, ua + ub), |
| 191 | BigInt.asUintN(s2, BigInt(unsigned_func( |
| 192 | s1>32 ? ua : Number(ua), |
| 193 | s1>32 ? ub : Number(ub) |
| 194 | ))) |
| 195 | ); |
| 196 | assertEquals( |
| 197 | BigInt.asIntN(s2, sa + sb), |
| 198 | BigInt.asIntN(s2, BigInt(signed_func( |
| 199 | s1>32 ? sa : Number(sa), |
| 200 | s1>32 ? sb : Number(sb) |
| 201 | ))) |
| 202 | ); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // 2D |
| 207 | test_vector_add(32, 64, uint64_array, module.exports.main_vector_2D_L_S, module.exports.main_vector_2D_L_U); |
no test coverage detected