|
120 | 120 | (set! initial-space-count pos)]
|
121 | 121 | [else
|
122 | 122 | (line-of-interest)
|
123 |
| - (readerr "expected the first character in the table to be ╔" |
| 123 | + (readerr "expected the first non-whitespace character in the table to be ╔" |
124 | 124 | pos)])]
|
125 | 125 | [else
|
126 | 126 | (line-of-interest)
|
127 | 127 | (readerr "expected some non-whitespace characters in the first line of the table"
|
128 | 128 | 0
|
129 | 129 | pos)]))
|
130 |
| - (let loop ([pos (+ initial-space-count 1)] |
131 |
| - [current-column-width 0] |
132 |
| - [column 0]) |
133 |
| - (cond |
134 |
| - [(< pos (string-length current-line)) |
135 |
| - (case (string-ref current-line pos) |
136 |
| - [(#\╦) |
137 |
| - (add-node column 0) |
138 |
| - (cons current-column-width (loop (+ pos 1) 0 (+ column 1)))] |
139 |
| - [(#\═) (loop (+ pos 1) (+ current-column-width 1) column)] |
140 |
| - [(#\╗) |
141 |
| - (add-node column 0) |
142 |
| - (let loop ([pos (+ pos 1)]) |
143 |
| - (when (< pos (string-length current-line)) |
144 |
| - (cond |
145 |
| - [(char-whitespace? (string-ref current-line pos)) |
146 |
| - (loop (+ pos 1))] |
147 |
| - [else |
148 |
| - (line-of-interest) |
149 |
| - (readerr "expected only whitespace to follow ╗ (on the same line)" pos)])) |
150 |
| - (list current-column-width))])] |
151 |
| - [else |
152 |
| - (line-of-interest) |
153 |
| - (readerr "expected ╗ to terminate the first line" pos)])) |
154 | 130 | (let loop ([pos (+ initial-space-count 1)]
|
155 | 131 | [current-column-width 0]
|
156 | 132 | [column 0]
|
|
575 | 551 | #f)
|
576 | 552 |
|
577 | 553 | (define lines-table (hash-copy all-line-of-interest))
|
| 554 | + |
578 | 555 | (parameterize ([current-lines lines-table])
|
| 556 | + (check-equal? (get-err-locs '("#2d ")) |
| 557 | + (list (srcloc #f 1 0 1 2))) |
579 | 558 | (check-equal? (get-err-locs
|
580 | 559 | '("#2d\n"
|
581 | 560 | " ╔══╦══╗\n"
|
|
592 | 571 | " ╠══╬══╣\n"
|
593 | 572 | " ║ ║ ║\n"
|
594 | 573 | " ╚══╩══╝\n"))
|
595 |
| - (list (srcloc #f 3 4 19 1) |
596 |
| - (srcloc #f 2 4 9 1)))) |
| 574 | + (list (srcloc #f 3 4 19 1))) |
| 575 | + (check-equal? (get-err-locs |
| 576 | + '("#2d\n" |
| 577 | + " ╔══╦══╗\n" |
| 578 | + " ║ ║ ║\n" |
| 579 | + " ╠══╬══╣\n" |
| 580 | + " ║ ║ ║\n" |
| 581 | + " ╚══╩══╝\n")) |
| 582 | + (list (srcloc #f 3 1 16 1))) |
| 583 | + (check-equal? (get-err-locs |
| 584 | + '("#2d\n" |
| 585 | + " ╔══╦══╗\n" |
| 586 | + " ║ ║ ║\n" |
| 587 | + " ╠══╬══\n" |
| 588 | + " ║ ║ ║\n" |
| 589 | + " ╚══╩══╝\n")) |
| 590 | + (list (srcloc #f 4 8 33 1))) |
| 591 | + (check-equal? (get-err-locs |
| 592 | + '("#2d\n" |
| 593 | + " +----+\n" |
| 594 | + " | |\n" |
| 595 | + " +----+\n")) |
| 596 | + (list (srcloc #f 2 2 7 1))) |
| 597 | + (check-equal? (get-err-locs |
| 598 | + '("#2d\n" |
| 599 | + " \n")) |
| 600 | + (list (srcloc #f 2 0 5 3))) |
| 601 | + (check-equal? (get-err-locs |
| 602 | + '("#2d\n" |
| 603 | + " ╔══╦══\n")) |
| 604 | + (list (srcloc #f 2 8 13 1))) |
| 605 | + |
| 606 | + (check-equal? (get-err-locs |
| 607 | + '("#2d\n" |
| 608 | + " ╔══╦══╦═══╗\n" |
| 609 | + " ║ ║ ║ ║\n" |
| 610 | + " ╠══╬══╩═══╣\n" |
| 611 | + " ║ ║ ║\n" |
| 612 | + " ╠══╣ ═ ║\n" |
| 613 | + " ║ ║ ║\n" |
| 614 | + " ╚══╩══════╝\n")) |
| 615 | + (list (srcloc #f 6 8 69 1))) |
| 616 | + ) |
| 617 | + |
597 | 618 | (let ([lines (hash-map lines-table (λ (x y) x))])
|
598 | 619 | (unless (null? lines)
|
599 | 620 | (eprintf "no test case for errors on lines: ~s\n"
|
|
701 | 722 | (module+ main
|
702 | 723 | (define s (string-append
|
703 | 724 | "#2d\n"
|
704 |
| - " ╔══╦══╗\n" |
705 |
| - " ║ ║\n" |
706 |
| - " ╠══╬══╣\n" |
707 |
| - " ║ ║ ║\n" |
708 |
| - " ╚══╩══╝\n")) |
| 725 | + " ╔══╦══╦═══╗\n" |
| 726 | + " ║ ║ ║ ║\n" |
| 727 | + " ╠══╬══╩═══╣\n" |
| 728 | + " ║ ║ ║\n" |
| 729 | + " ╠══╣ ═ ║\n" |
| 730 | + " ║ ║ ║\n" |
| 731 | + " ╚══╩══════╝\n")) |
709 | 732 |
|
710 | 733 | (define p (open-input-string s))
|
711 | 734 | (port-count-lines! p)
|
712 |
| - (with-handlers ((exn:fail:read? exn:fail:read-srclocs)) |
| 735 | + (with-handlers (#;(exn:fail:read? exn:fail:read-srclocs)) |
713 | 736 | (parameterize ([current-readtable rt])
|
714 | 737 | (read p)))
|
715 | 738 | ;; account for the "#2d" that was read from the first line
|
|
0 commit comments