def testEmbededCProgramFragment(self): fragment = r""" #include <assert.h> #include <stdio.h> #include <string.h> void foo() { char str[] = "Hello World!"; printf("%s", str); } """ link_cvm.link(self.env, fragment, self.tmpDest) self.assertSuccessOutput("Hello World!")
def testGarbageCollectionFragment(self): fragment = r""" #include <assert.h> #include <stdio.h> #include <string.h> void foo() { char str[] = "Hello Garbage-collected World!"; char *heapBuf = (char *)GC_MALLOC(sizeof str); assert(heapBuf != 0); assert(*heapBuf == 0); strcpy(heapBuf, str); printf("%s", heapBuf); } """ link_cvm.link(self.env, fragment, self.tmpDest) self.assertSuccessOutput("Hello Garbage-collected World!")
def testUseCVMOpcode(self): link_cvm.link(self.env, r"void foo(){CVM_VERSION}", self.tmpDest) self.assertSuccessOutput("You've compiled a C-VM program (version 1.0).")