(options)
| 57 | } |
| 58 | |
| 59 | async function tests(options) { |
| 60 | const repl = new REPLServer({ |
| 61 | prompt: PROMPT, |
| 62 | stream: new REPLStream(), |
| 63 | ignoreUndefined: true, |
| 64 | useColors: true, |
| 65 | ...options |
| 66 | }); |
| 67 | |
| 68 | repl.inputStream.run([ |
| 69 | 'function foo(x) { return x; }', |
| 70 | 'function koo() { console.log("abc"); }', |
| 71 | 'a = undefined;', |
| 72 | ]); |
| 73 | |
| 74 | const testCases = [{ |
| 75 | input: 'foo', |
| 76 | noPreview: '[Function: foo]', |
| 77 | preview: [ |
| 78 | 'foo', |
| 79 | '\x1B[90m[Function: foo]\x1B[39m\x1B[11G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r', |
| 80 | '\x1B[36m[Function: foo]\x1B[39m', |
| 81 | ] |
| 82 | }, { |
| 83 | input: 'koo', |
| 84 | noPreview: '[Function: koo]', |
| 85 | preview: [ |
| 86 | 'k\x1B[90moo\x1B[39m\x1B[9G', |
| 87 | '\x1B[90m[Function: koo]\x1B[39m\x1B[9G\x1B[1A\x1B[1B\x1B[2K\x1B[1A' + |
| 88 | '\x1B[0Ko\x1B[90mo\x1B[39m\x1B[10G', |
| 89 | '\x1B[90m[Function: koo]\x1B[39m\x1B[10G\x1B[1A\x1B[1B\x1B[2K\x1B[1A' + |
| 90 | '\x1B[0Ko', |
| 91 | '\x1B[90m[Function: koo]\x1B[39m\x1B[11G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r', |
| 92 | '\x1B[36m[Function: koo]\x1B[39m', |
| 93 | ] |
| 94 | }, { |
| 95 | input: 'a', |
| 96 | noPreview: 'repl > ', // No "undefined" output. |
| 97 | preview: ['a\r'] // No "undefined" preview. |
| 98 | }, { |
| 99 | input: " { b: 1 }['b'] === 1", |
| 100 | noPreview: '\x1B[33mtrue\x1B[39m', |
| 101 | preview: [ |
| 102 | " { b: 1 }['b']", |
| 103 | '\x1B[90m1\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ', |
| 104 | '\x1B[90m1\x1B[39m\x1B[23G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1', |
| 105 | '\x1B[90mtrue\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r', |
| 106 | '\x1B[33mtrue\x1B[39m', |
| 107 | ] |
| 108 | }, { |
| 109 | input: "{ b: 1 }['b'] === 1;", |
| 110 | noPreview: '\x1B[33mfalse\x1B[39m', |
| 111 | preview: [ |
| 112 | "{ b: 1 }['b']", |
| 113 | '\x1B[90m1\x1B[39m\x1B[21G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ', |
| 114 | '\x1B[90m1\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1', |
| 115 | '\x1B[90mtrue\x1B[39m\x1B[27G\x1B[1A\x1B[1B\x1B[2K\x1B[1A;', |
| 116 | '\x1B[90mfalse\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r', |
no test coverage detected
searching dependent graphs…