test.check

Are the map bindings in gen/let actually solving a problem?

Details

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

Description

I just discovered that the problem that the map binding form in gen/let was meant to solve is apparently not as big a problem as I thought, and possibly isn't a problem at all. It warrants more investigation before committing to that syntax in the final release.

The generator below shrinks just fine despite using bind, probably because the generators are independent and we pass the same immutable RNG in to the second phase when shrinking.

(def gen-keyword-and-number
  (gen/let [kw gen/keyword
            num gen/large-integer]
    {:keyword kw
     :number  num}))

(t.c/quick-check
 10000
 (prop/for-all [{:keys [keyword number]} gen-keyword-and-number]
   (prn keyword number)
   (not= number 42)))
{:result false, 
 :result-data {}, 
 :seed 1507768190347, 
 :failing-size 42, 
 :num-tests 5043, 
 :fail [{:keyword :+-V??:2A:31:*L?6--:t_S:h9, :number 42}], 
 :shrunk {:total-nodes-visited 13, :depth 7, :result false, :result-data {}, :smallest [{:keyword :A, :number 42}]}}

Activity

Hide
Gary Fredericks added a comment -

I added a test to validate my suspicions here, and reverted the original change here.

Show
Gary Fredericks added a comment - I added a test to validate my suspicions here, and reverted the original change here.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: