Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  function runFunctions(fs) {
  2.     let error;
  3.  
  4.     S.takeWhile(f => {
  5.       error = S.encaseEither(S.I, f, null);
  6.       return error.isRight;
  7.     }, fs);
  8.  
  9.     return error;
  10.   }
  11.  
  12.   function runTests() {
  13.     const functionTester = (name, isError) => {
  14.       return () => {
  15.         console.log("running " + name);
  16.         if (isError) {
  17.           throw new Error(name)
  18.         }
  19.       }
  20.     }
  21.  
  22.     return runFunctions([
  23.       functionTester("one", false),
  24.       functionTester("two", true),
  25.       functionTester("three", false),
  26.       functionTester("four", true),
  27.       functionTester("five", false)
  28.     ]);
  29.   }
  30.  
  31.   const error = runTests();
  32.   error.isLeft ? "got error: " + error.value : "All functions passed!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement