3 ms·
pattern-matching in arguments means that the picking the function according to its signature is the actual decision process? If you have a function that doesn't
by ofrzeta 5y ago
pattern-matching in arguments means that the picking the function according to its signature is the actual decision process? If you have a function that doesn't contain a decision it is easier to unit test, isn't it?
- innocentoldguy 5y agoNo. It's the same. If you have a function with a large if statement in it, you'd want to test all conditions within that if statement to make sure it was working, right? You'd do the exact same thing if you were testing a series of pattern-matched functions. The tests would be unchanged either way.
- jkhdigital 5y agoI think it makes it easier to tick off the list of cases that need to be tested: one for each head.
- ofrzeta 5y agoYou'd have the number of tests broadly but they are simpler because they don't need to handle the cases hidden in the functions themselves. Maybe in the end it's the same or a matter of taste but it recently occurred to me that unit testing becomes "cleaner" that way.