List<Symbol> arguments = Arrays.<Symbol>asList(
createReference("text", DataTypes.STRING),
pattern,
replacement
);
Function function = createFunction(ReplaceFunction.NAME, DataTypes.STRING, arguments);
ReplaceFunction regexpImpl = (ReplaceFunction) functions.get(function.info().ident());
regexpImpl.compile(arguments);
assertThat(regexpImpl.regexMatcher(), instanceOf(RegexMatcher.class));
assertEquals(expected, regexpImpl.regexMatcher().replace(term, replacement.value()));