Unit testing private methods in functional inheritance
<p>I just read this great book on Test-Driven Development for Javascript, and in there he mentioned an amazing way of creating objects with private members, originally created by Douglas Crockford, that is called "functional inheritance". It goes like this:</p>

<pre><code>    this.funcInh = function() {
        var privateString = "functional inheritance";

        function setPrivateString(string) {
            privateString = string;
        }

        function getPrivateString() {
            return privateString;
        }

        return {
            setPrivateString: setPrivateString,
            getPrivateString: getPrivateString
        };
    };
</code></pre>

<p>While i really love this way of creating objects, I'm wondering how on earth i can test it, other than testing the return value of the privileged functions 'setPrivateString' and 'getPrivateString'. This is just an example, but I can't really see any way to test "private" functions or that the privileged functions call the functions they should... Any ideas?</p>
