I'm a bit surprised by a sentence found in the book Clojure Programming (1st [and only as I write this!?] edition), page 78:It should be obvious that it's impossible to deterministically test a  function that depends upon a random number generatorWell, to me it's not obvious at all.First in the context the book definitely talks about a PRNG (that sentence just follows a mention of java.util.Random, which is a PRNG), not a real random source.Seen that functional languages that do support higher-order function can be, well, passed functions...  Why not simply pass the random generator function itself to the function you want to be able to deterministically test?If I've got something like the following function (it's just an example) and the PRNG itself is deterministic, why would it be impossible to deterministically test the following function:(defn shuffle-deck [deck  last-generated-number   prngf]      ...)I realize that instead of keeping a (global?) reference to your random generator, you need to keep a reference to the last generated number (and update it accordingly) but that's basically it.You can then test/reproduce the behaviour of any function using a PRNG as long as you pass the PRNG and 'the random number you're currently at'.It's not unlike deterministic game engines (like Blizzard's Warcraft III) where the replays only contains the player inputs, the time at which they happened and the overall seed to the PRNG.Basically I'm a bit confused: I've always seen PRNG as something that is not real randomness and I've got the impression that functional languages accepting higher-order function make it particularly easy to reproduce behavior of functions depending on PRNG.So, is that sentence of the book (which I found a great book btw) complete rubbish?  I sure do not find it obvious at all...
Determinism of functions using PRNG in Clojure and functional languages
functional programming;clojure;random;higher order functions
It depends on what the author had in mind when they made the statement. You're certainly correct that by using a deterministic PRNG, you can then test functions which are deterministic other than the PRNG they use. On the other hand, if what you're testing depends on the PRNG having some behavior common to them (like having at least a certain period or a particular distribution) and your test PRNG does not provide those behaviors, you'll break your tests (or at least neuter them).In general though, I would consider the sentence to be incorrect. It's commonplace to use deterministic PRNG's to deterministically test functions that use them as input.