FunctionLookup { public static FunctionInfo getInfo(String jiffleName, JiffleType ...argTypes) throws UndefinedFunctionException { List<FunctionInfo> fns = lookup.get(jiffleName); if (fns != null) { for (FunctionInfo info : fns) { if (info.matches(jiffleName, argTypes)) { return info; } } } throw new UndefinedFunctionException( String.format( "Undefined function: %s(%s)", jiffleName, Strings.commas((Object[])argTypes) )); }  static boolean isDefined(String jiffleName); static boolean isDefined(String jiffleName, JiffleType ...argTypes); static FunctionInfo getInfo(String jiffleName, JiffleType ...argTypes); static String getRuntimeExpr(String jiffleName, JiffleType ...argTypes); static JiffleType getReturnType(String jiffleName);  }
@Test public void proxyFunctions() throws Exception { System.out.println(" proxy functions"); String[] names = { "x", "y", "width", "height", "size" }; for (String name : names) { FunctionInfo info = FunctionLookup.getInfo(name, null); assertNotNull(info); assertTrue(info.isProxy()); } }
@Test public void oneAndTwoArgFunctions() throws Exception { System.out.println(" alternate one or two arg functions"); String[] names = { "round", "log" }; for (String name : names) { assertNotNull(FunctionLookup.getInfo(name, JiffleType.D)); assertNotNull(FunctionLookup.getInfo(name, JiffleType.D, JiffleType.D)); } }
@Test public void minAndMax() throws Exception { System.out.println(" alternate min and max functions"); String[] names = { "min", "max" }; for (String name : names) { FunctionInfo info = FunctionLookup.getInfo(name, JiffleType.LIST); assertNotNull(info); assertTrue(info.getRuntimeName().contains("_FN.")); info = FunctionLookup.getInfo(name, JiffleType.D, JiffleType.D); assertNotNull(info); assertTrue(info.getRuntimeName().contains("Math.")); } }