Skip to content

Commit b64abe2

Browse files
committed
Add test for #310 - nullable conversion with ignored result
1 parent 682a90e commit b64abe2

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Linq.Expressions;
4+
#if LIGHT_EXPRESSION
5+
using static FastExpressionCompiler.LightExpression.Expression;
6+
namespace FastExpressionCompiler.LightExpression.IssueTests
7+
#else
8+
using static System.Linq.Expressions.Expression;
9+
namespace FastExpressionCompiler.IssueTests
10+
#endif
11+
{
12+
[TestFixture]
13+
public class Issue310_InvalidProgramException_ignored_nullable
14+
{
15+
public int Run()
16+
{
17+
Test1();
18+
Test2();
19+
return 2;
20+
}
21+
22+
[Test]
23+
public void Test1()
24+
{
25+
var p = Parameter(typeof(int), "tmp0");
26+
var expr =
27+
Lambda<Action<int>>(Block(
28+
Convert(p, typeof(int?)),
29+
Default(typeof(void))), p);
30+
31+
var f = expr.CompileFast();
32+
f(2);
33+
}
34+
35+
[Test]
36+
public void Test2()
37+
{
38+
var p = Parameter(typeof(int), "tmp0");
39+
var expr =
40+
Lambda<Action<int>>(Convert(p, typeof(int?)), new[] { p });
41+
var f = expr.CompileFast();
42+
f(2);
43+
}
44+
}
45+
}

test/FastExpressionCompiler.TestsRunner/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ void Run(Func<int> run, string name = null)
226226
Run(new Issue308_Wrong_delegate_type_returned_with_closure().Run);
227227
Run(new FastExpressionCompiler.LightExpression.IssueTests.Issue308_Wrong_delegate_type_returned_with_closure().Run);
228228

229+
Run(new Issue310_InvalidProgramException_ignored_nullable().Run);
230+
Run(new FastExpressionCompiler.LightExpression.IssueTests.Issue310_InvalidProgramException_ignored_nullable().Run);
231+
229232
Console.WriteLine($"============={Environment.NewLine}IssueTests are passing in {sw.ElapsedMilliseconds} ms.");
230233
});
231234

0 commit comments

Comments
 (0)