-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathForStatementTests.cs
28 lines (25 loc) · 1000 Bytes
/
ForStatementTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using Cecilifier.Core.Tests.Tests.Unit.Framework;
using NUnit.Framework;
namespace Cecilifier.Core.Tests.Tests.Unit;
[TestFixture]
public class ForStatementTests : CecilifierUnitTestBase
{
[TestCase("parameter++", true)]
[TestCase("local++", true)]
[TestCase("field++", true)]
[TestCase("F()", true)]
[TestCase("localDummy = parameter++", false)]
[TestCase("localDummy = local++", false)]
[TestCase("localDummy = field++", false)]
[TestCase("localDummy = F()", false)]
public void TestForIncrement_IsPopped_IfNotConsumed(string value, bool expectPop)
{
var result = RunCecilifier($@"class C {{ int F() => 0; int field; void M(int parameter) {{ int localDummy; int local = parameter; for(int x = 0; x < 1; {value}); }} }}");
var cecilifiedCode = result.GeneratedCode.ReadToEnd();
Assert.That(
cecilifiedCode,
expectPop
? Does.Contain("Pop")
: Does.Not.Contains("Pop"));
}
}