These are just some straightforward tests. If anyone has others, please post. **Sign up for an account:** http://www.wordpress.com . It’s quick and spam-free!

(* The following are a list of my tests * Each are one line (except a few at the bottom * and DO NOT EXECUTE THE ENTIRE FILE at once. *)letfun(x)f=xin13endletfun(x)f=xinf(13)end(*make sure applying f not just returning 13*)letfun(x)f=7inf(13)end(*tail and nontail*)letfun(x)f=letfun(y)g=xingendin(f(13)) 7end(*binop*)letvalx=4+2inxendletfun(x)f=7inf(13)+5endletfun(x)f=7in5+f(13)endletfun(x)f=letfun(y)g=x+yingendin(f(13)) 7end(*20*)letfun(x)f=letfun(y)g=y+xingendin(f(13)) 7end(*20*)(*anon funcs*)val_=(fn(x)=>x) 13letfun(x)f=(fn(y)=>y+x)in(f(13)) 7end(*Unary funcs*)val_=~(1+3)(*tuple*)letfun(x)f=1+xin(f(13), f(14), f(7), f(5))end(*Subscripts*)val_=#2 (5, 6, 7)(*refs and order-of-eval-in-tuples/binops*)val_=!(ref0)letvalr=ref0val_=(r:=1)val_=(r:=2)in!rend(* Should the following return 1 or 2? *)letvalr=ref1fun(x)setTwo=letval_=(r:=2)in0endin!r+setTwo()end(* Should the following return 1 or 2? *)letvalr=ref1fun(x)setTwo=letval_=(r:=2)in0endinsetTwo()+!rendletvalr=ref1fun(x)two=(r:=2)fun(x)five=(r:=5)in(!r, two(),!r, five(),!r)end(*ifthenelse*)letfun(n)fact=ifn < 1then1elsen*fact(n-1)infact(4)end(*Datatypes*)letfun(x)iotaHelper=(casexof(0,l)=>l|(n,l)=>iotaHelper(n-1,Cons(n,l)))iniotaHelper(3,Nil)end(* Non-exhaustive Case tests: *)letfun(p)test=casepof0=>0in(test 0)end(* at this point you can try test-map.mml * SUGGESTION: change the noisy flag to false (cps-interp.sml line 382) * Otherwise, you'll be sitting around for hours ; ) *)

Advertisements

## Leave a Reply