(* Auto-tester for slow_trib and trib functions. *) use "tester.sml"; (* common utility functions *) (* Avoid "unbound variable or constructor" errors. *) type bigint = LargeInt.int; fun slow_trib _ _ = raise Undefined; fun trib _ _ = raise Undefined; (* Load file. *) print "\n--> Loading file \"trib.sml\"\n"; use "../trib.sml" handle _ => (); (* Run test cases. *) ( print "\n--> Beginning test cases for function 'slow_trib'...\n"; runtests total grade (slow_trib (~1,0,1)) "slow_trib (~1,0,1)" bigint2string bigint2string (op =) [ (0, 0, "(* base case *)", 0.2), (1, 1, "(* base case *)", 0.2), (2, 0, "(* small recursive case *)", 0.1), (3, 1, "(* small recursive case *)", 0.1), (13, 423, "(* medium recursive case *)", 0.1), (25, 634061, "(* medium recursive case *)", 0.2), (~1, ~1, "(* base case *)", 0.2), (~2, 2, "(* small recursive case *)", 0.1), (~3, ~1, "(* small recursive case *)", 0.1), (~20, 150, "(* medium recursive case *)", 0.2) ]; runtests total grade (slow_trib (8,~3,21)) "slow_trib (8,~3,21)" bigint2string bigint2string (op =) [ (0, ~3, "(* base case *)", 0.2), (1, 21, "(* base case *)", 0.2), (2, 26, "(* small recursive case *)", 0.1), (3, 44, "(* small recursive case *)", 0.1), (13, 21165, "(* medium recursive case *)", 0.1), (25, 31725425, "(* medium recursive case *)", 0.2), (~1, 8, "(* base case *)", 0.2), (~2, 16, "(* small recursive case *)", 0.1), (~3, ~27, "(* small recursive case *)", 0.1), (~20, ~3469, "(* medium recursive case *)", 0.2) ]; print "\n--> Beginning test cases for function 'trib'...\n"; runtests total grade (trib (~1,0,1)) "trib (~1,0,1)" bigint2string bigint2string (op =) [ (0, 0, "(* base case *)", 0.2), (1, 1, "(* base case *)", 0.2), (2, 0, "(* small recursive case *)", 0.1), (3, 1, "(* small recursive case *)", 0.1), (101, 82316850636514866677657075, "(* large recursive case *)", 0.2), (~1, ~1, "(* base case *)", 0.2), (~2, 2, "(* small recursive case *)", 0.1), (~3, ~1, "(* small recursive case *)", 0.1), (~24, ~1404, "(* medium recursive case *)", 0.1), (~101, ~743995515083, "(* large recursive case *)", 0.2) ]; runtests total grade (trib (5,10,15)) "trib (5,10,15)" bigint2string bigint2string (op =) [ (0, 10, "(* base case *)", 0.2), (1, 15, "(* base case *)", 0.2), (2, 30, "(* small recursive case *)", 0.1), (3, 55, "(* small recursive case *)", 0.1), (200, 747053026624259776795659876752332323263498347704443870, "(* large recursive case *)", 0.2), (~1, 5, "(* base case *)", 0.2), (~2, 0, "(* small recursive case *)", 0.1), (~3, 5, "(* small recursive case *)", 0.1), (~101, 25385860649515, "(* large recursive case *)", 0.1), (~500, 2138726963195269960155191826615554344934565379646758120298313514600, "(* larger recursive case *)", 0.2) ] ); (* Print total grade. *) print ("\n--> Grade = " ^ real2string (!grade) ^ " / " ^ real2string (!total) ^ "\n\n"); (* Quit the SML interpreter. *) exit 0;