This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Fizzbuzz : (k: Nat) -> Type where | |
Fizz : (k: Nat) -> IsFizz k -> Not (IsBuzz k) -> Fizzbuzz k |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let card = deckOfCardsObject.getNextCard(someStep) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cardIndex = cardIndex + someStep | |
if (cardIndex > cards.length) { | |
cardIndex = 0 | |
} | |
let card = cards[cardIndex] | |
// Use of a modulo would be simpler and less error-prone. | |
cardIndex = (cardIndex + someIndex) % deckOfCards.length | |
let card = deckOfCards[cardIndex] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let foundAnimal | |
for (animal in animals) { | |
if (animal.type === 'cat') { | |
foundAnimal = animal | |
break; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isCat = animal => animal.type === 'cat' | |
let foundAnimal = animals.some(isCat) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let foundAnimal | |
let i = 0 | |
while (i <= animals.length && !foundAnimal) { | |
if (animals[i].type === 'cat') { | |
foundAnimal = animals[i] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function needs only one test | |
function hardToTest() { | |
let data = requestExternalServer() | |
let lang = persistence.get(data.id)) | |
let langToUpdate = makeLangToUpdate(lang) | |
return persistence.update(data.id, langToUpdate) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hardToTest() { | |
let data = requestExternalServer() // hard to test | |
let lang = persistence.get(data.id)) // hard to test | |
// below pure transformation logic | |
let langToUpdate = {}; | |
versionsLangs.map((versionLang) => { | |
let restPath = versionLang.entity.toRestPath(); | |
lang.dates.langsDates.map(datePayload => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hardToTest() { | |
let data = callToDependency() | |
let result = easyToTestPureFunction(data) | |
let dataOther = callToDependency2(result) | |
} | |
function easyToTestPureFunction(data) { | |
// | |
// pure logic | |
// pure logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hardToTest() { | |
let data = callToDependency() | |
// | |
// pure logic | |
// pure logic | |
// pure logic | |
// | |
let dataOther = callToDependency2(result) | |
} |