本文整理汇总了C#中TestContext.GetOutputFileWriter方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.GetOutputFileWriter方法的具体用法?C# TestContext.GetOutputFileWriter怎么用?C# TestContext.GetOutputFileWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestContext
的用法示例。
在下文中一共展示了TestContext.GetOutputFileWriter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRuntime
private static void CreateRuntime(TestContext context, MethodReference method)
{
using (var runtime = context.GetOutputFileWriter("runtime.c"))
{
string printf;
//string function = "setup_stack(stack_base)";
string function = string.Format("{0}({1})", method.Name, string.Join(", ", context.Arguments.Select(o => o.ToString()).ToArray()) );
string returnType;
switch (method.ReturnType.ReturnType.Name.ToLower())
{
case "single":
printf = "%.3f";
returnType = "float";
break;
case "int32":
printf = "%d";
returnType = "long";
break;
case "boolean":
printf = "%s";
returnType = "bool";
function += " ? \"True\" : \"False\"";
break;
case "char":
printf = "%c";
returnType = "char";
break;
default:
printf = "%d";
returnType = "long";
if (Debugger.IsAttached)
Debugger.Break();
break;
}
runtime.WriteLine("#include <stdio.h>");
runtime.WriteLine("#include <stdbool.h>");
runtime.WriteLine("#include <stdlib.h>");
//runtime.WriteLine();
//runtime.WriteLine(string.Format("{0} setup_stack(char*);", returnType));
runtime.WriteLine();
runtime.WriteLine("int main(int argc, char** argv)");
runtime.WriteLine("{");
//runtime.WriteLine(" int stack_size = (16 * 4096);");
//runtime.WriteLine(" char* stack_top = malloc(stack_size);");
//runtime.WriteLine(" char* stack_base = stack_top + stack_size;");
runtime.WriteLine(" printf(\"{0}\\n\", {1});", printf, function);
//runtime.WriteLine(" free(stack_top);");
runtime.WriteLine(" return 0;");
runtime.WriteLine("}");
}
}