Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cesium.CodeGen.Tests/CodeGenDeclarationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Task StaticDeclarationsInDifferentFunctions() => DoTest(
int test()
{
static int i = 2;
return 0;
}");

[Fact]
Expand Down
19 changes: 16 additions & 3 deletions Cesium.CodeGen.Tests/CodeGenMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,24 @@ public Task ImplicitReturnAllowedForMain() => DoTest(@"int main()
int unused = 0;
}");

[Fact]
public void ImplicitReturnAllowedNonMain() => DoTest(@"int foo()
[Fact, NoVerify]
public void ImplicitReturnNotAllowedNonMain() => DoesNotCompile(@"int foo()
{
int unused;
}");
}", "Not all control flow paths in function foo return a value.");

[Fact, NoVerify]
public void ReturnIsNecessaryOnEntirePathsForNonMain() => DoesNotCompile(@"int foo()
{
if(1)
{
// missed return
}
else
{
return 1;
}
}", "Not all control flow paths in function foo return a value.");

[Fact, NoVerify]
public void ExpressionReturnDisallowedInVoidFunction() => DoesNotCompile(@"void foo()
Expand Down
2 changes: 1 addition & 1 deletion Cesium.CodeGen.Tests/CodeGenSwitchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Task LowerExpression() => DoTest(@"
int my_condition() { return 0; }
int main()
{
switch(my_condition()) {
switch(my_condition()) {
case 0: break;
case 1:
default: break;
Expand Down
32 changes: 32 additions & 0 deletions Cesium.CodeGen.Tests/CodeGenWhileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,36 @@ public Task DoWhile() => DoTest(
int i = 0;
do ++i; while (i < 10);
}");

[Fact]
public Task InfinityWhile() => DoTest(
@"int main()
{
int i = 0;
while (1) i++;
}");

[Fact]
public Task InfinityDoWhile() => DoTest(
@"int main()
{
int i = 0;
do i++; while (1);
}");

[Fact]
public Task NegativeWhile() => DoTest(
@"int main()
{
int i = 0;
while (!1) i++;
}");

[Fact]
public Task NegativeDoWhile() => DoTest(
@"int main()
{
int i = 0;
do i++; while (!1);
}");
}
Loading
Loading