( input: string, compilerOutput: string | null, evaluatorOutput: string | null, logs: string | null, errorMessage: string | null, )
| 19 | const SPROUT_SEPARATOR = '\n### Eval output\n'; |
| 20 | |
| 21 | export function writeOutputToString( |
| 22 | input: string, |
| 23 | compilerOutput: string | null, |
| 24 | evaluatorOutput: string | null, |
| 25 | logs: string | null, |
| 26 | errorMessage: string | null, |
| 27 | ) { |
| 28 | // leading newline intentional |
| 29 | let result = ` |
| 30 | ## Input |
| 31 | |
| 32 | ${wrapWithTripleBackticks(input, 'javascript')} |
| 33 | `; // trailing newline + space internional |
| 34 | |
| 35 | if (compilerOutput != null) { |
| 36 | result += ` |
| 37 | ## Code |
| 38 | |
| 39 | ${wrapWithTripleBackticks(compilerOutput, 'javascript')} |
| 40 | `; |
| 41 | } else { |
| 42 | result += '\n'; |
| 43 | } |
| 44 | |
| 45 | if (logs != null) { |
| 46 | result += ` |
| 47 | ## Logs |
| 48 | |
| 49 | ${wrapWithTripleBackticks(logs, null)} |
| 50 | `; |
| 51 | } |
| 52 | |
| 53 | if (errorMessage != null) { |
| 54 | result += ` |
| 55 | ## Error |
| 56 | |
| 57 | ${wrapWithTripleBackticks(errorMessage.replace(/^\/.*?:\s/, ''))} |
| 58 | \n`; |
| 59 | } |
| 60 | result += ` `; |
| 61 | if (evaluatorOutput != null) { |
| 62 | result += SPROUT_SEPARATOR + evaluatorOutput; |
| 63 | } |
| 64 | return result; |
| 65 | } |
| 66 | |
| 67 | export type TestResult = { |
| 68 | actual: string | null; // null == input did not exist |
no test coverage detected