001 package fj.test.reflect; 002 003 import fj.Effect; 004 import fj.P2; 005 import static fj.data.Array.array; 006 import fj.test.CheckResult; 007 import static fj.test.CheckResult.summary; 008 import static fj.test.reflect.Check.check; 009 010 import static java.lang.Class.forName; 011 import static java.lang.System.exit; 012 import static java.lang.System.out; 013 014 /** 015 * Checks the properties of a class using a standard random generator, standard check parameters and 016 * the given categories. The class name and categories are passed as command line arguments. 017 * 018 * @version %build.number%<br> 019 * <ul> 020 * <li>$LastChangedRevision: 5 $</li> 021 * <li>$LastChangedDate: 2008-12-06 16:49:43 +1000 (Sat, 06 Dec 2008) $</li> 022 * <li>$LastChangedBy: tonymorris $</li> 023 * </ul> 024 */ 025 public final class Main { 026 private Main() { 027 throw new UnsupportedOperationException(); 028 } 029 030 /** 031 * Check the given class and categories. At least one command line argument (the class name) must be 032 * passed or an error message results. 033 * 034 * @param args The class name as the first argument, then zero or more categories. 035 */ 036 public static void main(final String... args) { 037 if(args.length == 0) { 038 System.err.println("<class> [category]*"); 039 //noinspection CallToSystemExit 040 exit(441); 041 } else { 042 try { 043 check(forName(args[0]), array(args).toList().tail()).foreach(new Effect<P2<String, CheckResult>>() { 044 public void e(final P2<String, CheckResult> r) { 045 summary.print(r._2()); 046 out.println(" (" + r._1() + ')'); 047 } 048 }); 049 } catch(ClassNotFoundException e) { 050 System.err.println(e); 051 //noinspection CallToSystemExit 052 exit(144); 053 } 054 } 055 } 056 }