* Called by every test/demo * @param name - the name of this test. * @param makeTable - a function which builds the table under test. Also, The contents of this function will be printed. * @param expected - The expected result. * @param screenshot - If present, there is an image contain
(name, makeTable, expected, screenshot)
| 101 | * @param screenshot - If present, there is an image containing a screenshot of the output |
| 102 | */ |
| 103 | function printExample(name, makeTable, expected, screenshot) { |
| 104 | let code = makeTable.toString().split('\n').slice(1, -2).join('\n'); |
| 105 | |
| 106 | logName(name); |
| 107 | if (screenshot && logScreenShot) { |
| 108 | logScreenShot(screenshot); |
| 109 | } else { |
| 110 | logTable(makeTable().toString()); |
| 111 | } |
| 112 | logCode(code); |
| 113 | logSeparator('\n'); |
| 114 | } |
| 115 | |
| 116 | fn(printExample); |
| 117 | } |