Skip to content

Commit

Permalink
Add two spaces before contract error message fields (Reference sectio…
Browse files Browse the repository at this point in the history
…n 9.2.1).
  • Loading branch information
sstrickl committed Apr 13, 2013
1 parent 3cb555a commit eb12d76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions collects/racket/contract/private/blame.rkt
Expand Up @@ -153,7 +153,7 @@
(define (add-indent s)
(if (null? so-far)
s
(string-append "\n " s)))
(string-append "\n " s)))
(define nxt
(cond
[(eq? 'given: fst) (add-indent
Expand Down Expand Up @@ -190,13 +190,13 @@
(for/list ([context (in-list context)]
[n (in-naturals)])
(format (if (zero? n)
" in: ~a\n"
" ~a\n")
" in: ~a\n"
" ~a\n")
context)))))
(define contract-line (show/write (blame-contract blme) #:alone? #t))
(define at-line (if (string=? source-message "")
#f
(format " at: ~a" source-message)))
(format " at: ~a" source-message)))

(define self-or-not (if (blame-original? blme)
"broke its contract"
Expand All @@ -215,11 +215,11 @@
(define blaming-line
(cond
[(null? (cdr blame-parties))
(format " blaming: ~a" (convert-blame-singleton (car blame-parties)))]
(format " blaming: ~a" (convert-blame-singleton (car blame-parties)))]
[else
(apply
string-append
" blaming multiple parties:"
" blaming multiple parties:"
(for/list ([party (in-list blame-parties)])
(format "\n ~a" (convert-blame-singleton party))))]))

Expand All @@ -228,11 +228,11 @@
(let ([from-positive-message
(show/display
(from-info (blame-positive blme)))])
(format " contract from: ~a" from-positive-message))
(format " contract from: ~a" from-positive-message))
(let ([from-negative-message
(show/display
(from-info (blame-negative blme)))])
(format " contract from: ~a" from-negative-message))))
(format " contract from: ~a" from-negative-message))))

(combine-lines
start-of-message
Expand All @@ -241,7 +241,7 @@
(if context-lines
contract-line
(string-append
" in:"
" in:"
(substring contract-line 5 (string-length contract-line))))
from-line
blaming-line
Expand Down
2 changes: 1 addition & 1 deletion collects/scribblings/reference/contracts.scrbl
Expand Up @@ -1819,7 +1819,7 @@ the @racket[b] argument has been swapped or not (see @racket[blame-swap]).

If @racket[fmt] contains the symbols @racket['given:] or @racket['expected:],
they are replaced like @racket['given:] and @racket['expected:] are, but
the replacements are prefixed with the string @racket["\n "] to conform
the replacements are prefixed with the string @racket["\n "] to conform
to the error message guidelines in @secref["err-msg-conventions"].

}
Expand Down
4 changes: 2 additions & 2 deletions collects/tests/racket/contract-test.rktl
Expand Up @@ -13699,8 +13699,8 @@ so that propagation occurs.
(let* ([blame-pos (contract-eval '(make-blame (srcloc #f #f #f #f #f) #f (λ () 'integer?) 'positive 'negative #t))]
[blame-neg (contract-eval `(blame-swap ,blame-pos))])
(ctest "something ~a" blame-fmt->-string ,blame-neg "something ~a")
(ctest "promised: ~s\n produced: ~e" blame-fmt->-string ,blame-pos '(expected: "~s" given: "~e"))
(ctest "expected: ~s\n given: ~e" blame-fmt->-string ,blame-neg '(expected: "~s" given: "~e"))
(ctest "promised: ~s\n produced: ~e" blame-fmt->-string ,blame-pos '(expected: "~s" given: "~e"))
(ctest "expected: ~s\n given: ~e" blame-fmt->-string ,blame-neg '(expected: "~s" given: "~e"))
(ctest "promised ~s produced ~e" blame-fmt->-string ,blame-pos '(expected "~s" given "~e"))
(ctest "expected ~s given ~e" blame-fmt->-string ,blame-neg '(expected "~s" given "~e")))

Expand Down

0 comments on commit eb12d76

Please sign in to comment.