public void testTailFunction()
{
final TestElement element = TestElement.TYPE.instantiate();
final FunctionContext context = new ModelElementFunctionContext( element );
FunctionResult fr = ExpressionLanguageParser.parse( "${ Value.Tail( 3 ) }" ).evaluate( context );
try
{
assertEquals( "", fr.value() );
element.setValue( "ab" );
assertEquals( "ab", fr.value() );
element.setValue( "abcdefg" );
assertEquals( "efg", fr.value() );
}
finally
{
fr.dispose();
}
fr = ExpressionLanguageParser.parse( "${ Value.Tail( 0 ) }" ).evaluate( context );
try
{
element.setValue( null );
assertEquals( "", fr.value() );
element.setValue( "ab" );
assertEquals( "", fr.value() );
element.setValue( "abcdefg" );
assertEquals( "", fr.value() );
}
finally
{
fr.dispose();
}
fr = ExpressionLanguageParser.parse( "${ Value.Tail( -3 ) }" ).evaluate( context );
try
{
element.setValue( null );
assertEquals( "", fr.value() );
element.setValue( "ab" );
assertEquals( "", fr.value() );
element.setValue( "abcdefg" );
assertEquals( "", fr.value() );
}
finally
{
fr.dispose();
}
}