Skip to content

Commit 9c71945

Browse files
committed
[failed #70] ip and numeric lca
1 parent 930c48b commit 9c71945

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

src/Tests/NFun.Tic.Tests/IfThenElse.cs

+40-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace NFun.Tic.Tests;
66
class IfThenElse {
77
[Test(Description = "y = if a: 1 else 0")]
88
public void SolvingSimpleCaseWithIfs() {
9-
//node | 3 0 1 2
9+
//node | 3 0 1 2
1010
//expr |y = if a: 1 else 0;
1111

1212
var graph = new GraphBuilder();
@@ -68,7 +68,7 @@ public void SolvingCaseWithIfs() {
6868
[Test(Description = "y = if (a) x else z ")]
6969
public void CleanGenericOnIfs() {
7070
//node | 3 0 1 2
71-
//expr |y = if (true) x else z
71+
//expr |y = if (true) x else z
7272

7373
var graph = new GraphBuilder();
7474

@@ -87,7 +87,7 @@ public void CleanGenericOnIfs() {
8787
[Test(Description = "y = if (a) x else x ")]
8888
public void DummyGenericOnIfs() {
8989
//node | 3 0 1 2
90-
//expr |y = if (true) x else x
90+
//expr |y = if (true) x else x
9191

9292
var graph = new GraphBuilder();
9393

@@ -106,7 +106,7 @@ public void DummyGenericOnIfs() {
106106
[Test(Description = "y = if (x) x else x ")]
107107
public void IfXxx() {
108108
//node | 3 0 1 2
109-
//expr |y = if (x) x else x
109+
//expr |y = if (x) x else x
110110

111111
var graph = new GraphBuilder();
112112

@@ -122,6 +122,42 @@ public void IfXxx() {
122122
result.AssertNamed(StatePrimitive.Bool, "x", "y");
123123
}
124124

125+
[Test(Description = "y = if (true) 127.0.0.1 else 12")]
126+
public void IfOfIpAndNumeric() {
127+
//node | 3 0 1 2
128+
//expr |y = if (true) 127.0.0.1 else 12;
129+
130+
var graph = new GraphBuilder();
131+
132+
graph.SetConst(0, StatePrimitive.Bool);
133+
graph.SetConst(1, StatePrimitive.Ip);
134+
graph.SetIntConst(2, StatePrimitive.U8);
135+
graph.SetIfElse(new[] { 0 }, new[] { 1, 2 }, 3);
136+
graph.SetDef("y", 3);
137+
var result = graph.Solve();
138+
139+
result.AssertNoGenerics();
140+
result.AssertNamed(StatePrimitive.Any, "y");
141+
}
142+
143+
[Test(Description = "y = if (true) 127.0.0.1 else 12")]
144+
public void IfOfBoolAndNumeric() {
145+
//node | 3 0 1 2
146+
//expr |y = if (true) true else 12;
147+
148+
var graph = new GraphBuilder();
149+
150+
graph.SetConst(0, StatePrimitive.Bool);
151+
graph.SetConst(1, StatePrimitive.Bool);
152+
graph.SetIntConst(2, StatePrimitive.U8);
153+
graph.SetIfElse(new[] { 0 }, new[] { 1, 2 }, 3);
154+
graph.SetDef("y", 3);
155+
var result = graph.Solve();
156+
157+
result.AssertNoGenerics();
158+
result.AssertNamed(StatePrimitive.Any, "y");
159+
}
160+
125161
[Test]
126162
public void If_withMultipleAncestorRules_EquationSolved() {
127163
// 3 0 1 2 4 5 7 6

0 commit comments

Comments
 (0)