public void TypeMismatchAssignmentFromNumber_Test() { CmCompiler.CompileText( @"static bool b; b = 5;" ); }
public void TypeMismatchDefinitionIndirectionLevel_Test2() { CmCompiler.CompileText( @"static int y = 0; static int* x = y;" ); }
public void LargeReturnValuesNotSupportedTest() { CmCompiler.CompileText( @"typedef X { int x; int y; } X Test(int a);" ); }
public void TypeMismatchDefinitionFromVariable_Test() { CmCompiler.CompileText( @"static bool b; static int x = b;" ); }
public void ArrayIndexOnNonArray_Test2() { CmCompiler.CompileText( @"static int[10] x; (x[1])[2] = 1;" ); }
public void ArrayAssignment_Test() { CmCompiler.CompileText( @"static int[10] x; x[1] = 1;" ); }
public void ArrayToArrayAssignment_Test() { CmCompiler.CompileText( @"static int[10] x; static int[5] y = x;" ); }
public void TypeMismatchDefinitionIndirectionLevel_Test3() { CmCompiler.CompileText( @"static int* x; static int y = *(*x);" ); }
public void IndirectionLevels_Test2() { CmCompiler.CompileText( @"static int** x; static int y = *(*x);" ); }
public void TypeMismatchIndirectionLevel_Test4() { CmCompiler.CompileText( @"static int* x; static int* y = &x;" ); }
public TestVM ExecuteTestVM(string testCode) { CompilationContext context = CmCompiler.CompileText(testCode); byte[] objectCode; using (var s = new MemoryStream()) { CmCompiler.CreateObjectCode(s, new RIVMArchitecture(), context.GetIR(), context.GetStringConstants(), context.GetGlobalVariables(), context.GetFunctions()); objectCode = s.GetBuffer(); } byte[] executableCode; using (var s = new MemoryStream()) { CmLinker.Link(s, new List <byte[]> { objectCode }, false, SystemMemoryMap.BIOS_ROM_START); executableCode = s.GetBuffer(); } var bios = new BIOS(executableCode); var mmu = new MMU(SystemMemoryMap.BIOS_STACK_END, bios, null, null); var cpu = new CPU(mmu); cpu.Start(); return(new TestVM(cpu)); }
public void ArrayIndexOnNonArray_Test() { CmCompiler.CompileText( @"static int x; x[1] = 1;" ); }
public void AssignmentToArrayVariable_Test() { CmCompiler.CompileText( @"static int[10] a; a = 1;" ); }
public void VoidAssignmentTo_Test() { CmCompiler.CompileText( @"static void a; static void b; a = b;" ); }
public void AddressOfArrayIsSameAsArray_Test() { CmCompiler.CompileText( @"static int[10] x; static int* p = x; static int* q = &x;" ); }
public void FunctionReturnTypeVoidMismatch_Test() { CmCompiler.CompileText( @"void Test() { return 0; }" ); }
public void CompatibleTypeBoolean_Test3() { CmCompiler.CompileText( @"static bool a; static bool b; static bool res = a && b ^ 5;" ); }
public void ArrayOfPointersAssignmentError_Test() { CmCompiler.CompileText( @"static int x; static int y; static int*[10] a; a[0] = x; a[1] = y;" ); }
public void CompatibleTypeBoolean_Test5() { CmCompiler.CompileText( @"static int a; static int b; static bool res = a < 5 && b != 1;" ); }
public void CompatibleTypeBoolean_Test4() { CmCompiler.CompileText( @"static bool a; static bool b; static bool res = 5 || a ^ b;" ); }
public void TypeMismatchDefinitionFromExpression_Test() { CmCompiler.CompileText( @"static int x = 0; static int y = 1; static bool b = x + y;" ); }
public void CompatibleTypeBoolean_Test2() { CmCompiler.CompileText( @"static int x = 0; static int y = 1; static bool res = x && y;" ); }
public void PointerAsArrayAssignmentError_Test() { CmCompiler.CompileText( @"static int x; static int y; static int* a; a[0] = &x; a[1] = &y;" ); }
public void UndefinedArgumentVariable_Test() { CmCompiler.CompileText( @"int Test(int x, int y) { return z; }" ); }
public void FunctionReturnTypeMismatch_Test() { CmCompiler.CompileText( @"byte Test() { return (int)0; }" ); }
public void TypeMismatchAssignmentFromVariable_Test() { CmCompiler.CompileText( @"static bool b; static int x = 0; x = b;" ); }
public void MissingReturn_Test() { CmCompiler.CompileText( @"int Test(int x, int y, int z) { int temp = x + y; }" ); }
public void IndirectionLevels_Test() { CmCompiler.CompileText( @"static int x = 0; static int* y = &x; static int** z = &y;" ); }
public void ArrayFunctionArgumentCalledWithPointer_Test() { CmCompiler.CompileText( @"int Test(int[] a) { return 0; } static int* a; Test(a);" ); }
public void TypeMismatchIndirectionLevelAssignment_Test5() { CmCompiler.CompileText( @"static int* x; static int* y; y = &x;" ); }