Merge pull request #1472 from CosmosOS/add_branch_tests

Add complex branch tests for compiler
This commit is contained in:
valentinbreiz 2020-12-19 03:09:59 +01:00 committed by GitHub
commit 274c5c8b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,9 +12,34 @@ namespace Cosmos.Compiler.Tests.MethodTests
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}
public static void BranchStackCorruption2()
{
char c = 'l';
char c2 = (c <= 'Z' && c >= 'A') ? ((char)(c - 65 + 97)) : c;
c = 'L';
char c3 = (c <= 'Z' && c >= 'A') ? ((char)(c - 65 + 97)) : c;
}
public static void BranchStackCorruption()
{
bool flag1 = true;
bool flag2 = false;
bool flag3 = true;
if (flag1 && (flag2 || flag3))
{
return;
}
else
{
throw new Exception("This should not occur");
}
}
protected override void Run()
{
BranchStackCorruption();
BranchStackCorruption2();
try
{
ReturnTests.Execute();