test.check

Clojure Keywords must begin with a non-digit.

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Per http://clojure.org/reader, Clojure Keywords must begin with a non-numeric character. Currently, test.check generates keywords from strings of alpha-numeric characters, and sometimes the first character is a digit. Although the current reader on the JVM allows it, the ClojureScript reader fails with keywords like :1, :2aa, etc.

Here is the current code:

(def keyword
"Generate keywords."
(->> string-alpha-numeric
(such-that #(not= "" %))
(fmap core/keyword)))

Proposed fix:

(def keyword
"Generate keywords."
(->> (tuple char-alpha string-alpha-numeric)
(fmap #(apply str %))))
(fmap core/keyword)))

char-alpha will need to be defined.

This would also alleviate the need for the such-that to filter out empty strings.

Activity

Hide
Reid Draper added a comment -

+1. Do you have a CA signed, Eric? And would you like to provide a patch? If not, I'd be happy to fix this.

Show
Reid Draper added a comment - +1. Do you have a CA signed, Eric? And would you like to provide a patch? If not, I'd be happy to fix this.
Hide
Eric Normand added a comment -

My CA is filed with Cognitect.

I'll get a patch in today.

Show
Eric Normand added a comment - My CA is filed with Cognitect. I'll get a patch in today.
Hide
Eric Normand added a comment -

better-keywords.diff contains a patch to conform to the reader specs. All tests pass.

Show
Eric Normand added a comment - better-keywords.diff contains a patch to conform to the reader specs. All tests pass.
Hide
Reid Draper added a comment -

Merged in 4528b5ed391d6127b79f4db6bc5e086613da0d81

Show
Reid Draper added a comment - Merged in 4528b5ed391d6127b79f4db6bc5e086613da0d81
Hide
Reid Draper added a comment -

Thanks Eric!

Show
Reid Draper added a comment - Thanks Eric!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: