(sources)
| 13 | } |
| 14 | |
| 15 | format(sources) { |
| 16 | let str = "Error: " + this.message; |
| 17 | if (this.location) { |
| 18 | let src = null; |
| 19 | const st = sources.find(s => s.source === this.location.source); |
| 20 | if (st) { |
| 21 | src = st.text.split(/\r\n|\n|\r/g); |
| 22 | } |
| 23 | const s = this.location.start; |
| 24 | const offset_s = (this.location.source && (typeof this.location.source.offset === "function")) |
| 25 | ? this.location.source.offset(s) |
| 26 | : s; |
| 27 | const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; |
| 28 | if (src) { |
| 29 | const e = this.location.end; |
| 30 | const filler = "".padEnd(offset_s.line.toString().length, " "); |
| 31 | const line = src[s.line - 1]; |
| 32 | const last = s.line === e.line ? e.column : line.length + 1; |
| 33 | const hatLen = (last - s.column) || 1; |
| 34 | str += "\n --> " + loc + "\n" |
| 35 | + filler + " |\n" |
| 36 | + offset_s.line + " | " + line + "\n" |
| 37 | + filler + " | " + "".padEnd(s.column - 1, " ") |
| 38 | + "".padEnd(hatLen, "^"); |
| 39 | } else { |
| 40 | str += "\n at " + loc; |
| 41 | } |
| 42 | } |
| 43 | return str; |
| 44 | } |
| 45 | |
| 46 | static buildMessage(expected, found) { |
| 47 | function hex(ch) { |
no outgoing calls
no test coverage detected