diff --git a/interpreter.ts b/interpreter.ts index a5417cd7..59b0eb09 100644 --- a/interpreter.ts +++ b/interpreter.ts @@ -82,17 +82,14 @@ module J2ME { * Debugging helper to make sure native methods were implemented correctly. */ function checkReturnValue(methodInfo: MethodInfo, returnValue: any) { - if (returnValue instanceof Promise) { - console.error("You forgot to call asyncImpl():", methodInfo.implKey); - } else if (methodInfo.getReturnKind() === Kind.Void && returnValue) { - console.error("You returned something in a void method:", methodInfo.implKey); - } else if (methodInfo.getReturnKind() !== Kind.Void && (returnValue === undefined) && - !U) { - console.error("You returned undefined in a non-void method:", methodInfo.implKey); - } else if (typeof returnValue === "string") { - console.error("You returned a non-wrapped string:", methodInfo.implKey); - } else if (returnValue === true || returnValue === false) { - console.error("You returned a JS boolean:", methodInfo.implKey); + if (U) { + if (typeof returnValue !== "undefined") { + assert(false, "Expected undefined return value during unwind, got " + returnValue); + } + return; + } + if (!(getKindCheck(methodInfo.getReturnKind())(returnValue))) { + assert(false, "Expected " + Kind[methodInfo.getReturnKind()] + " return value, got " + returnValue); } } diff --git a/libs/long.js b/libs/long.js index c019ea2e..f3a10438 100644 --- a/libs/long.js +++ b/libs/long.js @@ -659,4 +659,5 @@ exports.fromNumber = fromNumber; exports.fromBits = fromBits; exports.fromString = fromString; + exports.constructor = Long; })(typeof exports === "undefined" ? this.Long = {} : exports); diff --git a/types.ts b/types.ts index a7ac8a53..f0712a0c 100644 --- a/types.ts +++ b/types.ts @@ -102,11 +102,11 @@ module J2ME { case Kind.Int: return (x) => (x | 0) === x; case Kind.Float: - return (x) => Math.fround(x) === x; + return (x) => isNaN(x) || Math.fround(x) === x; case Kind.Long: - return (x) => x instanceof Long; + return (x) => x instanceof Long.constructor; case Kind.Double: - return (x) => (+x) === x; + return (x) => isNaN(x) || (+x) === x; case Kind.Reference: return (x) => x === null || x instanceof Object; case Kind.Void: