{"id":474820,"date":"2025-09-12T21:02:39","date_gmt":"2025-09-12T21:02:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=474820"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=474820","title":{"rendered":"<span>\u0422\u0438\u043f\u044b \u0438 \u0442\u0435\u0441\u0442\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/h2>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e <a href=\"https:\/\/habr.com\/ru\/companies\/testops_tms\/articles\/935476\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/a> \u044f \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u043f\u043e\u0434\u0445\u043e\u0434 &#171;\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435&#187; (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B0_%D1%87%D0%B5%D1%80%D0%B5%D0%B7_%D1%82%D0%B5%D1%81%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\" rel=\"noopener noreferrer nofollow\">TDD<\/a>); \u0441\u0435\u0439\u0447\u0430\u0441 \u0436\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0442 \u0433\u0443\u0440\u0443 TDD, \u0420\u043e\u0431\u0435\u0440\u0442\u0430 \u041c\u0430\u0440\u0442\u0438\u043d\u0430, \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u043b\u0438\u044f\u0435\u0442 (\u0438\u043b\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442) \u043d\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f!<\/p>\n<h2>\u0422\u0438\u043f\u044b \u0438 \u0442\u0435\u0441\u0442\u044b<\/h2>\n<p>\u0423 \u043d\u0430\u0441 \u0441 \u041c\u0430\u0440\u043a\u043e\u043c \u0421\u0438\u043c\u0430\u043d\u043e\u043c \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0430\u0441\u044c \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f \u0432 \u0441\u0435\u0442\u0438. \u0412\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0441 \u043c\u043e\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p>\u201c\u041e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0434\u0435\u0442\u044c\u0441\u044f. \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u043b\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438 \u044d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438\u201d.<\/p>\n<p>\u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u043c\u043d\u043e\u0433\u0438\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u0434 \u044d\u0442\u0438\u043c \u0442\u0432\u0438\u0442\u043e\u043c \u0433\u0440\u0443\u0431\u044b\u0435 \u0438\/\u0438\u043b\u0438 \u043e\u0441\u043a\u043e\u0440\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u042d\u0442\u0438 \u043b\u044e\u0434\u0438 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442. \u0410 \u0432\u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u044b \u041c\u0430\u0440\u043a\u0430 \u0431\u044b\u043b\u0438 \u0443\u0432\u0430\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438. \u0421\u043f\u043e\u0440 \u043d\u0430\u0447\u0430\u043b\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>\u201c\u041f\u0440\u0438 \u0432\u0441\u0451\u043c \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0438, \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 null-\u0441\u0441\u044b\u043b\u043a\u0438. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442, \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <code>null<\/code>.<\/p>\n<p>\u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0442\u0438\u043f\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Haskell) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>null<\/code> \u043d\u0435\u0442. \u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432 \u043d\u0438\u0445 \u043d\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u0448\u044c\u201d.<\/p>\n<p>\u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0430\u0441\u044c \u0433\u043e\u0440\u044f\u0447\u0430\u044f \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043f\u043e\u0443\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u0435\u0451 \u0432\u0435\u0442\u043a\u0430\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0445\u043e\u0447\u0443 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u041c\u0430\u0440\u043a\u0430. \u041e\u043d \u0441\u043e\u0441\u043b\u0430\u043b\u0441\u044f \u043d\u0430 \u0441\u0432\u043e\u0439 <a href=\"https:\/\/blog.ploeh.dk\/2018\/07\/09\/typing-and-testing-problem-23\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442<\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0435\u0449\u0451 \u0432 2018 \u0433\u043e\u0434\u0443. \u042f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e. \u0412\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043c\u043d\u043e\u0433\u043e\u0435 \u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 Haskell. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043f\u043e\u0440\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \ud83d\ude09<\/p>\n<p>\u041c\u0430\u0440\u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0432 \u0441\u0432\u043e\u0451\u043c \u0431\u043b\u043e\u0433\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e: <code>rndselect(n,list)<\/code>. \u041e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 n \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u041e\u043d \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 Haskell \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432, QuickCheck \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u0442-\u0444\u0430\u043a\u0442\u0443\u043c \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e: \u0430 \u043a\u0430\u043a \u0431\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Clojure), \u0438 \u0441\u0442\u0440\u043e\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 TDD?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043c.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0441\u0442 \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e.<\/p>\n<pre><code>(deftest random-element-selection \u00a0\u00a0(testing \"degenerate case\" \u00a0\u00a0\u00a0(is (= [] (random-elements 0 []))) \u00a0\u00a0\u00a0(is (= [] (random-elements 0 [1]))) \u00a0\u00a0\u00a0(is (= [] (random-elements 1 []))) \u00a0\u00a0\u00a0))  (defn random-elements [n xs] \u00a0\u00a0[])<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043e\u0441\u0442\u0430 \u041c\u0430\u0440\u043a \u043e\u0442\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044e \u0438\u0437 \u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u0435\u043c\u0443 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u0437\u044f\u0442\u044b \u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u041d\u043e \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0438 \u0442\u0435\u0441\u0442\u044b \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b, \u0435\u0441\u043b\u0438 \u044f \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<pre><code>(testing \"trivial cases\" \u00a0\u00a0(is (= [1] (random-elements 1 [1]))))  (defn random-elements [n xs] \u00a0\u00a0(if (or (&lt; n 1) (empty? xs)) \u00a0\u00a0\u00a0\u00a0[] \u00a0\u00a0\u00a0\u00a0[(first xs)]))<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u044f \u0441\u043b\u0435\u0434\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e\u0431\u043e \u0432\u0441\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430, \u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u0430\u0447\u0438\u0432\u0430\u044e\u0441\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e: &#171;\u0421\u043b\u043e\u043d\u0430 \u0435\u0434\u044f\u0442 \u043f\u043e \u043a\u0443\u0441\u043e\u0447\u043a\u0430\u043c&#187;. \u041d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u0439\u0442\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043b\u044c\u0448\u0435 \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u0446\u0435\u043d\u0442\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041d\u0430\u0447\u0438\u043d\u0430\u0439\u0442\u0435 \u0441 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0445, \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0437\u044f\u0442\u044c\u0441\u044f, \u2014 \u044d\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c, \u043c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u043e\u0434\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c.<\/p>\n<pre><code>(testing \"repetitive case\" \u00a0\u00a0\u00a0\u00a0(is (= [1 1] (random-elements 2 [1]))))  (defn generate-indices [n] \u00a0\u00a0(repeat n 0))  (defn random-elements [n xs] \u00a0\u00a0(if (or (&lt; n 1) (empty? xs)) \u00a0\u00a0\u00a0\u00a0[] \u00a0\u00a0\u00a0\u00a0(map #(nth xs %) (generate-indices n))))<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0441\u043a\u0430\u0436\u0435\u0442\u0435, \u0447\u0442\u043e \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0431\u0435\u0436\u0430\u043b \u0432\u043f\u0435\u0440\u0451\u0434. \u042f \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0432\u044b\u0437\u043e\u0432 <code>first<\/code> \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 <code>nth<\/code>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430. \u041f\u043e\u0447\u0435\u043c\u0443? <em>\u041f\u043e\u0436\u0438\u043c\u0430\u044e \u043f\u043b\u0435\u0447\u0430\u043c\u0438<\/em>.\u00a0<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u2014 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e. \u0411\u044b\u043b\u043e \u0431\u044b \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442 \u043d\u0443\u043b\u044f, \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u043a \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430. \u042f \u0440\u0430\u0437\u043e\u0431\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>generate-indices<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>with-bindings<\/code> \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>index<\/code> \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 1. \u0410 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>^:dynamic<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0432 Clojure, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u043a\u0430\u0442\u044c (\u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c) \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<pre><code>(testing \"singular random case\"   (with-bindings {#'index (fn [] 1)}     (is (= [2] (random-elements 1 [1 2])))))  (testing \"repeated random case\"     (with-bindings {#'index (fn [] 1)}       (is (= [2 2] (random-elements 2 [1 2])))))  (defn ^:dynamic index []   0)  (defn generate-indices [n]   (repeatedly n index))  (defn random-elements [n xs]   (if (or (&lt; n 1) (empty? xs))     []     (map #(nth xs %) (generate-indices n)))) <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>rand-int<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0430 10 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 [0 10 20 30], \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 300.<\/p>\n<pre><code>(testing \"random selection\"   (let [ns (random-elements 10 [0 10 20 30])         sum (reduce + ns)]     (is (&lt; 0 sum 300))))  (defn ^:dynamic index [limit]   (rand-int limit))  (defn generate-indices [n limit]   (repeatedly n (partial index limit)))  (defn random-elements [n xs]   (if (or (&lt; n 1) (empty? xs))     []     (map #(nth xs %) (generate-indices n (count xs)))))<\/code><\/pre>\n<p>\u0428\u0430\u043d\u0441\u044b \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u0441\u044f, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043a \u043e\u0434\u043d\u043e\u043c\u0443. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0442 \u0448\u0430\u043d\u0441 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0448\u043f\u0438\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>random-int<\/code>. \u041d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0431\u0435\u0437\u0440\u0430\u0437\u043b\u0438\u0447\u0435\u043d \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0442\u0435\u0441\u0442\u044b, \u0433\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<pre><code>(testing \"trivial cases\"   (is (= [1] (random-elements 1 [1]))))  (testing \"repetitive case\"   (is (= [:x :x] (random-elements 2 [:x]))))  (testing \"singular random case\"   (with-bindings {#'index (fn [_] 1)}     (is (= ['b'] (random-elements 1 ['a' 'b'])))))  (testing \"repeated random case\"   (with-bindings {#'index (fn [_] 1)}     (is (= [\"two\" \"two\"] (random-elements 2 [\"one\" \"two\"])))))<\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0412 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 8 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041e\u0434\u043d\u0430\u043a\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 TDD. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0439, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438? \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u044c. \u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, 4 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u042f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438; \u043d\u043e, \u0441\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043e\u043d\u0438 \u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b.<\/p>\n<p>\u0410 \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0441 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438? \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c: <code>(random-elements -23 nil)<\/code>? \u0414\u043e\u043b\u0436\u0435\u043d \u043b\u0438 \u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432?<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b. \u042d\u0442\u043e \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f; \u043d\u043e \u043a\u043e\u0434 \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439. \u0414\u043b\u044f <code>nil<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041c\u0435\u043d\u044f \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442. \u042d\u0442\u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0442\u044c \u0442\u0438\u043f\u044b, \u043f\u043e\u043b\u0443\u0447\u0438\u0448\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0440\u0438\u0441\u043a\u0430? \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438 TDD, \u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0451 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 <em>\u0432\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u0442\u0435 \u0432 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e nil \u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442. <\/em>\u0412\u044b \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0439\u0442\u0435 \u043a\u0430\u043a \u0437\u043d\u0430\u0435\u0442\u0435, \u0430 \u044f \u043c\u043e\u0433\u0443 \u0441\u0435\u0431\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u0421\u0443\u0442\u044c<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0438 \u0441\u0443\u0442\u044c \u0441\u043f\u043e\u0440\u0430 \u043c\u0435\u0436\u0434\u0443 \u041c\u0430\u0440\u043a\u043e\u043c \u0438 \u043c\u043d\u043e\u0439. \u042f \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0415\u0441\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u043d\u0438 \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0438 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430. \u0422\u043e\u0447\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u043b \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u0430: &#171;\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435, \u0430 \u043d\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a.&#187; \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u042f \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0431\u044b\u043b \u0431\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u0430 \u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043b\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<p>\u041c\u0430\u0440\u043a \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0438\u043f\u043e\u0432 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u0437\u0430\u043a\u043e\u043d\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c\u044b\u043c\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u0445 \u0438\u0437 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <code>nil<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 <code>nil<\/code> \u2014 \u0434\u0430 \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041c\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f <code>nil<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e <code>nil<\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d. \u041c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c\u044b\u043c\u0438, \u0435\u0441\u043b\u0438 \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b.<\/p>\n<h3>\u041e \u0447\u0451\u043c \u0431\u0438\u0448\u044c \u043c\u044b&#8230;<\/h3>\n<p>\u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a <code>random-elements<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u041c\u0430\u0440\u043a \u0438 \u044f (\u0438 \u0435\u0441\u043b\u0438 \u0432\u044b, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043c\u0435\u043d\u044f, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435 Haskell), \u044f \u0434\u0443\u043c\u0430\u044e, \u0432\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0447\u0451\u043c-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0438. \u0410 \u0432\u043e\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435.<\/p>\n<p>\u0422\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0431\u043e\u0442\u0438\u043b\u043e \u043f\u043e\u0447\u0442\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 TDD, \u0442\u0435\u0441\u0442\u044b \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0432\u0435\u0434\u0443\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.\u00a0<\/p>\n<p>\u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u041c\u0430\u0440\u043a \u0431\u044b\u043b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0437\u0430\u0431\u043e\u0447\u0435\u043d \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u0415\u0433\u043e \u043c\u044b\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u044b\u043b \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043d\u044f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0430 \u0431\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. \u0417\u0430\u0442\u0435\u043c \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 QuickCheck \u0438 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041a\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0443\u0447\u0448\u0435?<\/p>\n<p>&#171;\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 <em>\u044d\u0442\u043e\u0442<\/em> \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u043e\u0438 \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f.&#187; &#8212; \u0411\u0430\u0440\u0430\u043a \u041e\u0431\u0430\u043c\u0430.<\/p>\n<p>\u0423 \u043a\u043e\u0433\u043e \u0438\u0437 \u043d\u0430\u0441 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432? \u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u041d\u043e \u0432 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b 8 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0430 \u041c\u0430\u0440\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 QuickCheck \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0442\u0440\u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430 \u043f\u043e\u0441\u0442-\u0444\u0430\u043a\u0442\u0443\u043c. \u0417\u043d\u0430\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0448 \u0441\u0447\u0451\u0442 \u2014 5:8? \u0410 \u043c\u043e\u0436\u0435\u0442, \u0442\u0435\u0441\u0442\u044b QuickCheck \u0441\u0442\u043e\u0438\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0447\u043a\u043e\u0432? \u042f \u043d\u0435 \u0437\u043d\u0430\u044e. \u0420\u0435\u0448\u0430\u0442\u044c \u0432\u0430\u043c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/944422\/\"> https:\/\/habr.com\/ru\/articles\/944422\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/h2>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e <a href=\"https:\/\/habr.com\/ru\/companies\/testops_tms\/articles\/935476\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/a> \u044f \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u043f\u043e\u0434\u0445\u043e\u0434 &#171;\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435&#187; (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D0%B7%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B0_%D1%87%D0%B5%D1%80%D0%B5%D0%B7_%D1%82%D0%B5%D1%81%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\" rel=\"noopener noreferrer nofollow\">TDD<\/a>); \u0441\u0435\u0439\u0447\u0430\u0441 \u0436\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0442 \u0433\u0443\u0440\u0443 TDD, \u0420\u043e\u0431\u0435\u0440\u0442\u0430 \u041c\u0430\u0440\u0442\u0438\u043d\u0430, \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u043b\u0438\u044f\u0435\u0442 (\u0438\u043b\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442) \u043d\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f!<\/p>\n<h2>\u0422\u0438\u043f\u044b \u0438 \u0442\u0435\u0441\u0442\u044b<\/h2>\n<p>\u0423 \u043d\u0430\u0441 \u0441 \u041c\u0430\u0440\u043a\u043e\u043c \u0421\u0438\u043c\u0430\u043d\u043e\u043c \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0430\u0441\u044c \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f \u0432 \u0441\u0435\u0442\u0438. \u0412\u0441\u0451 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0441 \u043c\u043e\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p>\u201c\u041e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0434\u0435\u0442\u044c\u0441\u044f. \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u043b\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e, \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0438 \u044d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438\u201d.<\/p>\n<p>\u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u043c\u043d\u043e\u0433\u0438\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u0434 \u044d\u0442\u0438\u043c \u0442\u0432\u0438\u0442\u043e\u043c \u0433\u0440\u0443\u0431\u044b\u0435 \u0438\/\u0438\u043b\u0438 \u043e\u0441\u043a\u043e\u0440\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u042d\u0442\u0438 \u043b\u044e\u0434\u0438 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442. \u0410 \u0432\u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u044b \u041c\u0430\u0440\u043a\u0430 \u0431\u044b\u043b\u0438 \u0443\u0432\u0430\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438. \u0421\u043f\u043e\u0440 \u043d\u0430\u0447\u0430\u043b\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>\u201c\u041f\u0440\u0438 \u0432\u0441\u0451\u043c \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0438, \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 null-\u0441\u0441\u044b\u043b\u043a\u0438. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442, \u043a\u0430\u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <code>null<\/code>.<\/p>\n<p>\u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0442\u0438\u043f\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Haskell) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>null<\/code> \u043d\u0435\u0442. \u042d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432 \u043d\u0438\u0445 \u043d\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u0448\u044c\u201d.<\/p>\n<p>\u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0430\u0441\u044c \u0433\u043e\u0440\u044f\u0447\u0430\u044f \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043f\u043e\u0443\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u0435\u0451 \u0432\u0435\u0442\u043a\u0430\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0445\u043e\u0447\u0443 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u041c\u0430\u0440\u043a\u0430. \u041e\u043d \u0441\u043e\u0441\u043b\u0430\u043b\u0441\u044f \u043d\u0430 \u0441\u0432\u043e\u0439 <a href=\"https:\/\/blog.ploeh.dk\/2018\/07\/09\/typing-and-testing-problem-23\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442<\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0435\u0449\u0451 \u0432 2018 \u0433\u043e\u0434\u0443. \u042f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e. \u0412\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043c\u043d\u043e\u0433\u043e\u0435 \u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 Haskell. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043f\u043e\u0440\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \ud83d\ude09<\/p>\n<p>\u041c\u0430\u0440\u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0432 \u0441\u0432\u043e\u0451\u043c \u0431\u043b\u043e\u0433\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e: <code>rndselect(n,list)<\/code>. \u041e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 n \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u041e\u043d \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 Haskell \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432, QuickCheck \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u0442-\u0444\u0430\u043a\u0442\u0443\u043c \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e: \u0430 \u043a\u0430\u043a \u0431\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Clojure), \u0438 \u0441\u0442\u0440\u043e\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 TDD?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043c.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0441\u0442 \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e.<\/p>\n<pre><code>(deftest random-element-selection \u00a0\u00a0(testing \"degenerate case\" \u00a0\u00a0\u00a0(is (= [] (random-elements 0 []))) \u00a0\u00a0\u00a0(is (= [] (random-elements 0 [1]))) \u00a0\u00a0\u00a0(is (= [] (random-elements 1 []))) \u00a0\u00a0\u00a0))  (defn random-elements [n xs] \u00a0\u00a0[])<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043e\u0441\u0442\u0430 \u041c\u0430\u0440\u043a \u043e\u0442\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044e \u0438\u0437 \u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u0435\u043c\u0443 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u0437\u044f\u0442\u044b \u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u041d\u043e \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0438 \u0442\u0435\u0441\u0442\u044b \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b, \u0435\u0441\u043b\u0438 \u044f \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<pre><code>(testing \"trivial cases\" \u00a0\u00a0(is (= [1] (random-elements 1 [1]))))  (defn random-elements [n xs] \u00a0\u00a0(if (or (&lt; n 1) (empty? xs)) \u00a0\u00a0\u00a0\u00a0[] \u00a0\u00a0\u00a0\u00a0[(first xs)]))<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u044f \u0441\u043b\u0435\u0434\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e\u0431\u043e \u0432\u0441\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430, \u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u0430\u0447\u0438\u0432\u0430\u044e\u0441\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e: &#171;\u0421\u043b\u043e\u043d\u0430 \u0435\u0434\u044f\u0442 \u043f\u043e \u043a\u0443\u0441\u043e\u0447\u043a\u0430\u043c&#187;. \u041d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u0439\u0442\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043b\u044c\u0448\u0435 \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u0446\u0435\u043d\u0442\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041d\u0430\u0447\u0438\u043d\u0430\u0439\u0442\u0435 \u0441 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0445, \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0437\u044f\u0442\u044c\u0441\u044f, \u2014 \u044d\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c, \u043c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u043e\u0434\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c.<\/p>\n<pre><code>(testing \"repetitive case\" \u00a0\u00a0\u00a0\u00a0(is (= [1 1] (random-elements 2 [1]))))  (defn generate-indices [n] \u00a0\u00a0(repeat n 0))  (defn random-elements [n xs] \u00a0\u00a0(if (or (&lt; n 1) (empty? xs)) \u00a0\u00a0\u00a0\u00a0[] \u00a0\u00a0\u00a0\u00a0(map #(nth xs %) (generate-indices n))))<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0441\u043a\u0430\u0436\u0435\u0442\u0435, \u0447\u0442\u043e \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0431\u0435\u0436\u0430\u043b \u0432\u043f\u0435\u0440\u0451\u0434. \u042f \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0432\u044b\u0437\u043e\u0432 <code>first<\/code> \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 <code>nth<\/code>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430. \u041f\u043e\u0447\u0435\u043c\u0443? <em>\u041f\u043e\u0436\u0438\u043c\u0430\u044e \u043f\u043b\u0435\u0447\u0430\u043c\u0438<\/em>.\u00a0<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u2014 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e. \u0411\u044b\u043b\u043e \u0431\u044b \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442 \u043d\u0443\u043b\u044f, \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u043a \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430. \u042f \u0440\u0430\u0437\u043e\u0431\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>generate-indices<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>with-bindings<\/code> \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>index<\/code> \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 1. \u0410 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>^:dynamic<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0432 Clojure, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u043a\u0430\u0442\u044c (\u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c) \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<pre><code>(testing \"singular random case\"   (with-bindings {#'index (fn [] 1)}     (is (= [2] (random-elements 1 [1 2])))))  (testing \"repeated random case\"     (with-bindings {#'index (fn [] 1)}       (is (= [2 2] (random-elements 2 [1 2])))))  (defn ^:dynamic index []   0)  (defn generate-indices [n]   (repeatedly n index))  (defn random-elements [n xs]   (if (or (&lt; n 1) (empty? xs))     []     (map #(nth xs %) (generate-indices n)))) <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>rand-int<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0430 10 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 [0 10 20 30], \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 300.<\/p>\n<pre><code>(testing \"random selection\"   (let [ns (random-elements 10 [0 10 20 30])         sum (reduce + ns)]     (is (&lt; 0 sum 300))))  (defn ^:dynamic index [limit]   (rand-int limit))  (defn generate-indices [n limit]   (repeatedly n (partial index limit)))  (defn random-elements [n xs]   (if (or (&lt; n 1) (empty? xs))     []     (map #(nth xs %) (generate-indices n (count xs)))))<\/code><\/pre>\n<p>\u0428\u0430\u043d\u0441\u044b \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u0441\u044f, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043a \u043e\u0434\u043d\u043e\u043c\u0443. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0442 \u0448\u0430\u043d\u0441 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0448\u043f\u0438\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>random-int<\/code>. \u041d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0431\u0435\u0437\u0440\u0430\u0437\u043b\u0438\u0447\u0435\u043d \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0442\u0435\u0441\u0442\u044b, \u0433\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b.<\/p>\n<pre><code>(testing \"trivial cases\"   (is (= [1] (random-elements 1 [1]))))  (testing \"repetitive case\"   (is (= [:x :x] (random-elements 2 [:x]))))  (testing \"singular random case\"   (with-bindings {#'index (fn [_] 1)}     (is (= ['b'] (random-elements 1 ['a' 'b'])))))  (testing \"repeated random case\"   (with-bindings {#'index (fn [_] 1)}     (is (= [\"two\" \"two\"] (random-elements 2 [\"one\" \"two\"])))))<\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0412 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 8 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041e\u0434\u043d\u0430\u043a\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 TDD. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0439, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438? \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u044c. \u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, 4 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u042f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438; \u043d\u043e, \u0441\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043e\u043d\u0438 \u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b.<\/p>\n<p>\u0410 \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0441 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438? \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c: <code>(random-elements -23 nil)<\/code>? \u0414\u043e\u043b\u0436\u0435\u043d \u043b\u0438 \u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432?<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b. \u042d\u0442\u043e \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f; \u043d\u043e \u043a\u043e\u0434 \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439. \u0414\u043b\u044f <code>nil<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041c\u0435\u043d\u044f \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442. \u042d\u0442\u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0442\u044c \u0442\u0438\u043f\u044b, \u043f\u043e\u043b\u0443\u0447\u0438\u0448\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0440\u0438\u0441\u043a\u0430? \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438 TDD, \u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u0451 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 <em>\u0432\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u0442\u0435 \u0432 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e nil \u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442. <\/em>\u0412\u044b \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0439\u0442\u0435 \u043a\u0430\u043a \u0437\u043d\u0430\u0435\u0442\u0435, \u0430 \u044f \u043c\u043e\u0433\u0443 \u0441\u0435\u0431\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u0421\u0443\u0442\u044c<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0438 \u0441\u0443\u0442\u044c \u0441\u043f\u043e\u0440\u0430 \u043c\u0435\u0436\u0434\u0443 \u041c\u0430\u0440\u043a\u043e\u043c \u0438 \u043c\u043d\u043e\u0439. \u042f \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0415\u0441\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u043d\u0438 \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0438 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430. \u0422\u043e\u0447\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u043b \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u0430: &#171;\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435, \u0430 \u043d\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a.&#187; \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u042f \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0431\u044b\u043b \u0431\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u0430 \u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043b\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<p>\u041c\u0430\u0440\u043a \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0438\u043f\u043e\u0432 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u0437\u0430\u043a\u043e\u043d\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c\u044b\u043c\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u0445 \u0438\u0437 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <code>nil<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 <code>nil<\/code> \u2014 \u0434\u0430 \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041c\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f <code>nil<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e <code>nil<\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d. \u041c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c\u044b\u043c\u0438, \u0435\u0441\u043b\u0438 \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b.<\/p>\n<h3>\u041e \u0447\u0451\u043c \u0431\u0438\u0448\u044c \u043c\u044b&#8230;<\/h3>\n<p>\u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a <code>random-elements<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u041c\u0430\u0440\u043a \u0438 \u044f (\u0438 \u0435\u0441\u043b\u0438 \u0432\u044b, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043c\u0435\u043d\u044f, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435 Haskell), \u044f \u0434\u0443\u043c\u0430\u044e, \u0432\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0447\u0451\u043c-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0438. \u0410 \u0432\u043e\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438, \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435.<\/p>\n<p>\u0422\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0431\u043e\u0442\u0438\u043b\u043e \u043f\u043e\u0447\u0442\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 TDD, \u0442\u0435\u0441\u0442\u044b \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0432\u0435\u0434\u0443\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.\u00a0<\/p>\n<p>\u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u041c\u0430\u0440\u043a \u0431\u044b\u043b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0437\u0430\u0431\u043e\u0447\u0435\u043d \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u0415\u0433\u043e \u043c\u044b\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u044b\u043b \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043d\u044f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0430 \u0431\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. \u0417\u0430\u0442\u0435\u043c \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 QuickCheck \u0438 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041a\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0443\u0447\u0448\u0435?<\/p>\n<p>&#171;\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 <em>\u044d\u0442\u043e\u0442<\/em> \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-474820","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/474820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=474820"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/474820\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=474820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=474820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=474820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}