@@ -6,7 +6,7 @@ namespace NFun.Tic.Tests;
6
6
class IfThenElse {
7
7
[ Test ( Description = "y = if a: 1 else 0" ) ]
8
8
public void SolvingSimpleCaseWithIfs ( ) {
9
- //node | 3 0 1 2
9
+ //node | 3 0 1 2
10
10
//expr |y = if a: 1 else 0;
11
11
12
12
var graph = new GraphBuilder ( ) ;
@@ -68,7 +68,7 @@ public void SolvingCaseWithIfs() {
68
68
[ Test ( Description = "y = if (a) x else z " ) ]
69
69
public void CleanGenericOnIfs ( ) {
70
70
//node | 3 0 1 2
71
- //expr |y = if (true) x else z
71
+ //expr |y = if (true) x else z
72
72
73
73
var graph = new GraphBuilder ( ) ;
74
74
@@ -87,7 +87,7 @@ public void CleanGenericOnIfs() {
87
87
[ Test ( Description = "y = if (a) x else x " ) ]
88
88
public void DummyGenericOnIfs ( ) {
89
89
//node | 3 0 1 2
90
- //expr |y = if (true) x else x
90
+ //expr |y = if (true) x else x
91
91
92
92
var graph = new GraphBuilder ( ) ;
93
93
@@ -106,7 +106,7 @@ public void DummyGenericOnIfs() {
106
106
[ Test ( Description = "y = if (x) x else x " ) ]
107
107
public void IfXxx ( ) {
108
108
//node | 3 0 1 2
109
- //expr |y = if (x) x else x
109
+ //expr |y = if (x) x else x
110
110
111
111
var graph = new GraphBuilder ( ) ;
112
112
@@ -122,6 +122,42 @@ public void IfXxx() {
122
122
result . AssertNamed ( StatePrimitive . Bool , "x" , "y" ) ;
123
123
}
124
124
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
+
125
161
[ Test ]
126
162
public void If_withMultipleAncestorRules_EquationSolved ( ) {
127
163
// 3 0 1 2 4 5 7 6
0 commit comments