-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from adrianoc/staging
February 2025 Update 1 (Version 2.18)
- Loading branch information
Showing
43 changed files
with
687 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Cecilifier.Core.Tests/Tests/OutputBased/LocalFunctionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Cecilifier.Core.Tests.Framework; | ||
using NUnit.Framework; | ||
|
||
namespace Cecilifier.Core.Tests.OutputBased; | ||
|
||
[TestFixture] | ||
public class LocalFunctionTests : OutputBasedTestBase | ||
{ | ||
[TestCase("static", TestName = "Static")] | ||
[TestCase("", TestName = "Instance")] | ||
public void InstanceLocalFunction(string staticOrInstance) | ||
{ | ||
AssertOutput($""" | ||
System.Console.Write(M(1)); | ||
{staticOrInstance} int M(int i) => 41 + i; | ||
""", | ||
"42"); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
Cecilifier.Core.Tests/Tests/OutputBased/NullCoalescingOperatorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Cecilifier.Core.Tests.Framework; | ||
using NUnit.Framework; | ||
|
||
namespace Cecilifier.Core.Tests.OutputBased; | ||
|
||
[TestFixture] | ||
public class NullCoalescingOperatorTests : OutputBasedTestBase | ||
{ | ||
[Test] | ||
public void SimpleNullableValueType() | ||
{ | ||
AssertOutput(""" | ||
System.Console.Write(M(42, 1)); | ||
int? M(int? i1, int? i2) => i1 ?? i2; | ||
""", | ||
"42"); | ||
} | ||
|
||
[Test] | ||
public void SimpleReferenceType() | ||
{ | ||
AssertOutput(""" | ||
System.Console.Write(M(null, "42")); | ||
object M(object o1, object o2) => o1 ?? o2; | ||
""", | ||
"42"); | ||
} | ||
|
||
[Test] | ||
public void MixedNullableValueType_AndReferenceType() | ||
{ | ||
AssertOutput(""" | ||
var r = M3(42, 1); | ||
System.Console.Write(r.Value); | ||
int? M3(int? i1, object i2) => i1 ?? (int) i2; | ||
""", | ||
"42"); | ||
} | ||
|
||
[TestCase("(int?) o1 ?? (int?) o2")] | ||
[TestCase("(int?) o1 ?? (int) o2")] | ||
public void Convoluted(string coalescingExpression) | ||
{ | ||
AssertOutput($""" | ||
var r = M(42, 1); | ||
System.Console.Write(r.Value); | ||
int? M(object o1, object o2) => {coalescingExpression}; | ||
""", | ||
"42"); | ||
} | ||
|
||
[TestCase(null, null, "C", "C")] | ||
[TestCase(null, "B", null, "B")] | ||
[TestCase(null, "B", "C", "B")] | ||
[TestCase("A", "B", "C", "A")] | ||
[TestCase("A", "B", null, "A")] | ||
public void TestAssociative(string a, string b, string c, string expectedOutput) | ||
{ | ||
AssertOutput($"System.Console.Write({Quote(a)} ?? {Quote(b)} ?? {Quote(c)});", expectedOutput); | ||
|
||
string? Quote(string s) => s == null ? "null" : $"\"{s}\""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.