private IParseTreeValue CreateInspValueFrom(string valAndType, string conformTo = null)
 {
     if (valAndType.Contains(VALUE_TYPE_SEPARATOR))
     {
         var    args         = valAndType.Split(new string[] { VALUE_TYPE_SEPARATOR }, StringSplitOptions.None);
         var    value        = args[0];
         string declaredType = args[1].Equals(string.Empty) ? null : args[1];
         if (conformTo is null)
         {
             if (declaredType is null)
             {
                 return(ValueFactory.Create(value));
             }
             return(ValueFactory.CreateDeclaredType(value, declaredType));
         }
         else
         {
             if (declaredType is null)
             {
                 return(ValueFactory.CreateDeclaredType(value, conformTo));
             }
             return(ValueFactory.CreateDeclaredType(value, declaredType));
         }
     }
     return(conformTo is null?ValueFactory.Create(valAndType)
                : ValueFactory.CreateDeclaredType(valAndType, conformTo));
 }
        public void ParseTreeValueExpressionEvaluator_LikeOperator(string operands, string expected)
        {
            var ops    = operands.Split(new string[] { "_" }, StringSplitOptions.None);
            var LHS    = ValueFactory.CreateDeclaredType(ops[0], Tokens.String);
            var RHS    = ValueFactory.CreateDeclaredType(ops[2], Tokens.String);
            var result = Calculator.Evaluate(LHS, RHS, ops[1]);

            Assert.AreEqual(expected, result.Token, $"{LHS} Like {RHS}");
            Assert.IsTrue(result.ParsesToConstantValue);
        }
        private (IParseTreeValue, IParseTreeValue) TestBinaryOp(string opSymbol, string operands, string expected, string expectedResultTypeName)
        {
            GetBinaryOpValues(operands, out IParseTreeValue LHS, out IParseTreeValue RHS, out _);

            var result = Calculator.Evaluate(LHS, RHS, opSymbol);

            Assert.AreEqual(expectedResultTypeName, result.ValueType);

            if (expectedResultTypeName.Equals(Tokens.Double) || expectedResultTypeName.Equals(Tokens.Single) || expectedResultTypeName.Equals(Tokens.Currency))
            {
                var compareLength = expected.Length > 5 ? 5 : expected.Length;
                var accuracy      = Math.Pow(10, -1.0 * compareLength);
                var lhs           = double.Parse(result.Token.Substring(0, compareLength), CultureInfo.InvariantCulture);
                var rhs           = double.Parse(expected.Substring(0, compareLength), CultureInfo.InvariantCulture);
                Assert.IsTrue(Math.Abs(lhs - rhs) <= accuracy, $"Actual={result.Token} Expected={expected}");
                return(result, result);
            }
            var expectedResult = ValueFactory.CreateDeclaredType(expected, expectedResultTypeName);

            Assert.AreEqual(expectedResult, result);
            return(expectedResult, result);
        }