(function() { function word2hex(w) { return "0x" + ((w|0)+0xF00000000000).toString(16).substr(4); } var b0 = sjcl.bitArray.partial(1, 0); var b1 = sjcl.bitArray.partial(1, 1); function concatbits(s) { var j, b, a = []; for (j = 0; j < s.length; ++j) { b = (s[j] == '1' ? b1 : b0); a = sjcl.bitArray.concat(a, [b]); } return a; } new sjcl.test.TestCase("bitArray single bits", function (cb) { if (!sjcl.bitArray) { this.unimplemented(); cb && cb(); return; } this.require((b0|0) === (0x00000000|0), "bitstring '0': " + word2hex(b0)); this.require((b1|0) === (0x80000000|0), "bitstring '1': " + word2hex(b1)); cb && cb(); }); new sjcl.test.TestCase("bitArray concat small bitstrings", function (cb) { if (!sjcl.bitArray) { this.unimplemented(); cb && cb(); return; } var i, kat = sjcl.test.vector.bitArray.bits, tv, a, b, bitlen, t; for (i=0; i>> (32 - tv[0].length)); // unsigned shift, convert to signed word this.require(b === (tv[1]|0), t + "array entry shifted is number: " + word2hex(b) + " == " + word2hex(tv[1])); } cb && cb(); }); new sjcl.test.TestCase("bitArray concat, slicing, shifting and clamping", function (cb) { if (!sjcl.bitArray) { this.unimplemented(); cb && cb(); return; } var i, j, kat = sjcl.test.vector.bitArray.slices, tv, a, a1, b, bitlen, t; for (i=0; i