}
/** Base case test of NUMERIC literal processing */
public void testAssignLiteralConstantTypes()
{
AbstractExpression lit_dec;
AbstractExpression dec_lit;
AbstractExpression lit;
AbstractExpression dec;
AbstractExpression bint;
// convert NUMERIC to DECIMAL right/left
lit = new ConstantValueExpression();
lit.m_valueType = VoltType.NUMERIC;
lit.m_valueSize = VoltType.NUMERIC.getLengthInBytesForFixedTypes();
dec = new ConstantValueExpression();
dec.m_valueType = VoltType.DECIMAL;
dec.m_valueSize = VoltType.DECIMAL.getLengthInBytesForFixedTypes();
lit_dec = new OperatorExpression(ExpressionType.OPERATOR_PLUS, lit, dec);
ExpressionUtil.assignLiteralConstantTypesRecursively(lit_dec, VoltType.STRING);
assertEquals(lit.m_valueType, VoltType.DECIMAL);
assertEquals(lit.m_valueSize, VoltType.DECIMAL.getLengthInBytesForFixedTypes());
assertEquals(dec.m_valueType, VoltType.DECIMAL);
assertEquals(dec.m_valueSize, VoltType.DECIMAL.getLengthInBytesForFixedTypes());
// convert NUMERIC to DECIMAL (left/right)
lit = new ConstantValueExpression();
lit.m_valueType = VoltType.NUMERIC;
lit.m_valueSize = VoltType.NUMERIC.getLengthInBytesForFixedTypes();
dec = new ConstantValueExpression();
dec.m_valueType = VoltType.DECIMAL;
dec.m_valueSize = VoltType.DECIMAL.getLengthInBytesForFixedTypes();
dec_lit = new OperatorExpression(ExpressionType.OPERATOR_DIVIDE, dec, lit);
ExpressionUtil.assignLiteralConstantTypesRecursively(dec_lit, VoltType.STRING);
assertEquals(lit.m_valueType, VoltType.DECIMAL);
assertEquals(lit.m_valueSize, VoltType.DECIMAL.getLengthInBytesForFixedTypes());
assertEquals(dec.m_valueType, VoltType.DECIMAL);
assertEquals(dec.m_valueSize, VoltType.DECIMAL.getLengthInBytesForFixedTypes());
// convert numeric to float
lit = new ConstantValueExpression();
lit.m_valueType = VoltType.NUMERIC;
lit.m_valueSize = VoltType.NUMERIC.getLengthInBytesForFixedTypes();
bint = new ConstantValueExpression();
bint.m_valueType = VoltType.BIGINT;
bint.m_valueSize = VoltType.BIGINT.getLengthInBytesForFixedTypes();
AbstractExpression lit_bint =
new OperatorExpression(ExpressionType.OPERATOR_MINUS, lit, bint);
ExpressionUtil.assignLiteralConstantTypesRecursively(lit_bint, VoltType.STRING);
assertEquals(lit.m_valueType, VoltType.FLOAT);
assertEquals(lit.m_valueSize, VoltType.FLOAT.getLengthInBytesForFixedTypes());
assertEquals(bint.m_valueType, VoltType.BIGINT);
assertEquals(bint.m_valueSize, VoltType.BIGINT.getLengthInBytesForFixedTypes());
// test a larger tree
lit = new ConstantValueExpression();
lit.m_valueType = VoltType.NUMERIC;
lit.m_valueSize = VoltType.NUMERIC.getLengthInBytesForFixedTypes();
bint = new ConstantValueExpression();
bint.m_valueType = VoltType.DECIMAL;
bint.m_valueSize = VoltType.DECIMAL.getLengthInBytesForFixedTypes();
lit_bint = new OperatorExpression(ExpressionType.OPERATOR_MINUS, lit, bint);
AbstractExpression root = new OperatorExpression(ExpressionType.OPERATOR_MULTIPLY,
lit_bint, new TupleValueExpression());
ExpressionUtil.assignLiteralConstantTypesRecursively(root);
assertEquals(lit.m_valueType, VoltType.DECIMAL);
assertEquals(lit.m_valueSize, VoltType.DECIMAL.getLengthInBytesForFixedTypes());
assertEquals(bint.m_valueType, VoltType.DECIMAL);