Tests and types

Brent has some thoughts on strong and weakly typed programming languages. Starting point: a simple function that needs testing:

rgbToHex(red, green, blue) {
    // …
}

Testing the result the function should return is easy. But what about edge cases?

What happens though if we pass doubles instead of integers? Or numbers outside of the allowed range? What about null? Or strings Or the wrong amount of arguments? Or a combination of the above?

Ah, the starting point for a nice article … (and no, requiring ints is not a bulletproof solution)

Tests and types →

🔥 Be sure to also check out Brent’s podcast Rant With Brent.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.