public void if_then_expression_infers_type_when_one_value_is_nil() { // nil && 1 var target = new IfThenElseExpression { Test = new BoolLiteral(true), Then = new StringLiteralExpression("\"abc\""), Else = new NullLiteralExpression(), }; AstHelper helper = Mother.CreateRuntime(); var result = target.Compile(helper).Eval <string>(); Assert.AreEqual("abc", result); }
public void if_then_expression_infers_type_and_returns_nil_of_that_type() { // nil && 1 var target = new IfThenElseExpression { Test = new BoolLiteral(false), Then = new StringLiteralExpression("\"abc\""), Else = new NullLiteralExpression(), }; AstHelper helper = Mother.CreateRuntime(); var result = target.Compile(helper).Eval <string>(); Assert.AreEqual(null, result); }