Beispiel #1
0
        public void ExpressionFactoryDecimal_SuccessfullyCreates_ConstantDecimalExpression_Test()
        {
            //Arrange
            var constantDecimal = new ConstantDecimal <IContext>(1.23m);
            //Act
            var sut = _expressions.Decimal(1.23m);

            //Assert
            Assert.True(sut.Interpret(_context) == constantDecimal.Interpret(_context));
        }
		// BaseType: FuncIdent | NUMBER | QUOTE   - note certain types are restricted in expressions
		private void MatchBaseType(out IExpr result)
		{
			if (MatchFuncIDent(out result))
				return;

			switch (curToken.Type)
			{
				case TokenTypes.NUMBER:
					result = new ConstantDecimal(curToken.Value);
					break;
				case TokenTypes.DATETIME:
					result = new ConstantDateTime(curToken.Value);
					break;
				case TokenTypes.DOUBLE:
					result = new ConstantDouble(curToken.Value);
					break;
				case TokenTypes.INTEGER:
					result = new ConstantInteger(curToken.Value);
					break;
				case TokenTypes.QUOTE:
					result = new ConstantString(curToken.Value);
					break;
				default:
					throw new ParserException("Constant or Identifier expected but not found.  Found '" + curToken.Value + "'  At column " + Convert.ToString(curToken.StartCol));
			}
			curToken = tokens.Extract();

			return;
		}