コード例 #1
0
ファイル: ParserUtils.cs プロジェクト: telkomops/TypeCobol
/*TODO#249
 *              private static void Dump(StringBuilder str, IList<Function> functions) {
 *                      if (functions == null || functions.Count < 1) return;
 *                      str.AppendLine("FUNCTIONS:");
 *                      foreach(var function in functions) {
 *                              str.Append(" £ ").Append(function.Name).Append(':').Append(function.Visibility);
 *                              str.AppendLine();
 *                              foreach(var parameter in function.Profile.InputParameters) {
 *                                      str.Append("        in: ");
 *                                      Dump(str, parameter);
 *                                      str.AppendLine();
 *                              }
 *                              foreach(var parameter in function.Profile.OutputParameters) {
 *                                      str.Append("       out: ");
 *                                      Dump(str, parameter);
 *                                      str.AppendLine();
 *                              }
 *                              foreach(var parameter in function.Profile.InoutParameters) {
 *                                      str.Append("        io: ");
 *                                      Dump(str, parameter);
 *                                      str.AppendLine();
 *                              }
 *                              if (function.Profile.ReturningParameter != null) {
 *                                      str.Append("    return: ");
 *                                      Dump(str, function.Profile.ReturningParameter);
 *                                      str.AppendLine();
 *                              }
 *                      }
 *              }
 *              private static void Dump(StringBuilder str, ParameterDescription parameter) {
 *                      str.Append(parameter.Name).Append(':');
 *                      var entry = (ParameterDescriptionEntry)parameter.CodeElement;
 *                      if (entry.CustomType != null) str.Append(entry.CustomType);
 *                      else
 *                      if (entry.Picture != null) str.Append(entry.Picture);
 *                      else str.Append("?");
 *              }
 * // [/TYPECOBOL]
 *
 * private static void Dump(StringBuilder str, Dictionary<string, List<Named>> map) {
 * foreach(string key in map.Keys) {
 *  foreach (var data in map[key]) {
 *      Dump(str, data, 1);
 *      str.Append("\n");
 *  }
 * }
 * }
 *
 * private static StringBuilder Dump(StringBuilder str, Named data, int indent = 0)
 * {
 * DumpIndent(str, indent);
 * str.Append(data.Name);
 * return str;
 * }
 *
 * private static StringBuilder DumpIndent(StringBuilder str, int indent)
 * {
 * for (int c=0; c<indent; c++) str.Append("  ");
 * return str;
 * }
 */

        public static void CheckWithResultFile(string result, string testName)
        {
            using (StreamReader reader = new StreamReader(PlatformUtils.GetStreamForProjectFile(@"Parser\CodeElements\" + testName + ".txt")))
            {
                CheckWithResultReader(testName, result, reader, PlatformUtils.GetPathForProjectFile(@"Parser\CodeElements\" + testName + ".txt"));
            };
        }
コード例 #2
0
/*TODO#249
 *              private static void Dump(StringBuilder str, IList<Function> functions) {
 *                      if (functions == null || functions.Count < 1) return;
 *                      str.AppendLine("FUNCTIONS:");
 *                      foreach(var function in functions) {
 *                              str.Append(" £ ").Append(function.Name).Append(':').Append(function.Visibility);
 *                              str.AppendLine();
 *                              foreach(var parameter in function.Profile.InputParameters) {
 *                                      str.Append("        in: ");
 *                                      Dump(str, parameter);
 *                                      str.AppendLine();
 *                              }
 *                              foreach(var parameter in function.Profile.OutputParameters) {
 *                                      str.Append("       out: ");
 *                                      Dump(str, parameter);
 *                                      str.AppendLine();
 *                              }
 *                              foreach(var parameter in function.Profile.InoutParameters) {
 *                                      str.Append("        io: ");
 *                                      Dump(str, parameter);
 *                                      str.AppendLine();
 *                              }
 *                              if (function.Profile.ReturningParameter != null) {
 *                                      str.Append("    return: ");
 *                                      Dump(str, function.Profile.ReturningParameter);
 *                                      str.AppendLine();
 *                              }
 *                      }
 *              }
 *              private static void Dump(StringBuilder str, ParameterDescription parameter) {
 *                      str.Append(parameter.Name).Append(':');
 *                      var entry = (ParameterDescriptionEntry)parameter.CodeElement;
 *                      if (entry.CustomType != null) str.Append(entry.CustomType);
 *                      else
 *                      if (entry.Picture != null) str.Append(entry.Picture);
 *                      else str.Append("?");
 *              }
 * // [/TYPECOBOL]
 *
 * private static void Dump(StringBuilder str, Dictionary<string, List<Named>> map) {
 * foreach(string key in map.Keys) {
 *  foreach (var data in map[key]) {
 *      Dump(str, data, 1);
 *      str.Append("\n");
 *  }
 * }
 * }
 *
 * private static StringBuilder Dump(StringBuilder str, Named data, int indent = 0)
 * {
 * DumpIndent(str, indent);
 * str.Append(data.Name);
 * return str;
 * }
 *
 * private static StringBuilder DumpIndent(StringBuilder str, int indent)
 * {
 * for (int c=0; c<indent; c++) str.Append("  ");
 * return str;
 * }
 */

        public static void CheckWithResultFile(string result, string testName)
        {
            using (StreamReader reader = new StreamReader(PlatformUtils.GetStreamForProjectFile(@"Compiler\Parser\ResultFiles\" + testName + ".txt")))
            {
                CheckWithResultReader(testName, result, reader);
            }
        }
コード例 #3
0
        public static void CheckWithResultFile(string result, string testName)
        {
            using (StreamReader reader = new StreamReader(PlatformUtils.GetStreamForProjectFile(@"Parser\Scanner\ResultFiles\" + testName + ".txt")))
            {
                string expectedResult = reader.ReadToEnd();

                TestUtils.compareLines(testName, result, expectedResult);
            }
        }