public void testNormalizeSymbol() throws Exception {
List<Symbol> arguments = Arrays.<Symbol>asList(
Literal.newLiteral("foobarbequebaz bar"),
Literal.newLiteral(".*(ba).*")
);
Function function = createFunction(MatchesFunction.NAME, DataTypes.STRING, arguments);
MatchesFunction regexpImpl = (MatchesFunction) functions.get(function.info().ident());
Symbol result = regexpImpl.normalizeSymbol(function);
BytesRef[] expected = new BytesRef[]{ new BytesRef("ba") };
assertLiteralSymbol(result, expected, new ArrayType(DataTypes.STRING));
arguments = Arrays.<Symbol>asList(
createReference("text", DataTypes.STRING),
Literal.newLiteral(".*(ba).*")
);
function = createFunction(MatchesFunction.NAME, DataTypes.STRING, arguments);
regexpImpl = (MatchesFunction) functions.get(function.info().ident());
result = regexpImpl.normalizeSymbol(function);
assertThat(result, instanceOf(Function.class));
assertThat((Function)result, is(function));
}