Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case "f32": {
const actuali32 = actual.value.reinterpret();
const expectedi32 = Long.fromString(expected.value).toInt();
assert(
actuali32.toNumber() === expectedi32,
`Expected value ${expectedi32}, got ${actuali32.toString()}`
);
break;
}
case "f64": {
const actuali32 = actual.value.reinterpret();
const expectedi32 = Long.fromString(expected.value).toNumber();
assert(
actuali32.toNumber() === expectedi32,
`Expected value ${expectedi32}, got ${actuali32.toString()}`
);
break;
}
case "i64": {
console.warn("eq with i64 is unsupported");
// const actuali64 = actual.value.toString();
// const expectedi64 = Long.fromString(expected.value)
// .toSigned()
// .toString();
function eq(actual: StackLocal, expected: Object) {
// check type
assert(
actual.type === expected.type,
`type mismatch; expected ${expected.type}, given ${actual.type}`
);
// check value
switch (expected.type) {
case "i32": {
const i32Value = Long.fromString(expected.value).toInt();
assert(
actual.value.toString() === i32Value.toString(),
`Expected value ${i32Value}, got ${actual.value.toString()}`
);
break;
}
case "f32": {
const actuali32 = actual.value.reinterpret();
const expectedi32 = Long.fromString(expected.value).toInt();
assert(
actuali32.toNumber() === expectedi32,
`Expected value ${expectedi32}, got ${actuali32.toString()}`
);
const compatibleArgs = args.map(x => {
if (x.type === "i64") {
return new Long.fromString(x.value);
}
return x.value;
});
export function parse64I(sourceString) {
var long;
if (isHexLiteral(sourceString)) {
long = Long.fromString(sourceString, false, 16);
} else if (isDecimalExponentLiteral(sourceString)) {
throw new Error("This number literal format is yet to be implemented.");
} else {
long = Long.fromString(sourceString);
}
return {
high: long.high,
low: long.low
};
}
var NAN_WORD = /^\+?-?nan/;
export function parse64I(sourceString) {
var long;
if (isHexLiteral(sourceString)) {
long = Long.fromString(sourceString, false, 16);
} else if (isDecimalExponentLiteral(sourceString)) {
throw new Error("This number literal format is yet to be implemented.");
} else {
long = Long.fromString(sourceString);
}
return {
high: long.high,
low: long.low
};
}
var NAN_WORD = /^\+?-?nan/;