Skip to content

Instantly share code, notes, and snippets.

@certainty
Created February 28, 2014 16:50
Show Gist options
  • Save certainty/9274655 to your computer and use it in GitHub Desktop.
Save certainty/9274655 to your computer and use it in GitHub Desktop.
quickcheck
my-reverse
✔ is reversable
✔ preserves length
✔ works like the builtin
is verifier
✔ (verify "single line" (is "single line"))
✘ handles differences in strings nicely [ID: 1]
✔ (verify #t)
✔ (verify 3 (is > 0))
pending
☐ (verify (error "I will never be executed")) [Need to fix other stuff first]
handling errors
✘ (verify (error "It handles errors")) [ID: 2]
Pending:
(verify (error "I will never be executed")) is pending
REASON: Need to fix other stuff first
Failed:
1) handles differences in strings nicely
expected: "multiline\ntaxi\nstation"
got: "multiline\ntext"
Diff:
*** actual
--- expected
***************
*** 1,2 ****
multiline
! text
--- 1,3 ----
multiline
! taxi
! station
2) (verify (error "It handles errors"))
It handles errors CONDITION
Kind: exn
Properties:
| location | #f |
| arguments | () |
| message | It handles errors |
Call history:
kvlists.scm:122: map!
kvlists.scm:123: keyword->symbol
kvlists.scm:56: keyword->string
kvlists.scm:56: string->symbol
<eval> (##sys#dynamic-wind swap516 (##core#lambda () (verify (error "It handles errors"))) swap516)
<eval> [swap516] (current-meta-data513518519)
<eval> [swap516] (current-meta-data513518519 g520521 mode517)
<eval> (make-verification-subject535 (quote536 (verify537 (error "It handles errors") (boolean-verifier528)...
<eval> (##sys#make-promise (##core#lambda () (##sys#make-promise (##sys#call-with-values (##core#lambda () ...
<eval> (current-meta-data539)
<eval> (notify540 (run-verification541 (quote536 veritas532542) subject534 (boolean-verifier528) #f))
<eval> (run-verification541 (quote536 veritas532542) subject534 (boolean-verifier528) #f)
<eval> (boolean-verifier528)
<eval> (##sys#make-promise (##sys#call-with-values (##core#lambda () (error "It handles errors")) ##sys#lis......
<eval> (##sys#call-with-values (##core#lambda () (error "It handles errors")) ##sys#list)
<eval> (error "It handles errors") <--
Total: 9 Passed: 6 Pending: 1 Failed: 2
(use veritas-console veritas-quickcheck data-generators)
;; general settings
(use-documentation-formatter)
;; how many examples are generated by quickcheck
(current-sample-size 100)
(group "quickcheck"
(define (my-reverse ls)
(fold cons '() ls))
(group "my-reverse"
(quickcheck (ls (with-size (1 . 5)
(gen-list-of (cut between gen-fixnum 0 10))))
(let ((reversed (my-reverse ls)))
(verify (my-reverse reversed) (is ls) "is reversable")
(verify (length reversed) (is (length ls)) "preserves length")
(verify reversed (is (reverse ls)) "works like the builtin")))))
(group "is verifier"
(verify "single line" (is "single line"))
(verify "multiline\ntext" (is "multiline\ntaxi\nstation") "handles differences in strings nicely")
(verify #t)
(verify 3 (is > 0)))
(group "pending"
(pending "Need to fix other stuff first"
(verify (error "I will never be executed"))))
(group "handling errors"
(verify (error "It handles errors")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment