Skip to content

Instantly share code, notes, and snippets.

@shiqimei
Created August 22, 2020 15:13
Show Gist options
  • Save shiqimei/db734a87c5b96e96eca5bea32537ab60 to your computer and use it in GitHub Desktop.
Save shiqimei/db734a87c5b96e96eca5bea32537ab60 to your computer and use it in GitHub Desktop.
const range = (m, n) => Array(n).fill().map((_, i) => i+1).slice(m-1);
const expect = (input) => ({
toEqual(expected) {
const { stringify } = JSON;
if (stringify(expected) !== stringify(input)) {
throw Error(`expect ${expected} while ${input}`);
} else {
console.info('Pass');
}
}
});
expect(range(1, 2)).toEqual([1, 2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment