% The old version of the function on new Matlab (>=2008b) wouldn't work on this % new test case, calling rand changed the state of randn in a way it didn't % understand: rand(); reset_all = make_rand_resetter(); u1 = rand; u2 = randn; u3 = rand; reset_all(); u1a = rand; u2a = randn; u3a = rand; testequal([u1, u2, u3], [u1a, u2a, u3a]); %%%%%%%%%%%%%%%%%%%%%%%%% Old tests start here: rand('seed', 0); rand('state', 1); rand('twister', 2); randn('seed', 3); randn('state', 4); rand_resetter = make_rand_resetter(); aa = rand; bb = randn; rand('seed'); cc = rand; rand('state'); dd = rand; randn('seed'); ee = randn; rand('seed', 0); rand('state', 1); rand('twister', 2); randn('seed', 3); randn('state', 4); aa2 = rand; bb2 = randn; rand('seed'); cc2 = rand; rand('state'); dd2 = rand; randn('seed'); ee2 = randn; rand_resetter(); aa3 = rand; bb3 = randn; rand('seed'); cc3 = rand; rand('state'); dd3 = rand; randn('seed'); ee3 = randn; testequal([aa, bb, cc, dd, ee], [aa2, bb2, cc2, dd2, ee2]); testequal([aa, bb, cc, dd, ee], [aa3, bb3, cc3, dd3, ee3]); test_exit