Skip to content

Instantly share code, notes, and snippets.

const contains = (pattern, text) => {
return text.substr(1).indexOf(pattern) !== -1;
};
fc.sample(
fc.property(
fc.string(), fc.string(), fc.string(),
(a, b, c) => contains(b, a+b+c))
);
const fc = require('fast-check');
fc.assert(
fc.property(
fc.string(), fc.string(), fc.string(),
(a, b, c) => contains(b, a+b+c))
);
'\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
fc.assert(
fc.property(
fc.nat(),
n => decompose(n).reduce((acc, cur) => acc*cur, 1) === n));
fc.assert(
fc.property(
fc.string(), fc.string(), fc.string(),
(a, b, c) => contains(b, a + b + c)));
fc.assert(
fc.property(
fc.char(), fc.array(fc.char()).map(d => d.sort()),
(c, data) => binaryContains(c, data) === linearContains(c, data)));
fc.assert(
fc.property(
fc.string(),
v => unzip(zip(v)) === v));
fc.assert(
fc.property(
fc.nat(), fc.nat(),
(a, b) => lcm(a, b) * gcd(a, b) === a * b));
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));