/*JSON{ "type" : "function", "name" : "trace", "ifndef" : "SAVE_ON_FLASH", "generate" : "jswrap_interface_trace", "params" : [ ["root","JsVar","The symbol to output (optional). If nothing is specified, everything will be output"] ] } Output debugging information */ void jswrap_interface_trace(JsVar *root) { if (jsvIsUndefined(root)) { jsvTrace(execInfo.root, 0); } else { jsvTrace(root, 0); } }
/*JSON{ "type":"function", "name" : "trace", "ifndef" : "SAVE_ON_FLASH", "description" : "Output debugging information", "generate" : "jswrap_interface_trace", "params" : [ [ "root", "JsVarName", "The symbol to output (optional). If nothing is specified, everything will be output"] ] }*/ void jswrap_interface_trace(JsVar *root) { if (jsvIsUndefined(root)) { jsvTrace(jsvGetRef(jsiGetParser()->root), 0); } else { jsvTrace(jsvGetRef(root), 0); } }
/*JSON{ "type" : "function", "name" : "trace", "ifndef" : "SAVE_ON_FLASH", "generate" : "jswrap_interface_trace", "params" : [ ["root","JsVar","The symbol to output (optional). If nothing is specified, everything will be output"] ] } Output debugging information Note: This is not included on boards with low amounts of flash memory, or the Espruino board. */ void jswrap_interface_trace(JsVar *root) { #ifdef ESPRUINOBOARD // leave this function out on espruino board - we need to save as much flash as possible jsiConsolePrintf("Trace not included on this board"); #else if (jsvIsUndefined(root)) { jsvTrace(execInfo.root, 0); } else { jsvTrace(root, 0); } #endif }
bool run_test(const char *filename) { printf("----------------------------------\r\n"); printf("----------------------------- TEST %s \r\n", filename); char *buffer = read_file(filename); if (!buffer) exit(1); jshInit(); jsvInit(); jsiInit(false /* do not autoload!!! */); addNativeFunction("quit", nativeQuit); addNativeFunction("interrupt", nativeInterrupt); jsvUnLock(jspEvaluate(buffer, true)); isRunning = true; bool isBusy = true; while (isRunning && (jsiHasTimers() || isBusy)) isBusy = jsiLoop(); JsVar *result = jsvObjectGetChild(execInfo.root, "result", 0/*no create*/); bool pass = jsvGetBool(result); jsvUnLock(result); if (pass) printf("----------------------------- PASS %s\r\n", filename); else { printf("----------------------------------\r\n"); printf("----------------------------- FAIL %s <-------\r\n", filename); jsvTrace(execInfo.root, 0); printf("----------------------------- FAIL %s <-------\r\n", filename); printf("----------------------------------\r\n"); } printf("BEFORE: %d Memory Records Used\r\n", jsvGetMemoryUsage()); // jsvTrace(execInfo.root, 0); jsiKill(); printf("AFTER: %d Memory Records Used\r\n", jsvGetMemoryUsage()); jsvGarbageCollect(); unsigned int unfreed = jsvGetMemoryUsage(); printf("AFTER GC: %d Memory Records Used (should be 0!)\r\n", unfreed); jsvShowAllocated(); jsvKill(); jshKill(); if (unfreed) { printf("FAIL because of unfreed memory.\r\n"); pass = false; } //jsvDottyOutput(); printf("\r\n"); free(buffer); return pass; }
bool run_test(const char *filename) { printf("----------------------------------\r\n"); printf("----------------------------- TEST %s \r\n", filename); char *buffer = (char *)read_file(filename); if (!buffer) return (false); jshInit(); jsiInit(false /* do not autoload!!! */); jspAddNativeFunction(jsiGetParser(), "function quit()", nativeQuit); jspAddNativeFunction(jsiGetParser(), "function interrupt()", nativeInterrupt); jsvUnLock(jspEvaluate(jsiGetParser(), buffer )); isRunning = true; while (isRunning && jsiHasTimers()) jsiLoop(); JsVar *result = jsvObjectGetChild(jsiGetParser()->root, "result", 0/*no create*/); bool pass = jsvGetBool(result); jsvUnLock(result); if (pass) printf("----------------------------- PASS %s\r\n", filename); else { printf("----------------------------------\r\n"); printf("----------------------------- FAIL %s <-------\r\n", filename); jsvTrace(jsvGetRef(jsiGetParser()->root), 0); printf("----------------------------- FAIL %s <-------\r\n", filename); printf("----------------------------------\r\n"); } printf("BEFORE: %d Memory Records Used\r\n", jsvGetMemoryUsage()); // jsvTrace(jsiGetParser()->root, 0); jsiKill(); printf("AFTER: %d Memory Records Used\r\n", jsvGetMemoryUsage()); jsvGarbageCollect(); printf("AFTER GC: %d Memory Records Used (should be 0!)\r\n", jsvGetMemoryUsage()); jsvShowAllocated(); jshKill(); //jsvDottyOutput(); printf("\r\n"); free(buffer); return pass; }