@Test
public void testExternalFunctionDefinition() {

    String inputExpression = "{ trigonometric cosine : function( angle ) external {"
                   + "    java : {"
                   + "        class : \"java.lang.Math\","
                   + "        method signature : \"cos(double)\""
                   + "    }"
                   + "}}";
    BaseNode ctxbase = parse( inputExpression );
    assertThat( ctxbase, is( instanceOf( ContextNode.class ) ) );
    assertThat( ctxbase.getText(), is( inputExpression ) );
    ContextNode ctx = (ContextNode) ctxbase;
    assertThat( ctx.getEntries().size(), is( 1 ) );
    ContextEntryNode entry = ctx.getEntries().get( 0 );
    assertThat( entry.getName(), is( instanceOf( NameDefNode.class ) ) );
    NameDefNode name = (NameDefNode) entry.getName();
    assertThat( name.getText(), is("trigonometric cosine") );
    assertThat( entry.getValue(), is( instanceOf( FunctionDefNode.class ) ) );
    assertThat( entry.getValue().getText(), is("function( angle ) external {"
                                             + "    java : {"
                                             + "        class : \"java.lang.Math\","
                                             + "        method signature : \"cos(double)\""
                                             + "    }"
                                             + "}" ) );
    FunctionDefNode cos = (FunctionDefNode) entry.getValue();
    assertThat( cos.getFormalParameters().size(), is( 1 ) );
    assertThat( cos.getFormalParameters().get( 0 ).getText(), is( "angle" ) );
    assertThat( cos.isExternal(), is( true ) );
    assertThat( cos.getBody(), is( instanceOf( ContextNode.class ) ) );
    ContextNode body = (ContextNode) cos.getBody();
    assertThat( body.getEntries().size(), is( 1 ) );
    ContextEntryNode java = body.getEntries().get( 0 );
    assertThat( java.getName().getText(), is( "java" ) );
    assertThat( java.getValue(), is( instanceOf( ContextNode.class ) ) );
    ContextNode def = (ContextNode) java.getValue();
    assertThat( def.getEntries().size(), is( 2 ) );
    assertThat( def.getEntries().get( 0 ).getName().getText(), is( "class" ) );
    assertThat( def.getEntries().get( 0 ).getValue(), is( instanceOf( StringNode.class ) ) );
    assertThat( def.getEntries().get( 0 ).getValue().getText(), is( "\"java.lang.Math\"" ) );
    assertThat( def.getEntries().get( 1 ).getName().getText(), is( "method signature" ) );
    assertThat( def.getEntries().get( 1 ).getValue(), is( instanceOf( StringNode.class ) ) );
    assertThat( def.getEntries().get( 1 ).getValue().getText(), is( "\"cos(double)\"" ) );
}