prop_check 0.18.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/run_tests.yaml +3 -2
- data/.tool-versions +1 -1
- data/CHANGELOG.md +8 -2
- data/README.md +11 -10
- data/lib/prop_check/generators.rb +1 -2
- data/lib/prop_check/property/output_formatter.rb +10 -5
- data/lib/prop_check/property.rb +0 -1
- data/lib/prop_check/version.rb +1 -1
- data/prop_check.gemspec +1 -3
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92c7d32ca511178bcd51c8d5583b1e525ce6f7108c875704d956ae3b19b0511d
|
4
|
+
data.tar.gz: ab8bb6b9b44c540938fcab33c4001978c88d380a45efcb5941e9c93a1d62e870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577df1c50915e8c78492f22444183aa84a58297e74044dab6577d5640eff45ff9b541ab694c7a9e6e8833b89794b4f89693b259f3b57b525d9180e7d9652dc27
|
7
|
+
data.tar.gz: f0c9b489e637c589e171a68c35052b1f4403505037d9d1ba99e971ce3ed81af9eafd2f58981a2e2326e0c1d417bdf7456783725ac357b07195f7f48b61931ec1
|
@@ -15,8 +15,9 @@ jobs:
|
|
15
15
|
runs-on: ubuntu-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
# NOTE:
|
19
|
-
|
18
|
+
# NOTE: We're stopping testing Ruby < 3.0 since prop_check version 1.0.0
|
19
|
+
# It will _probably_ still work but as they're end-of-life, no guarantees!
|
20
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
20
21
|
|
21
22
|
steps:
|
22
23
|
- uses: actions/checkout@v3
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
- 1.0.1
|
2
|
+
- Fixes:
|
3
|
+
- The invariants of the of the `min` option for the `array` generator were not checked correctly, sometimes causing arrays with too small lengths to be generated. (c.f. [#26](https://github.com/Qqwy/ruby-prop_check/pull/26). Thank you, @olafura!)
|
4
|
+
- 1.0.0
|
5
|
+
- Changes:
|
6
|
+
- Pretty-print failures using Ruby's builtin `PP`, so `prop_check` no longer depends on the `awesome_print` gem. (c.f. #19)
|
1
7
|
- 0.18.2
|
2
8
|
- Documentation updates:
|
3
|
-
-
|
4
|
-
-
|
9
|
+
- Adding an example of using prop_check with the `test-unit` testing framework to the README. (c.f. #18, thank you, @niku!)
|
10
|
+
- Fixing typos in various parts of the documentation. (c.f. #16, #17, #21. Thank you, @meganemura, @niku and @harlantwood!)
|
5
11
|
- 0.18.1
|
6
12
|
- Fixes:
|
7
13
|
- Compatibility with Ruby 3.2:
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ PropCheck allows you to do Property Testing in Ruby.
|
|
5
5
|
[](https://rubygems.org/gems/prop_check)
|
6
6
|
[](https://github.com/Qqwy/ruby-prop_check/actions/workflows/run_tests.yaml)
|
7
7
|
[](https://codeclimate.com/github/Qqwy/ruby-prop_check/maintainability)
|
8
|
-
[](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/
|
8
|
+
[](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/main/)
|
9
9
|
|
10
10
|
It features:
|
11
11
|
|
@@ -14,6 +14,8 @@ It features:
|
|
14
14
|
- Shrinking to a minimal counter-example on failure.
|
15
15
|
- Hooks to perform extra set-up/cleanup logic before/after every example case.
|
16
16
|
|
17
|
+
It requires _no_ external dependencies, and integrates well with all common test frameworks (see below).
|
18
|
+
|
17
19
|
## What is PropCheck?
|
18
20
|
|
19
21
|
PropCheck is a Ruby library to create unit tests which are simpler to write and more powerful when run, finding edge-cases in your code you wouldn't have thought to look for.
|
@@ -218,16 +220,15 @@ For instance, when a failure happens with the input `x = 100`,
|
|
218
220
|
PropCheck will see if the failure still happens with `x = 50`.
|
219
221
|
If it does , it will try `x = 25`. If not, it will try `x = 75`, and so on.
|
220
222
|
|
221
|
-
This means if something only goes wrong for `x
|
223
|
+
This means for example that if something only goes for wrong for `x >= 8`, the program will try:
|
222
224
|
- `x = 100`(fails),
|
223
225
|
- `x = 50`(fails),
|
224
226
|
- `x = 25`(fails),
|
225
227
|
- `x = 12`(fails),
|
226
|
-
- `x = 6`(
|
227
|
-
- `x =
|
228
|
-
- `x = 1` (succeeds), `x = 2` (fails).
|
228
|
+
- `x = 6`(succeeds), `x = 9` (fails)
|
229
|
+
- `x = 7`(succeeds), `x = 8` (fails).
|
229
230
|
|
230
|
-
and thus the simplified case of `x =
|
231
|
+
and thus the simplified case of `x = 8` is shown in the output.
|
231
232
|
|
232
233
|
The documentation of the provided generators explain how they shrink.
|
233
234
|
A short summary:
|
@@ -239,7 +240,7 @@ A short summary:
|
|
239
240
|
|
240
241
|
### Builtin Generators
|
241
242
|
|
242
|
-
PropCheck comes with [many builtin generators in the PropCheck::Generators](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/
|
243
|
+
PropCheck comes with [many builtin generators in the PropCheck::Generators](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/main/PropCheck/Generators) module.
|
243
244
|
|
244
245
|
It contains generators for:
|
245
246
|
- (any, positive, negative, etc.) integers,
|
@@ -305,8 +306,8 @@ you can use `Generators.frequency` which takes a hash of (integer_frequency => g
|
|
305
306
|
There are even more functions in the `Generator` class and the `Generators` module that you might want to use,
|
306
307
|
although above are the most generally useful ones.
|
307
308
|
|
308
|
-
[PropCheck::Generator documentation](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/
|
309
|
-
[PropCheck::Generators documentation](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/
|
309
|
+
[PropCheck::Generator documentation](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/main/PropCheck/Generator)
|
310
|
+
[PropCheck::Generators documentation](https://www.rubydoc.info/github/Qqwy/ruby-prop_check/main/PropCheck/Generators)
|
310
311
|
|
311
312
|
|
312
313
|
## Usage within Rails / with a database
|
@@ -348,7 +349,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
348
349
|
|
349
350
|
## Code of Conduct
|
350
351
|
|
351
|
-
Everyone interacting in the PropCheck project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Qqwy/ruby-prop_check/blob/
|
352
|
+
Everyone interacting in the PropCheck project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Qqwy/ruby-prop_check/blob/main/CODE_OF_CONDUCT.md).
|
352
353
|
|
353
354
|
## Attribution and Thanks
|
354
355
|
|
@@ -385,8 +385,7 @@ module PropCheck
|
|
385
385
|
end
|
386
386
|
|
387
387
|
private def make_array(element_generator, min, count, uniq)
|
388
|
-
amount = min if count
|
389
|
-
amount = min if count == min && min != 0
|
388
|
+
amount = min if min > (count - min)
|
390
389
|
amount ||= (count - min)
|
391
390
|
|
392
391
|
# Simple, optimized implementation:
|
@@ -1,5 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# @api private
|
3
|
+
require 'pp'
|
4
|
+
|
3
5
|
module PropCheck::Property::OutputFormatter
|
4
6
|
extend self
|
5
7
|
|
@@ -32,10 +34,13 @@ module PropCheck::Property::OutputFormatter
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def print_roots(lazy_tree_val)
|
35
|
-
|
36
|
-
lazy_tree_val[0].
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
data =
|
38
|
+
if lazy_tree_val.is_a?(Array) && lazy_tree_val.length == 1 && lazy_tree_val[0].is_a?(Hash)
|
39
|
+
lazy_tree_val[0]
|
40
|
+
else
|
41
|
+
lazy_tree_val
|
42
|
+
end
|
43
|
+
|
44
|
+
PP.pp(data, '')
|
40
45
|
end
|
41
46
|
end
|
data/lib/prop_check/property.rb
CHANGED
data/lib/prop_check/version.rb
CHANGED
data/prop_check.gemspec
CHANGED
@@ -6,7 +6,7 @@ require "prop_check/version"
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "prop_check"
|
8
8
|
spec.version = PropCheck::VERSION
|
9
|
-
spec.authors = ["Qqwy/
|
9
|
+
spec.authors = ["Qqwy/Marten Wijnja"]
|
10
10
|
spec.email = ["w-m@wmcode.nl"]
|
11
11
|
|
12
12
|
spec.summary = %q{PropCheck allows you to do property-based testing, including shrinking.}
|
@@ -35,6 +35,4 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = ["lib"]
|
36
36
|
|
37
37
|
spec.required_ruby_version = '>= 2.5.1'
|
38
|
-
|
39
|
-
spec.add_dependency 'amazing_print', '~> 1.2'
|
40
38
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prop_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Qqwy/
|
8
|
-
autorequire:
|
7
|
+
- Qqwy/Marten Wijnja
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: amazing_print
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.2'
|
11
|
+
date: 2025-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: PropCheck allows you to do property-based testing, including shrinking.
|
28
14
|
(akin to Haskell's QuickCheck, Erlang's PropEr, Elixir's StreamData). This means
|
29
15
|
that your test are run many times with different, autogenerated inputs, and as soon
|
@@ -69,7 +55,7 @@ metadata:
|
|
69
55
|
homepage_uri: https://github.com/Qqwy/ruby-prop_check/
|
70
56
|
source_code_uri: https://github.com/Qqwy/ruby-prop_check/
|
71
57
|
changelog_uri: https://github.com/Qqwy/ruby-prop_check/CHANGELOG.md
|
72
|
-
post_install_message:
|
58
|
+
post_install_message:
|
73
59
|
rdoc_options: []
|
74
60
|
require_paths:
|
75
61
|
- lib
|
@@ -84,8 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
70
|
- !ruby/object:Gem::Version
|
85
71
|
version: '0'
|
86
72
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
88
|
-
signing_key:
|
73
|
+
rubygems_version: 3.4.19
|
74
|
+
signing_key:
|
89
75
|
specification_version: 4
|
90
76
|
summary: PropCheck allows you to do property-based testing, including shrinking.
|
91
77
|
test_files: []
|