florence / cover

a code coverage tool for racket
MIT License
38 stars 7 forks source link

Can't cover `syntax` form in syntax class attributes #131

Closed jackfirth closed 7 years ago

jackfirth commented 7 years ago

Given this program:

#lang racket
(require syntax/parse/define
         rackunit)

(begin-for-syntax
  (define-syntax-class stx-class
    (pattern expr:expr
             #:attr attr
             #'(add1 expr))))

(define-simple-macro (foo cls:stx-class) cls.attr)
(check-equal? (foo 5) 6)

Cover reports that the #' element is uncovered. Using(syntax (add1 expr)) doesn't change this.

florence commented 7 years ago

What happens if the you export the macro and use it in a separate file?

florence commented 7 years ago

(and run both files through cover)

jackfirth commented 7 years ago

That seems to fix it! I moved the syntax class definition into a submodule instead of its own file though:

#lang racket
(require syntax/parse/define
         rackunit)

(module stx-class racket/base
  (require (for-template racket/base)
           syntax/parse)
  (provide stx-class)
  (define-syntax-class stx-class
    (pattern expr:expr
             #:attr attr
             #'(add1 expr))))

(require (for-syntax 'stx-class))
(define-simple-macro (foo cls:stx-class) cls.attr)
(check-equal? (foo 5) 6)

Now cover reports no uncovered expressions. Here's an image of the HTML coverage output.

screen shot 2017-01-14 at 10 32 29 pm

Is this the same issue as #130?

florence commented 7 years ago

Marking as duplicate of #133