This commit is contained in:
Thomas Denney 2016-08-09 16:11:27 +01:00
commit 99d05ec91b

View File

@ -23,18 +23,17 @@ namespace control {
* Display specified error code and stop the program. * Display specified error code and stop the program.
*/ */
//% shim=pxtrt::panic //% shim=pxtrt::panic
export function panic(code: number) { export function panic(code: number) { }
}
/** /**
* If the condition is false, display msg on serial console, and panic with code 098. * If the condition is false, display msg on serial console, and panic with code 098.
*/ */
export function assert(condition:boolean, msg?: string) export function assert(condition: boolean, msg ?: string) {
{
if (!condition) { if (!condition) {
console.log("ASSERTION FAILED") console.log("ASSERTION FAILED")
if (msg != null) if (msg != null) {
console.log(msg) console.log(msg)
}
panic(98) panic(98)
} }
} }