Compile partial global function to function object

Add a test case for using Apply().