Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 10, 2021 Hypothesis equivalent for D? | ||||
---|---|---|---|---|
| ||||
Hypothesis is a Python library for generating tests. https://hypothesis.readthedocs.io/en/latest/quickstart.html from hypothesis import example, given, strategies as st @given(st.text()) @example("") def test_decode_inverts_encode(s): assert decode(encode(s)) == s What are the equivalent D libraries? |
April 10, 2021 Re: Hypothesis equivalent for D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to James Lu | On 4/10/21 11:47 AM, James Lu wrote:
> Hypothesis is a Python library for generating tests. https://hypothesis.readthedocs.io/en/latest/quickstart.html
>
> from hypothesis import example, given, strategies as st
>
>
> @given(st.text())
> @example("")
> def test_decode_inverts_encode(s):
> assert decode(encode(s)) == s
>
> What are the equivalent D libraries?
Nice idea, thanks for sharing. I don't think there's a D equivalent, and there's a need because there definitely are some instances of ad-hoc solutions in Phobos unittesting. Defining a systematic library for that stuff would be pretty awesome and would cut down a lot of duplication from Phobos.
|
April 12, 2021 Re: Hypothesis equivalent for D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Saturday, 10 April 2021 at 16:57:04 UTC, Andrei Alexandrescu wrote: > Defining a systematic library for that stuff would be pretty awesome and would cut down a lot of duplication from Phobos. In Python, hypothesis is used with icontract, a Design-by-Contract library. Generated testcases are discarded if they don't meet the contract. icontract-hypothesis also has a mode that automatically infers hypothesis testcase generation strategy such that it always satisfies the contract. (!) https://pypi.org/project/icontract-hypothesis/ |
April 13, 2021 Re: Hypothesis equivalent for D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | >> What are the equivalent D libraries? > > Nice idea, thanks for sharing. I don't think there's a D equivalent, Property-based testing in unit-threaded which was based on https://code.dlang.org/packages/std_benchmark |
April 16, 2021 Re: Hypothesis equivalent for D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert burner Schadek | On Tuesday, 13 April 2021 at 06:38:59 UTC, Robert burner Schadek wrote: >>> What are the equivalent D libraries? >> >> Nice idea, thanks for sharing. I don't think there's a D equivalent, > > > Property-based testing in unit-threaded which was based on https://code.dlang.org/packages/std_benchmark Yep, here: https://github.com/atilaneves/unit-threaded/blob/cfdca0af7e40458bec66cfa7e959d4726496be7f/subpackages/property/source/unit_threaded/property.d#L173 |
Copyright © 1999-2021 by the D Language Foundation