Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rosylilly/queencheck
like haskell's QuickCheck
https://github.com/rosylilly/queencheck
Last synced: 5 days ago
JSON representation
like haskell's QuickCheck
- Host: GitHub
- URL: https://github.com/rosylilly/queencheck
- Owner: rosylilly
- Created: 2012-01-21T04:52:28.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-05-01T16:22:15.000Z (over 12 years ago)
- Last Synced: 2024-12-22T13:14:56.455Z (15 days ago)
- Language: Ruby
- Homepage: http://rosylilly.github.com/QueenCheck
- Size: 1.56 MB
- Stars: 23
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# QueenCheck [![Build Status](https://secure.travis-ci.org/rosylilly/QueenCheck.png)](http://travis-ci.org/rosylilly/QueenCheck) [![Gem Status](https://gemnasium.com/rosylilly/QueenCheck.png)](https://gemnasium.com/rosylilly/QueenCheck)
QueenCheck is random test library.
Inspired by QuickCheck library in Haskell.
## Usage
$ gem install queencheck
or
$ git clone git://github.com/rosylilly/QueenCheck.git QueenCheck
$ cd QueenCheck
$ bundle install
$ bundle exec rake install## CI Report
[See Travis-CI](http://travis-ci.org/#!/rosylilly/QueenCheck)
## Abstract
let's start DDT(Data Driven Testing)
require 'queencheck'
def plus(x, y)
x + y
endprop_Plus = QueenCheck::Testable.new(Integer, Integer) do | x, y |
plus(x, y) == x + y
end
puts prop_Plus.check.pretty_report
# Tests: 100
# ✓ Successes : 100
# ✗ Failures : 0
# ✷ Exceptions : 0with `exception`, `labeling` and `where`
def div(x, y)
x / y # => raise ZeroDividedError if y == 0
endprop_Div = QueenCheck::Testable.new(Integer, Integer) do | x, y |
div(x, y) == x / y
end
puts prop_Div.check.pretty_report
# Tests: 100
# ✓ Successes : 99
# ✗ Failures : 1
# ✷ Exceptions : 1puts prop_Div.check_with_label(
"x > y" => proc{|x,y| x > y },
"x < y" => proc{|x,y| x < y },
"x = y" => proc{|x,y| x == y },
"x is 0" => proc{|x,y| x.zero? },
"y is 0" => proc{|x,y| y.zero? }
).pretty_report
# Tests: 100
# ✓ Successes : 99
# x > y : 43
# x < y : 56
# x = y : 0
# x is 0 : 0
# y is 0 : 0
# ✗ Failures : 1
# x > y : 0
# x < y : 0
# x = y : 1
# x is 0 : 1
# y is 0 : 1
# ✷ Exceptions : 1
# x > y : 0
# x < y : 0
# x = y : 1
# x is 0 : 1
# y is 0 : 1int_generater = Integer.arbitrary.gen # => QueenCheck::Gen
nonzero_integer = int_generater.where{|num| !num.zero? }
prop_DivSuccess = QueenCheck::Testable.new(nonzero_integer, nonzero_integer) do | x, y |
div(x, y) == x / y
end
puts prop_DivSuccess.check_with_label(
"x > y" => proc{|x,y| x > y },
"x < y" => proc{|x,y| x < y },
"x = y" => proc{|x,y| x == y },
"x is 0" => proc{|x,y| x.zero? },
"y is 0" => proc{|x,y| y.zero? }
).pretty_report
# Tests: 99
# ✓ Successes : 99
# x > y : 55
# x < y : 44
# x = y : 0
# x is 0 : 0
# y is 0 : 0
# ✗ Failures : 0
# x > y : 0
# x < y : 0
# x = y : 0
# x is 0 : 0
# y is 0 : 0
# ✷ Exceptions : 0
# x > y : 0
# x < y : 0
# x = y : 0
# x is 0 : 0
# y is 0 : 0## Help me
please fork [QueenCheck repository](https://github.com/rosylilly/QueenCheck).
__I'm waiting for the code review of you !__