Open joskuijpers opened 10 years ago
I forgot: I took some stuff from node.js util.js, that is: is* functions and an inherit() to make two constructors inherit each other. https://github.com/joskuijpers/Andromeda/blob/master/Andromeda/Resources/JavaScript/util.js
It is much cleaner to use than when writing it yourself (and making mistakes with null
and undefined
).
Because the implementation is bound to javascript, I also put the implementation in util.js.
minisphere includes an assert
module based on the CommonJS specification since v4.1.0. No test
module though.
After I implemented my modules, I also added assert.js and test.js, according to CommonJS/Unit Testing/1.0. It provides a number of assert functions, such as assert(), assert.equal(), assert.deepEqual() and assert.throws(). These can be used to prevent some errors.
Then there is test.js that contains only one function: run(). You provide an object with functions starting with the letters 'test' and it will execute all these. Very nice for making unit tests. In a module, you run the code:
This means that you can include unit tests in your module, and run those tests if your module become the main module. This is how CommonJS describes it.
I think it is a neat little addition that does not cause trouble when added to pegasus but it will advertize good programming style.