के अंदर रैकयूनीट स्रोत स्थान मैं रैकुनिट परीक्षणों का एक सेट बना रहा हूं, जहां वास्तविक test-case
और check-equal?
फ़ंक्शन को मैक्रो में परिभाषित किया गया है। कोड इस तरह दिखता है:मैक्रोज़
#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)
हालांकि, जब मैं इस कोड मैं निम्नलिखित आउटपुट प्राप्त चलाएँ:
--------------------
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
कहाँ लाइन 11 मैक्रो के अंदर check-equal?
समारोह की लाइन है: (check-equal? case1 case2)))]))
क्या कोई तरीका है कि मैं उस लाइन पर त्रुटि दिखाने के लिए rackunit कर सकता हूं जहां my-test=?
उपयोग किया जाता है: (my-test=? 'a 'b)))
?
हां, यह [मुझे पहले से बाहर चला गया है] (http://www.greghendershott.com/2014/01/using-syntax-loc.html)। यह दस्तावेज में "तत्काल वाक्यविन्यास वस्तु" वाक्यांश महत्वपूर्ण है! –