public void test_access_complex() { string testName = "access_complex"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); }
public void test_and_operator_returns_value() { string testName = "and_operator_returns_value"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The body's expression of <while> must not return a value") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_and_operator_non_valued_operands() { string testName = "and_operator_non_valued_operands"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The rigth operand in \"&\" operator must be return an int"), new Error(0,0,"The left operand in \"&\" operator must be return an int"), new Error(0,0,"The left operand in \"&\" operator must be return an int"), new Error(0,0,"The rigth operand in \"&\" operator must be return an int") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
static void Main(string[] args) { if (args == null || args.Length == 0) { Console.WriteLine("The program expected 1 argument"); Console.ReadLine(); return; } DirectoryInfo di = new DirectoryInfo(args[0]); if (!File.Exists(args[0])) { Console.WriteLine("The path {0} is wrong", args[0]); Console.ReadLine(); return; } string dir; Console.WriteLine("\n\nTiger Compiler version 1.0\n\n Copyright (C) 2011-2012 Oisbel Simpson & Danaice Lopez & Karla Iturriza\n\n"); Compiler compiler = new Compiler(); dir = args[0].ToString(); //dir = "..\\..\\..\\tests\\Success\\str.tig"; List<Error> errors = compiler.Compile(dir); if (errors.Count > 0) { Console.WriteLine("__________Errores_________\n"); foreach (var item in errors) { Console.WriteLine(item.ToString()); } Console.WriteLine("\n… código de salida de tiger.exe: 1"); } else { string name = dir.Substring(dir.LastIndexOf("\\") + 1); string[] filename = name.Split('.'); Console.WriteLine("… código de salida de tiger.exe: 0\n … y se crea (o sobrescribe) el archivo {0}", filename[0] + ".exe"); } Console.ReadLine(); }
public void test_recursive_array() { string testName = "recursive_array"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The array \"a\" can't be recursive") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_record_literal_invalid_types() { string testName = "record_literal_invalid_types"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Cannot assign <nil> to an <int>"), new Error(0,0,"The field \"siblin\" of record must be of type \"human\""), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_record_literal_more_params() { string testName = "record_literal_more_params"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The record \"human\" don't have 2 parameter(s)") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_if_then_without_valued_condition() { string testName = "if_then_without_valued_condition"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The break is illegal outside <for> or <while>"), new Error(0,0,"The condition's expressions of <if-then> must be an int"), new Error(0,0,"The break is illegal outside <for> or <while>") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_record_access_incompatibles_types() { string testName = "record_access_incompatibles_types"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Cannot asssign \"human\" to \"int\""), new Error(0,0,"The left and rigth operand in \"=\" operator may be either of the same type") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test11() { string testName = "test11"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The To'expression of <for> must be an int"), new Error(0,0,"Cannot assign any value to variable \"i\" of <for>") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test16() { string testName = "test16"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type \"d\" do not not pass through record or array"), new Error(0,0,"The type \"c\" do not not pass through record or array"), new Error(0,0,"The type \"b\" do not not pass through record or array"), new Error(0,0,"The type \"a\" do not not pass through record or array"), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_mod5() { string testName = "mod5"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type \"MyType\" is already defined in this scope"), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_mod7_3() { string testName = "mod7_3"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The expression that try assign to \"int\" not return value"), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_mod2() { string testName = "mod2"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Cannot declarate a type named <string>"), new Error(0,0,"Cannot assisgn \"int\" to a variable of type \"string\""), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_mod3() { string testName = "mod3"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Cannot create a function named \"print\""), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_invalid_mutually_recursive_record_depth_4() { string testName = "invalid_mutually_recursive_record_depth_4"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type \"C\" is not defined"), new Error(0,0,"The type \"H\" is not defined"), new Error(0,0,"The type \"C\" do not not pass through record or array"), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_invalid_mutually_recursive_function_depth_4() { string testName = "invalid_mutually_recursive_function_depth_4"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type of parameter \"b\" is not defined"), new Error(0,0,"Doesn't exist any function with name \"h\""), new Error(0,0,"Doesn't exist any function with name \"i\""), new Error(0,0,"Doesn't exist any function with name \"f\""), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_incompatible_types_jagged_array() { string testName = "incompatible_types_jagged_array"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Cannot asssign \"string\" to \"int\"") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_str() { string testName = "str1"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; //string outputBinary = "..\\..\\..\\tests\\Success"; //SetDirectory(outputBinary); Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test Failed ", testName); }
public void test_test18() { string testName = "test18"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Doesn't exist any function with name \"do_nothing2\""), new Error(0,0,"Doesn't exist any function with name \"do_nothing1\""), new Error(0,0,"Doesn't exist any function with name \"do_nothing1\"") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_expression_sequence_returns_last_value() { string testName = "expression_sequence_returns_last_value"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The condition's expressions of <if-then-else> must be an int"), new Error(0,0,"The second and third expressions of <if-then-else> must be of the same type") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test21() { string testName = "test21"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The rigth operand in \"*\" operator must be return an int"), new Error(0,0,"The procedure \"nfactor\"cannot return any value"), new Error(0,0,"Doesn't exist any function with name \"nfactor\"") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test14() { string testName = "test14"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The left and rigth operand in \"<>\" operator may be either of the same type") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_undefined_type_for_array_declaration() { string testName = "undefined_type_for_array_declaration"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type \"rectype\" is not defined in this scope") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test17() { string testName = "test17"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type \"treelist\" is not defined"), new Error(0,0,"The type \"tree\" is not defined") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_if_then_else_without_return_value() { string testName = "if_then_else_without_return_value"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The first expression of <while> must be an int") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test19() { string testName = "test19"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The variable \"a\" doesn't exist in the current scope") }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_procedure_same_parameters_name() { string testName = "procedure_same_parameters_name"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"Cannot be 2 parameters with the same name"), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_test22() { string testName = "test22"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { new Error(0,0,"The type \"rectype\" don't have any field \"nam\""), }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }
public void test_queens() { string testName = "queens"; string inputProgram = "..\\..\\..\\tests\\" + testName + ".tig"; Compiler compiler = new Compiler(); compiler.Compile(inputProgram); List<Error> expected = new List<Error>() { }; Assert.AreEqual(expected.Count, Compiler.Errors.Count, "El test " + testName + "la cantidad de errores fueron distintos"); for (int i = 0; i < expected.Count; i++) Assert.AreEqual(expected[i], Compiler.Errors[i], "{0} Test fallido ", testName); }