public void Test1() { const string source = @"MODULE Test; TYPE rType = RECORD a: INTEGER; b: STRING END; VAR demo: rType; BEGIN demo.a := 1; WriteInt(demo.a); WriteLn END Test."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("1\n", output.ToString().NlFix()); }
public void TestIssue25Repeat() { const string source = @"MODULE Issue25; VAR x: BOOLEAN; BEGIN x := FALSE; REPEAT WriteString('Yes'); x := TRUE UNTIL x; WriteLn END Issue25."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("Yes\n", output.ToString().NlFix()); }
public override bool Execute() { var stopwatch = Stopwatch.StartNew(); BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("PepitaPackage (version {0}) Executing", GetType().Assembly.GetName().Version), "", "Pepita", MessageImportance.High)); try { ValidatePackageDir(); var runner = new Runner { PackageDirectory = NuGetBuildDirectory, MetadataAssembly = MetadataAssembly, Version = Version, TargetDir = TargetDir, WriteInfo = s => BuildEngine.LogMessageEvent(new BuildMessageEventArgs("\t" + s, "", "Pepita", MessageImportance.High)), }; runner.Execute(); } catch (ExpectedException expectedException) { BuildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", "", 0, 0, 0, 0, string.Format("Pepita: {0}", expectedException.Message), "", "Pepita")); return false; } catch (Exception exception) { BuildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", "", 0, 0, 0, 0, string.Format("Pepita: {0}", exception), "", "Pepita")); return false; } finally { stopwatch.Stop(); BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("\tFinished ({0}ms)", stopwatch.ElapsedMilliseconds), "", "Pepita", MessageImportance.High)); } return true; }
public void RepeatTest() { const string source = @"MODULE Test; VAR i: INTEGER; BEGIN i := 1; REPEAT WriteInt(i); WriteLn; i := i+1; UNTIL i > 5 END Test."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("1\n2\n3\n4\n5\n", output.ToString().NlFix()); }
public void TestNegRealVar() { string source = @"MODULE Array; VAR a: REAL; BEGIN a := 1.5; a := -a; WriteReal(a); WriteLn; WriteReal(-a); WriteLn END Array."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal($"{-1.5}\n{1.5}\n", output.ToString().NlFix()); }
public void CanGoToFavourites() { using (var runner = new Runner<FavouritesTask>()) { runner.Execute(); } }
public void TestReservedWordIssue23() { const string source = @"MODULE Test; VAR int: INTEGER; BEGIN int := 1; WriteInt(int); WriteLn END Test."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("1\n", output.ToString().NlFix()); }
public void TestReadBoolVar() { string source = @"MODULE Array; VAR a,b: BOOLEAN; BEGIN ReadBool(a); ReadBool(b); WriteBool(a); WriteLn; WriteBool(b); WriteLn; END Array."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output, new StringReader("true" + Environment.NewLine + "false" + Environment.NewLine)); Assert.Equal($"{true}\n{false}\n", output.ToString().NlFix()); }
public void TestReadIntVar() { const string source = @"MODULE Array; VAR a: INTEGER; BEGIN ReadInt(a); WriteInt(a); WriteLn; END Array."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output, new StringReader("12" + Environment.NewLine)); Assert.Equal("12\n", output.ToString().NlFix()); }
public void ExecuteTest() { var mergeOptions = new MergeOptions { InputFiles = new[] { @"TestFiles\TestFile1.xml", @"TestFiles\TestFile2.xml" }, OutputFile = "merged.xml", LogLevel = LogLevel.Trace, DisableSanitize = false }; var fileLoader = new FileLoader(new NullLogger <FileLoader>()); var reportSanitizer = new ReportSanitizer(new NullLogger <ReportSanitizer>()); var reportMerger = new ReportMerger(new NullLogger <ReportMerger>()); var reportCalculator = new ReportCalculator(new NullLogger <ReportCalculator>()); var reportWriter = new ReportWriter(new NullLogger <ReportWriter>()); var logger = new MessageLogger <Runner>(); var runner = new Runner(logger, fileLoader, reportSanitizer, reportMerger, reportCalculator, reportWriter); Assert.True(runner.Execute(mergeOptions.InputFiles, mergeOptions.OutputFile, mergeOptions.DisableSanitize)); Assert.Empty(logger.Messages); }
public void SimpleArraySetAndGetValueGlobal() { const string source = @"MODULE Array3; VAR a: ARRAY 32 OF INTEGER; n: INTEGER; BEGIN a[1] := 1; n := a[1]; WriteInt(n); WriteLn END Array3."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("1\n", output.ToString().NlFix()); }
public void TestAddVarConst() { const string source = @"MODULE Array; VAR a: INTEGER; BEGIN a := 1; WriteInt(a+2); WriteLn END Array."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("3\n", output.ToString().NlFix()); }
public void TestArrayCallByValue() { string source = @"MODULE Test; TYPE aType = ARRAY 5 OF INTEGER; VAR arr: aType; PROCEDURE TestArray(a: aType); BEGIN IF (a[1] # 1) THEN WriteString('a is 0') END; a[1] := 2 END TestArray; BEGIN arr[1] := 1; TestArray(arr); WriteBool(arr[1] = 1); WriteLn END Test."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal($"{true}\n", output.ToString().NlFix()); }
public void TestEpsilon() { string source = @"MODULE Test; CONST expected = 10.8511834932; VAR r, s, z: REAL; b, c: BOOLEAN; BEGIN r := 1.5; s := 7.2341223288; z := r * s; b := (r - expected) < EPSILON; c := r = expected; WriteBool(b); WriteString(','); WriteBool(c); WriteLn END Test."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal($"{true},{false}\n", output.ToString().NlFix()); }
public void SystemToStringReal() { const string source = @"MODULE ToStringTest; VAR s: STRING; BEGIN s := ToString(12.5); WriteString(s); WriteLn END ToStringTest."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal("12.5\n", output.ToString().NlFix()); }
public override bool Execute() { var stopwatch = Stopwatch.StartNew(); BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("Pepita (version {0}) Executing", GetType().Assembly.GetName().Version), "", "Pepita", MessageImportance.High)); try { GetProjectPath(Console.Out); var runner = new Runner { ProjectDirectory = ProjectDirectory, SolutionDirectory = SolutionDirectory, WriteInfo = s => BuildEngine.LogMessageEvent(new BuildMessageEventArgs("\t" + s, "", "Pepita", MessageImportance.High)), }; runner.Execute(); } catch (ExpectedException expectedException) { BuildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", "", 0, 0, 0, 0, string.Format("Pepita: {0}", expectedException.Message), "", "Pepita")); return false; } catch (Exception exception) { BuildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", "", 0, 0, 0, 0, string.Format("Pepita: {0}", exception), "", "Pepita")); return false; } finally { stopwatch.Stop(); BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("\tFinished ({0}ms)", stopwatch.ElapsedMilliseconds), "", "Pepita", MessageImportance.High)); } return true; }
public void Execute() { var packagePath = Path.Combine(Environment.CurrentDirectory, "NugetPackageFiles"); packagePath = Path.GetFullPath(packagePath); var runner = new Runner { PackageDirectory = packagePath, MetadataAssembly="Standard.dll", WriteInfo = s => Debug.WriteLine(s) }; runner.Execute(); var outputFile = Path.Combine(packagePath, "MyPackage.1.0.nupkg"); var expectedFIle = Path.Combine(Environment.CurrentDirectory, "MyPackage.1.0.nupkg "); using (var package1 = Package.Open(expectedFIle)) using (var package2 = Package.Open(outputFile)) { foreach (var part1 in package1.GetParts()) { if (part1.Uri.OriginalString.EndsWith("psmdcp")) { continue; } if (part1.Uri.OriginalString.EndsWith("rels")) { continue; } var part2 = package2.GetPart(part1.Uri); var hash1 = GetFileHash(part1); var hash2 = GetFileHash(part2); Assert.AreEqual(hash1,hash2, part1.Uri.OriginalString); } } }
// dismissing method public static void Observe(string classImplementation) { var sourcesPath = Path.Combine(Environment.CurrentDirectory, "Sources"); Console.WriteLine($"Running from: {Environment.CurrentDirectory}"); Console.WriteLine($"Sources from: {sourcesPath}"); Console.WriteLine("Modify the sources to compile and run it!"); var compiler = new Compiler(); var runner = new Runner(); using (var watcher = new ObservableFileSystemWatcher(c => { c.Path = @".\Sources"; })) { var changes = watcher.Changed.Throttle(TimeSpan.FromSeconds(.5)).Where(c => c.FullPath.EndsWith(@"DynamicProgram.cs")).Select(c => c.FullPath); changes.Subscribe(filepath => runner.Execute("dynamicNamespace.dynamicClassName", compiler.CompileFile(filepath), new JObject()) ); watcher.Start(); Console.WriteLine("Press any key to exit!"); Console.ReadLine(); } }
public static JObject RunWithTemplate(JObject jsonToElaborate, JObject DataStructure, string classNameWithNameSpace, string dynamicTemplateElaboatorClassPath = @".\Sources\DynamicScribanTemplate.txt") { // -- compile template var sourcesPath = Path.Combine(Environment.CurrentDirectory, "Sources"); string templateFromText = File.ReadAllText(dynamicTemplateElaboatorClassPath); var renderedTemplate = ScribanRenderer.RenderJson(DataStructure.ToString(), templateFromText); // -- compile and run class var compiler = new Compiler(); var runner = new Runner(); var compiledAssembly = compiler.CompileSource(renderedTemplate); var jsonElaborated = runner.Execute(classNameWithNameSpace, compiledAssembly, jsonToElaborate); // ---- test /*var dynamicScribanTemplate = new DynamicScribanTemplate(); * var jsonElaborated = dynamicScribanTemplate.Elaborate(jsonToElaborate);*/ // ---- return(jsonElaborated); }
public override void SetUp() { WriteTrace("Deleting from mt_hilo"); Runner.StartTransaction(); Runner.Execute("delete from mt_hilo"); }
public void Execute(Runner my) { var prop = typeof(TestClass).GetProperty("TestProperty"); var obj = new TestClass(); my.Execute("raw", i => { obj.TestProperty = "asd"; }); var stdDel = (Action <TestClass, string>)Delegate.CreateDelegate(typeof(Action <TestClass, string>), prop.GetSetMethod()); my.Execute("stddel", i => { stdDel(obj, "asd"); }); var genDel = new MethodCache().GetSetter(prop); my.Execute("gendel", i => { genDel(obj, "asd"); }); var cache = new MethodCache(); var method = prop.GetSetMethod(); cache.GetInvoker(method); my.Execute("gendelc", i => { cache.GetInvoker(method)(obj, "asd"); }); my.Execute("gendelc2", i => { cache.GetSetter(prop)(obj, "asd"); }); my.Execute("invoke", i => { method.Invoke(obj, new[] { "asd" }); }); my.Execute("setvalue", i => { prop.SetValue(obj, "asd", null); }); var settable = prop.ToSettable(); my.Execute("settable", i => { settable.Set(obj, "asd"); }); }
public void Build(string[] args) { try { //check if another instance is running - if so exit ExecutionLogLogger.SetExecutionStartTime(DateTime.Now); var isProcessRunning = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Length > 1; if (isProcessRunning) { Log.Info("Another instance was running, so exiting the application without any processing."); return; } // First check if the "done" file is there. If so, skip job execution and move to file-related steps if (HasDoneFile()) { Log.Info("Done file exists at the drop folder. Skipping job execution and moving to file operations."); ExecuteFileOperations(); return; } Log.Info("Execution started!"); var feed = FeedService.GetFeed(FeedId); var allowPrimary = !feed.IsPaused; if (!allowPrimary) { Log.InfoFormat("{0} feeds are paused. Exiting application without any processing.", feed.Name); return; } // First clean all the files inside the output folder (in case the previous run failed and left out old files behind.) RemoveOldFiles(); _currentRun = FeedRunService.GetOrCreateActiveFeedRun(feed.FeedId, true, false); _effectiveExecutionEndTime = DateTime.Now; Runner.Initialize(ExecutionLogLogger, _currentRun.FeedId); ExecutionLogLogger = Runner.Execute(); if (ExecutionLogLogger.HasError) { Log.Error("Execution failed!!! Exiting application without moving any files."); HandleExit(); return; } HandleSuccess(); var elapsedTime = DateTime.Now - ExecutionLogLogger.GetExecutionStartTime(); Log.InfoFormat("Execution completed in {0}", elapsedTime.ToString(@"dd\.hh\:mm\:ss")); } catch (Exception e) { Log.Error("Execution failed!!!", e); HandleExit(); } }
public void ExecuteIncorrectParametersTest() { CompilationTester tester = new CompilationTester(FunctionContainer.CreateDefaultSetting()); string programPath; string exeString; Program program = FunctionContainer.CreateProgram("", 10000, 100000); Result result; try { //-----------CS----------- programPath = tester.GenerateFileForCompilation(CompileServiceLanguageSourceCode.CSCorrectSourceCode, Language.CSharp3); exeString = Path.ChangeExtension(programPath, "exe"); program.InputTest = "2"; program.OutputTest = "23"; program.Language = Language.CSharp3; result = Runner.Execute(exeString, program); Assert.AreNotEqual(result.ProgramStatus, Status.Accepted); //-----------CPP----------- programPath = tester.GenerateFileForCompilation(CompileServiceLanguageSourceCode.CPPCorrectSourceCode, Language.VC8); exeString = Path.ChangeExtension(programPath, "exe"); program.InputTest = "2"; program.OutputTest = "23"; program.Language = Language.VC8; result = Runner.Execute(exeString, program); Assert.AreNotEqual(result.ProgramStatus, Status.Accepted); //-----------Java----------- programPath = tester.GenerateFileForCompilation(CompileServiceLanguageSourceCode.JavaCorrectSourceCode, Language.Java6); exeString = Path.ChangeExtension(programPath, "exe"); program.InputTest = "2"; program.OutputTest = "23"; program.Language = Language.Java6; result = Runner.Execute(exeString, program); Assert.AreNotEqual(result.ProgramStatus, Status.Accepted); //-----------Delphi----------- programPath = tester.GenerateFileForCompilation(CompileServiceLanguageSourceCode.DelphiCorrectSourceCode, Language.Delphi7); exeString = Path.ChangeExtension(programPath, "exe"); program.InputTest = ""; program.OutputTest = " world!"; program.Language = Language.Delphi7; result = Runner.Execute(exeString, program); Assert.AreNotEqual(result.ProgramStatus, Status.Accepted); } catch (Exception) { Assert.AreEqual(true, false); } }
private void BackgroundDoWork(object sender, DoWorkEventArgs e) { var rdr = (DatabaseReader)e.Argument; var runner = new Runner(rdr, _filePath, OriginSqlType(), SqlServerCE4Radio.Checked); //pass thru the event to background worker runner.ProgressChanged += (s1, e1) => backgroundWorker1.ReportProgress(e1.ProgressPercentage, e1.UserState); var result = runner.Execute(); if (!result) e.Result = runner.LastErrorMessage; else e.Result = null; rdr.Dispose(); }
static void Main(string[] args) { var sourcePath = @"C:\Users\Admin\source\repos\SiriCompiler"; var filePath = Path.Combine(sourcePath, "DynamicProgram.cs"); Console.WriteLine($"Kører fra: {sourcePath}"); var compiler = new Compiler(); var runner = new Runner(); runner.Execute(compiler.Compile(filePath), new[] { "Denmark" }); int[] a = new int[] { 1, 3, 5, 7, 9 }; Console.WriteLine(); Console.WriteLine(a.Count()); var filePath2 = Path.Combine(sourcePath, "TestArrayCount.cs"); runner.Execute(compiler.Compile(filePath2), new[] { "a.Count();" }); }
static void Main(string[] args) { var options = Runner.ParseOptions <Runner.RunnerOptions>(args); ProjectDefinition.Register(options, new ProjectDefinition { SolutionPath = "./YouTubeArchiver.sln" }); Runner.Execute(options); }
static void Main(string[] args) { var options = Runner.ParseOptions <Runner.RunnerOptions>(args); ProjectDefinition.Register(options, new ProjectDefinition { SolutionPath = "./SharpReadWriteLock.sln" }); Runner.Execute(options); }
public void Execute(Runner my) { var prop = typeof(TestClass).GetProperty("TestProperty"); var obj = new TestClass(); my.Execute("raw", i => { obj.TestProperty = "asd"; }); var stdDel = (Action<TestClass, string>)Delegate.CreateDelegate(typeof(Action<TestClass, string>), prop.GetSetMethod()); my.Execute("stddel", i => { stdDel(obj, "asd"); }); var genDel = new MethodCache().GetSetter(prop); my.Execute("gendel", i => { genDel(obj, "asd"); }); var cache = new MethodCache(); var method = prop.GetSetMethod(); cache.GetInvoker(method); my.Execute("gendelc", i => { cache.GetInvoker(method)(obj, "asd"); }); my.Execute("gendelc2", i => { cache.GetSetter(prop)(obj, "asd"); }); my.Execute("invoke", i => { method.Invoke(obj, new[] { "asd" }); }); my.Execute("setvalue", i => { prop.SetValue(obj, "asd", null); }); var settable = prop.ToSettable(); my.Execute("settable", i => { settable.Set(obj, "asd"); }); }
static void Main(string[] args) { var options = Runner.ParseOptions <Runner.RunnerOptions>(args); Info($"Configuration: {options.Config}"); var gitVersion = GetGitVersion(ExpandPath("./")); Info($"Version: {gitVersion.FullVersion}"); var commandBuildArgs = $"--configuration {options.Config}"; var commandBuildArgsWithVersion = commandBuildArgs; if (!string.IsNullOrEmpty(gitVersion.PreReleaseTag)) { commandBuildArgsWithVersion += $" --version-suffix \"{gitVersion.PreReleaseTag}\""; } Target("clean", () => { CleanDirectory(ExpandPath("./output")); }); Target("update-version", () => { if (FileExists("./build/version.props")) { DeleteFile("./build/version.props"); } WriteFile("./build/version.props", $@"<Project> <PropertyGroup> <VersionPrefix>{gitVersion.Version}</VersionPrefix> </PropertyGroup> </Project>"); }); Target("build", () => { RunShell($"dotnet build {commandBuildArgs} {ExpandPath("./AptTool.sln")}"); }); Target("deploy", () => { RunShell($"dotnet pack --output {ExpandPath("./output")} {commandBuildArgsWithVersion} {ExpandPath("./src/AptTool/AptTool.csproj")}"); }); Target("ci", DependsOn("clean", "update-version", "deploy")); Target("default", DependsOn("build")); Runner.Execute(options); }
static void Main(string[] args) { var options = Runner.ParseOptions <Runner.RunnerOptions>(args); ProjectDefinition.Register(options, new ProjectDefinition { ProjectName = "Wallet", SolutionPath = "./PlumPack.Wallet.sln", WebProjectPath = "./src/PlumPack.Wallet.Web/PlumPack.Wallet.Web.csproj", DockerImageName = "plumpack/wallet" }); Runner.Execute(options); }
public void Multiply(int a, int b) { string source = @" MODULE MultiplyTest; VAR x, y, z: INTEGER; PROCEDURE Multiply(x: INTEGER; y: INTEGER; VAR z: INTEGER); VAR negate : BOOLEAN; BEGIN negate := x < 0; IF (negate) THEN x := -x END; z := 0; WHILE x > 0 DO IF x MOD 2 = 1 THEN z := z + y END; y := 2*y; x := x DIV 2 END ; IF (negate) THEN z := -z END; END Multiply; BEGIN ReadInt(x); ReadInt(y); Multiply(x, y, z); WriteInt(z); WriteLn END MultiplyTest. "; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output, new StringReader($"{a}{Environment.NewLine}{b}{Environment.NewLine}")); Assert.Equal($"{a * b}\n", output.ToString().NlFix()); }
public void Execute() { var packagePath = Path.Combine(Environment.CurrentDirectory, "NugetPackageFiles"); packagePath = Path.GetFullPath(packagePath); var runner = new Runner { PackageDirectory = packagePath, MetadataAssembly = "Standard.dll", WriteInfo = s => Debug.WriteLine(s) }; runner.Execute(); var outputFile = Path.Combine(packagePath, "Standard.1.0.0.0.nupkg"); var expectedFile = Path.Combine(Environment.CurrentDirectory, "MyPackage.1.0.0.0.nupkg "); VerifyPackagesAreTheSame(expectedFile, outputFile); }
public ApiResult Test(TestRequestDto <string> dto) { var result = Runner.Execute(service.HisInterfaceTest, dto.GetRequestData()).Result; if (result.hasError) { return(new ApiResult <Exception> { Success = false, ResultData = result.error }); } else { return(new ApiResult <string> { Success = true, ResultData = result.data }); } }
public void TestRecordCallByValue() { string source = @"MODULE Test; TYPE rType = RECORD a: INTEGER; b: REAL; c: BOOLEAN END; VAR r: rType; PROCEDURE TestRecord(r: rType); BEGIN IF (r.a # 1) THEN WriteString(' a error') END; IF ~r.c THEN WriteString('c error') END; IF ABS(r.b - 1.2345) > EPSILON THEN WriteString('b error') END; r.a := -1; r.b := -1.2345; r.c := FALSE; END TestRecord; BEGIN r.a := 1; r.b := 1.2345; r.c := TRUE; TestRecord(r); WriteBool((r.a = 1) & (ABS(r.b - 1.2345) < EPSILON) & r.c); WriteLn END Test."; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal($"{true}\n", output.ToString().NlFix()); }
public void TestProcedureBoolean() { string source = @" MODULE ProcTest; CONST true_ = TRUE; VAR x, y: BOOLEAN; i, j: BOOLEAN; PROCEDURE Test(x: BOOLEAN; y: BOOLEAN; VAR a: BOOLEAN; b: BOOLEAN); BEGIN x := FALSE; y := true_; a := TRUE; b := FALSE; END Test; BEGIN x := TRUE; y := x = true_; i := FALSE; j := FALSE; Test(y, x, i, j); WriteBool(x); WriteString(', '); WriteBool(y); WriteString(', '); WriteBool(i); WriteString(', '); WriteBool(j); WriteLn END ProcTest. "; var cg = CompileHelper.CompileOberon0Code(source, out string code, _output); Assert.NotEmpty(code); var syntaxTree = CSharpSyntaxTree.ParseText(code); var assembly = syntaxTree.CompileAndLoadAssembly(cg, true); Assert.True(assembly != null); using var output = new StringWriter(); Runner.Execute(assembly, output); Assert.Equal($"{true}, {true}, {true}, {false}\n", output.ToString().NlFix()); }
public void Execute_WithAnInnerException_ReturnsNonZero() { var buggyParamReader = new Mock <IParamReader>(); buggyParamReader .Setup(o => o.Read(It.IsAny <string[]>())) .Throws(new Exception("Bim")); var target = new Runner( buggyParamReader.Object, Mock.Of <IFileEnumerator>(), Mock.Of <IReader>(), Mock.Of <IDependencyFilter>(), Mock.Of <ILogger>(), Mock.Of <TextWriter>() ); var result = target.Execute(null); Assert.AreNotEqual(0, result); }
public bool Execute() { var runner = new Runner(new MSBuildLogWriter(BuildEngine), new MSBuildParameterParser()); return runner.Execute(new[] {TargetDirectory, Variables ?? string.Empty}); }
public static int Main(string[] args) { _runner = new Runner(new ConsoleLogWriter(), new ConsoleParameterParser()); return _runner.Execute(args) ? 0 : 1; }