This file contains 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
const contains = (pattern, text) => { | |
return text.substr(1).indexOf(pattern) !== -1; | |
}; |
This file contains 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
fc.sample( | |
fc.property( | |
fc.string(), fc.string(), fc.string(), | |
(a, b, c) => contains(b, a+b+c)) | |
); |
This file contains 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
const fc = require('fast-check'); | |
fc.assert( | |
fc.property( | |
fc.string(), fc.string(), fc.string(), | |
(a, b, c) => contains(b, a+b+c)) | |
); |
This file contains 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
'\u{1f431}' // result: '🐱' | |
'\u{1f431}'.length // result: 2 | |
'\u{1f431}'.split('') // result: ['\ud83d', '\udc31'] | |
encodeURIComponent('\u{1f431}') // result: '%F0%9F%90%B1' | |
encodeURIComponent('\u{1f431}'.charAt(0)) // error: URIError: malformed URI sequence |
This file contains 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
fc.assert( | |
fc.property( | |
fc.nat(), | |
n => decompose(n).reduce((acc, cur) => acc*cur, 1) === n)); |
This file contains 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
fc.assert( | |
fc.property( | |
fc.string(), fc.string(), fc.string(), | |
(a, b, c) => contains(b, a + b + c))); |
This file contains 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
fc.assert( | |
fc.property( | |
fc.char(), fc.array(fc.char()).map(d => d.sort()), | |
(c, data) => binaryContains(c, data) === linearContains(c, data))); |
This file contains 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
fc.assert( | |
fc.property( | |
fc.string(), | |
v => unzip(zip(v)) === v)); |
This file contains 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
fc.assert( | |
fc.property( | |
fc.nat(), fc.nat(), | |
(a, b) => lcm(a, b) * gcd(a, b) === a * b)); |
This file contains 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
fc.assert( | |
fc.property( | |
fc.integer(), fc.integer(), | |
(a, b) => a <= b | |
? a <= average(a, b) && average(a, b) <= b | |
: b <= average(a, b) && average(a, b) <= a)); |
OlderNewer