Bir grup gerçek bir test-case
ve check-equal?
işlevinin bir makroda tanımlandığı bir dizi site testi oluşturuyorum. AncakRackUnit makrolar içinde kaynak konumu
#lang racket
(require rackunit
rackunit/text-ui)
(define-syntax (my-test=? stx)
(syntax-case stx()
[(_ case1 case2)
(syntax/loc stx
(test-case "tests"
(check-equal? case1 case2)))]))
(define tests
(test-suite "tests"
(my-test=? 'a 'b)))
(run-tests tests)
Ben şu çıktıyı almak bu kodu çalıştırdığınızda: Kod şöyle görünür
hat 11 makro içcheck-equal?
fonksiyonunun hattıdır
--------------------
tests > tests
tests
FAILURE
name: check-equal?
location: unsaved-editor:11:9
actual: 'a
expected: 'b
. Check failure
--------------------
0 success(es) 1 failure(s) 0 error(s) 1 test(s) run
: (check-equal? case1 case2)))]))
my-test=?
'un kullanıldığı satırdaki hatayı göstermek için herhangi bir yol gösterebilir miyim? (my-test=? 'a 'b)))
?
Evet, bu [beni daha önce düşürdü] (http://www.greghendershott.com/2014/01/using-syntax-loc.html). Belgelerindeki "anında sözdizimi nesnesi" ifadesi önemli! –