Skip to content

Commit ded6cb1

Browse files
committed
more test cases ...
1 parent 7df363c commit ded6cb1

File tree

1 file changed

+56
-33
lines changed

1 file changed

+56
-33
lines changed

collects/unstable/2d/reader.rkt

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -120,37 +120,13 @@
120120
(set! initial-space-count pos)]
121121
[else
122122
(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 ╔"
124124
pos)])]
125125
[else
126126
(line-of-interest)
127127
(readerr "expected some non-whitespace characters in the first line of the table"
128128
0
129129
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)]))
154130
(let loop ([pos (+ initial-space-count 1)]
155131
[current-column-width 0]
156132
[column 0]
@@ -575,7 +551,10 @@
575551
#f)
576552

577553
(define lines-table (hash-copy all-line-of-interest))
554+
578555
(parameterize ([current-lines lines-table])
556+
(check-equal? (get-err-locs '("#2d "))
557+
(list (srcloc #f 1 0 1 2)))
579558
(check-equal? (get-err-locs
580559
'("#2d\n"
581560
" ╔══╦══╗\n"
@@ -592,8 +571,50 @@
592571
" ╠══╬══╣\n"
593572
" ║ ║ ║\n"
594573
" ╚══╩══╝\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+
597618
(let ([lines (hash-map lines-table (λ (x y) x))])
598619
(unless (null? lines)
599620
(eprintf "no test case for errors on lines: ~s\n"
@@ -701,15 +722,17 @@
701722
(module+ main
702723
(define s (string-append
703724
"#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"))
709732

710733
(define p (open-input-string s))
711734
(port-count-lines! p)
712-
(with-handlers ((exn:fail:read? exn:fail:read-srclocs))
735+
(with-handlers (#;(exn:fail:read? exn:fail:read-srclocs))
713736
(parameterize ([current-readtable rt])
714737
(read p)))
715738
;; account for the "#2d" that was read from the first line

0 commit comments

Comments
 (0)