Добавил в отчёт примеры функций непроходящих тесты

This commit is contained in:
2024-12-06 18:59:49 +03:00
parent 4bcec8060d
commit a5b624a333

View File

@@ -256,6 +256,27 @@ propFilterByPredicateAlwaysTrue xs =
filterByPredicate (\_ -> True) xs == xs filterByPredicate (\_ -> True) xs == xs
\end{lstlisting} \end{lstlisting}
В листинге~\ref{lst:broken1} представлена реализация функции \texttt{filterByPredicate}, которая не пройдёт ни один из перечисленных тестов. А в листинге~\ref{lst:broken2} представлена реализация, которая не пройдёт два из трёх тестов, первый и третий.
\begin{lstlisting}[caption={Пример реализации функции filterByPredicate, которая не пройдёт ни один тест.}, label={lst:broken1}]
filterByPredicate :: (a -> Bool) -> [a] -> [a]
filterByPredicate _ [] = []
filterByPredicate predicate (x:xs)
| not $ predicate x = x : x : filteredTail
| otherwise = x : x : filteredTail
where
filteredTail = filterByPredicate predicate xs
\end{lstlisting}
\begin{lstlisting}[caption={Пример реализации функции filterByPredicate, которая не пройдёт первый и третий тесты.}, label={lst:broken2}]
filterByPredicate :: (a -> Bool) -> [a] -> [a]
filterByPredicate _ [] = []
filterByPredicate predicate (x:xs)
| not $ predicate x = x : filteredTail
| otherwise = filteredTail
where
filteredTail = filterByPredicate predicate xs
\end{lstlisting}
\subsection{Запуск тестов} \subsection{Запуск тестов}