Last active
August 29, 2015 14:10
-
-
Save nberger/489db687c3c98e400fc7 to your computer and use it in GitHub Desktop.
Rantly - Towards improving shrinking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
require 'rantly/shrinks' | |
require 'rantly/testunit_extensions' | |
class PropertyShrinking < Test::Unit::TestCase | |
def setup | |
Rantly.gen.reset | |
end | |
should "be able to shrink an array of ints towards smaller int elements" do | |
property_of { | |
array { positive_integer } | |
}.check { |arr| | |
assert arr.all? { |i| i == 0 } | |
} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ruby -Itest test/property_with_shrink_test.rb -n "/shrink an array of ints towards smaller int elements/" | |
# current shrink output | |
# ======================== | |
failure: 0 tests, on: | |
[1453699108680333782, 1619720976417280257, 1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
found a reduced failure case: | |
[726849554340166890, 1619720976417280257, 1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
found a reduced failure case: | |
[363424777170083444, 1619720976417280257, 1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
... | |
found a reduced failure case: | |
[1290, 1619720976417280257, 1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
... | |
found a reduced failure case: | |
[0, 0, 0, 0, 15898, 2295738168544629080] | |
... | |
found a reduced failure case: | |
[0, 0, 0, 0, 0, 1] | |
found a reduced success: | |
[0, 0, 0, 0, 0, 0] | |
minimal failed data is: | |
[0, 0, 0, 0, 0, 1] | |
1) Failure: | |
RantlyTest::Shrinking#test_: Rantly::Shrinking should be able to shrink an array of ints towards smaller int elements. [test/property_with_shrink_test.rb:26]: | |
Failed assertion, no message given. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ruby -Itest test/property_with_shrink_test.rb -n "/shrink an array of ints towards smaller int elements/" | |
# desired shrink output | |
# ======================== | |
failure: 0 tests, on: | |
[1453699108680333782, 1619720976417280257, 1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
found a reduced failure case: | |
[1619720976417280257, 1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
found a reduced failure case: | |
[1182423061134533425, 1641371618241291156, 1118829741216353398, 2295738168544629080] | |
found a reduced failure case: | |
[1641371618241291156, 1118829741216353398, 2295738168544629080] | |
found a reduced failure case: | |
[1118829741216353398, 2295738168544629080] | |
found a reduced success: | |
[2295738168544629080] | |
found a reduced failure case: | |
[214882974121635, 2295738168544629080] | |
found a reduced failure case: | |
[6153297412, 2295738168544629080] | |
... | |
found a reduced failure case: | |
[57, 435] | |
... | |
found a reduced failure case: | |
[1] | |
found a reduced success: | |
[0] | |
minimal failed data is: | |
[1] | |
1) Failure: | |
RantlyTest::Shrinking#test_: Rantly::Shrinking should be able to shrink an array of ints towards smaller int elements. [test/property_with_shrink_test.rb:26]: | |
Failed assertion. First failure: | |
[1507395846795238915, 2272427556804198336, -338939259755974401, -935990783988399133, 857239857720980257, -1756669130252341556] | |
Smallest shrunk failure: | |
[0,0] | |
Reduced shrunk success: | |
[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ruby -Itest test/property_with_shrink_test.rb -n "/shrink an array of ints towards smaller int elements/" | |
# desired shrink output | |
# ======================== | |
failure: 0 tests, on: | |
[2, 1] | |
found a reduced failure case: | |
[1] | |
found a reduced success: | |
[0] | |
minimal failed data is: | |
[1] | |
1) Failure: | |
RantlyTest::Shrinking#test_: Rantly::Shrinking should be able to shrink an array of ints towards smaller int elements. [test/property_with_shrink_test.rb:26]: | |
Failed assertion. First failure: | |
[2, 1] | |
Smallest: | |
[1] | |
Reduced shrunk success: | |
[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'clojure.test) | |
(require '[clojure.test.check :as tc] | |
'[clojure.test.check.generators :as gen] | |
'[clojure.test.check.clojure-test :as ct :refer (defspec)] | |
'[clojure.test.check.properties :as prop]) | |
(defspec int-vec-is-all-zero | |
(prop/for-all [v (gen/vector gen/pos-int)] | |
(is (every? zero? v)))) | |
(int-vec-is-all-zero) | |
;; OUTPUT | |
""" | |
FAIL in clojure.lang.PersistentList$EmptyList@1 (form-init8374541921464517868.clj:3) | |
expected: (every? zero? v) | |
actual: (not | |
(every? | |
#<core$zero_QMARK_ clojure.core$zero_QMARK_@28164824> | |
[1 0])) | |
FAIL in clojure.lang.PersistentList$EmptyList@1 (form-init8374541921464517868.clj:3) | |
expected: (every? zero? v) | |
actual: (not | |
(every? | |
#<core$zero_QMARK_ clojure.core$zero_QMARK_@28164824> | |
[1])) | |
{:result false, :seed 1417441962891, :failing-size 2, :num-tests 3, :fail [[1 0]], :shrunk {:total-nodes-visited 4, :depth 1, :result false, :smallest [[1]]}} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment