Files
cell/tests/fit.cm
2025-12-05 23:21:07 -06:00

188 lines
6.6 KiB
Plaintext

var fit = use("fit");
return {
and_12_10: function() {
if (fit.and(12, 10) != 8) throw "fit.and(12, 10) expected 8";
},
and_16_2: function() {
if (fit.and(16, 2) != 0) throw "fit.and(16, 2) expected 0";
},
and_15_3: function() {
if (fit.and(15, 3) != 3) throw "fit.and(15, 3) expected 3";
},
and_13_3: function() {
if (fit.and(13, 3) != 1) throw "fit.and(13, 3) expected 1";
},
and_string_input: function() {
if (fit.and("10", 3) != null) throw "fit.and('10', 3) expected null";
},
or_12_10: function() {
if (fit.or(12, 10) != 14) throw "fit.or(12, 10) expected 14";
},
or_16_2: function() {
if (fit.or(16, 2) != 18) throw "fit.or(16, 2) expected 18";
},
or_15_3: function() {
if (fit.or(15, 3) != 15) throw "fit.or(15, 3) expected 15";
},
or_13_3: function() {
if (fit.or(13, 3) != 15) throw "fit.or(13, 3) expected 15";
},
xor_12_10: function() {
if (fit.xor(12, 10) != 6) throw "fit.xor(12, 10) expected 6";
},
xor_16_2: function() {
if (fit.xor(16, 2) != 18) throw "fit.xor(16, 2) expected 18";
},
xor_15_3: function() {
if (fit.xor(15, 3) != 12) throw "fit.xor(15, 3) expected 12";
},
xor_13_3: function() {
if (fit.xor(13, 3) != 14) throw "fit.xor(13, 3) expected 14";
},
xor_float_input: function() {
if (fit.xor(13.01, 3) != null) throw "fit.xor(13.01, 3) expected null";
},
left_12_10: function() {
if (fit.left(12, 10) != 12288) throw "fit.left(12, 10) expected 12288";
},
left_16_2: function() {
if (fit.left(16, 2) != 64) throw "fit.left(16, 2) expected 64";
},
left_15_53: function() {
if (fit.left(15, 53) != -9007199254740992) throw "fit.left(15, 53) expected -9007199254740992";
},
right_12_10: function() {
if (fit.right(12, 10) != 0) throw "fit.right(12, 10) expected 0";
},
right_19_2: function() {
if (fit.right(19, 2) != 4) throw "fit.right(19, 2) expected 4";
},
right_large: function() {
if (fit.right(-9007199254740992, 53) != 7) throw "fit.right(-9007199254740992, 53) expected 7";
},
right_signed: function() {
if (fit.right_signed(-2, 1) != -1) throw "fit.right_signed(-2, 1) expected -1";
},
mask_0: function() {
if (fit.mask(0) != 0) throw "fit.mask(0) expected 0";
},
mask_1: function() {
if (fit.mask(1) != 1) throw "fit.mask(1) expected 1";
},
mask_3: function() {
if (fit.mask(3) != 7) throw "fit.mask(3) expected 7";
},
mask_8: function() {
if (fit.mask(8) != 255) throw "fit.mask(8) expected 255";
},
mask_16: function() {
if (fit.mask(16) != 65535) throw "fit.mask(16) expected 65535";
},
mask_32: function() {
if (fit.mask(32) != 4294967295) throw "fit.mask(32) expected 4294967295";
},
mask_55: function() {
if (fit.mask(55) != 36028797018963967) throw "fit.mask(55) expected 36028797018963967";
},
mask_56: function() {
if (fit.mask(56) != -1) throw "fit.mask(56) expected -1";
},
mask_57: function() {
if (fit.mask(57) != null) throw "fit.mask(57) expected null";
},
mask_neg1: function() {
if (fit.mask(-1) != -2) throw "fit.mask(-1) expected -2";
},
mask_neg3: function() {
if (fit.mask(-3) != -8) throw "fit.mask(-3) expected -8";
},
mask_neg8: function() {
if (fit.mask(-8) != -256) throw "fit.mask(-8) expected -256";
},
mask_neg16: function() {
if (fit.mask(-16) != -65536) throw "fit.mask(-16) expected -65536";
},
mask_neg32: function() {
if (fit.mask(-32) != -4294967296) throw "fit.mask(-32) expected -4294967296";
},
mask_neg55: function() {
if (fit.mask(-55) != -36028797018963968) throw "fit.mask(-55) expected -36028797018963968";
},
mask_neg56: function() {
if (fit.mask(-56) != 0) throw "fit.mask(-56) expected 0";
},
not_0: function() {
if (fit.not(0) != -1) throw "fit.not(0) expected -1";
},
not_1: function() {
if (fit.not(1) != -2) throw "fit.not(1) expected -2";
},
not_neg1: function() {
if (fit.not(-1) != 0) throw "fit.not(-1) expected 0";
},
ones_neg1: function() {
if (fit.ones(-1) != 56) throw "fit.ones(-1) expected 56";
},
ones_0: function() {
if (fit.ones(0) != 0) throw "fit.ones(0) expected 0";
},
ones_8: function() {
if (fit.ones(8) != 1) throw "fit.ones(8) expected 1";
},
ones_18: function() {
if (fit.ones(18) != 2) throw "fit.ones(18) expected 2";
},
ones_255: function() {
if (fit.ones(255) != 8) throw "fit.ones(255) expected 8";
},
zeros_neg1: function() {
if (fit.zeros(-1) != 0) throw "fit.zeros(-1) expected 0";
},
zeros_0: function() {
if (fit.zeros(0) != 56) throw "fit.zeros(0) expected 56";
},
zeros_1: function() {
if (fit.zeros(1) != 55) throw "fit.zeros(1) expected 55";
},
zeros_2: function() {
if (fit.zeros(2) != 54) throw "fit.zeros(2) expected 54";
},
zeros_1024: function() {
if (fit.zeros(1024) != 45) throw "fit.zeros(1024) expected 45";
},
rotate_1_1: function() {
if (fit.rotate(1, 1) != 2) throw "fit.rotate(1, 1) expected 2";
},
rotate_neg2_1: function() {
if (fit.rotate(-2, 1) != -3) throw "fit.rotate(-2, 1) expected -3";
},
rotate_full: function() {
if (fit.rotate(1, 56) != 1) throw "fit.rotate(1, 56) expected 1";
},
rotate_right: function() {
if (fit.rotate(1, -1) != 1 << 55) throw "fit.rotate(1, -1) expected 1 << 55";
},
reverse_neg: function() {
if (fit.reverse(-36028797018963968) != 1) throw "fit.reverse(-36028797018963968) expected 1";
},
reverse_pi: function() {
if (fit.reverse(3141592653589793) != 2334719610726733) throw "fit.reverse(3141592653589793) expected 2334719610726733";
},
and_out_of_range: function() {
if (fit.and(1 << 56, 1) != null) throw "fit.and with out-of-range expected null";
},
left_negative_shift: function() {
if (fit.left(1, -1) != null) throw "fit.left with negative shift expected null";
},
left_large_shift: function() {
if (fit.left(1, 100) != null) throw "fit.left with large shift expected null";
},
right_negative_shift: function() {
if (fit.right(1, -1) != null) throw "fit.right with negative shift expected null";
},
mask_float: function() {
if (fit.mask(3.5) != null) throw "fit.mask with float expected null";
}
}