我目前正在为Matlab实现PBB,不知何故受到假设的影响
我不明白假设如何处理延迟策略的收缩。 文档中有代码片段
import hypothesis.strategies as st
x = st.deferred(lambda: st.booleans() | st.tuples(x, x))
x.example()
>>> (((False, (True, True)), (False, True)), (True, True))
现在,这个例子很可能通过减少递归的深度来缩小。但是,假设如何知道如何操纵lambda以使示例缩小
马西弗博士回答后的问题:
(False,(False,False))
可以构造为10010000
(深度优先)。如果我们将子序列01
(其中第一个0
属于策略booleans
,而不是现在的tuples
),我们将得到示例True
,它可能不算作前者的缩小版本李>
收缩一个延迟的策略与收缩任何其他策略的效果相同,因为在假设中收缩对一个潜在的表示统一起作用,而不需要知道关于所使用的策略的很多信息
假设不是操纵生成的值,而是修改用于构建它们的选择。你可以把这看作是一系列的抛硬币。e、 g.
(True, False)
可能由序列10100
生成,该序列为1
(选择|
的第二个分支),然后是01
,选择第一个分支,然后生成True
和00
,选择第一个分支,然后生成False。我们可以通过用01
替换10100
将(True, False)
减少为True
,或者通过用00
替换False
将(True, False)
减少为True
,这两者都可以作为原始选择序列的子序列如果你想知道更多关于这方面的信息,你可以阅读报纸(或观看演讲):https://2020.ecoop.org/details/ecoop-2020-papers/13/Test-Case-Reduction-via-Test-Case-Generation-Insights-From-the-Hypothesis-Reducer
不,假设没有任何关于选择的“所有权”的特定概念,并且认为
True
是(False, (False, False))
的完全有效的收缩!它毕竟是相当小和简单的相关问题 更多 >
编程相关推荐