From 44e725659b941682c621a2fd9309ab4acc8ab199 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Sun, 8 Nov 2026 07:29:28 +0300 Subject: publish --- doc/biblio.bib | 13 ++ doc/gost/gost-7-32-bibliography.sty | 57 +++++++++ doc/gost/gost-7-32-captions.sty | 28 +++++ doc/gost/gost-7-32-counters.sty | 44 +++++++ doc/gost/gost-7-32-headings.sty | 106 ++++++++++++++++ doc/gost/gost-7-32-lists.sty | 17 +++ doc/gost/gost-7-32-tables.sty | 29 +++++ doc/gost/gost-7-32-toc.sty | 34 ++++++ doc/gost/gost-7-32.cls | 63 ++++++++++ doc/ox-init.el | 30 +++++ doc/report.org | 235 ++++++++++++++++++++++++++++++++++++ doc/setup.org | 24 ++++ doc/spbstu-report.cls | 74 ++++++++++++ 13 files changed, 754 insertions(+) create mode 100644 doc/biblio.bib create mode 100644 doc/gost/gost-7-32-bibliography.sty create mode 100644 doc/gost/gost-7-32-captions.sty create mode 100644 doc/gost/gost-7-32-counters.sty create mode 100644 doc/gost/gost-7-32-headings.sty create mode 100644 doc/gost/gost-7-32-lists.sty create mode 100644 doc/gost/gost-7-32-tables.sty create mode 100644 doc/gost/gost-7-32-toc.sty create mode 100644 doc/gost/gost-7-32.cls create mode 100644 doc/ox-init.el create mode 100644 doc/report.org create mode 100644 doc/setup.org create mode 100644 doc/spbstu-report.cls (limited to 'doc') diff --git a/doc/biblio.bib b/doc/biblio.bib new file mode 100644 index 0000000..bfdf8b3 --- /dev/null +++ b/doc/biblio.bib @@ -0,0 +1,13 @@ +@article{LucianoPrichett1987, + author = {Luciano, D. and Prichett, G.}, + title = {Cryptology: From Caesar Ciphers to Public-Key Cryptosystems}, + location = {The College Mathematics Journal}, + year = 1987, + urldate = {2014-11-23} +} + +@online{JuicyPixels, + title = {Hackage -- JuicyPixels: Picture loading/serialization}, + url = {https://hackage.haskell.org/package/JuicyPixels}, + urldate = {2014-11-23} +} diff --git a/doc/gost/gost-7-32-bibliography.sty b/doc/gost/gost-7-32-bibliography.sty new file mode 100644 index 0000000..dca60fa --- /dev/null +++ b/doc/gost/gost-7-32-bibliography.sty @@ -0,0 +1,57 @@ +\ProvidesPackage{gost-7-32-bibliography}[2022/01/28 GOST 7.32-2017] + +\def\UrlBreaks{\do\/\do-} +\RequirePackage{url} + +\newdimen\bibindent +\renewenvironment{thebibliography}[1]{ + \chapter*{\bibname}\addcontentsline{toc}{chapter}{\bibname}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy\clubpenalty4000\widowpenalty4000% + \sfcode`\.\@m +}{ + \setcounter{totalbib}{\c@enumiv}% + \def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist +} +\renewcommand\@biblabel{}% +\setlength\bibindent{1.5em} + +% Точки после номеров в библиографии. Несовместимо с natbib! -- Коротков И. +%\makeatletter +\renewcommand*{\@biblabel}[1]{\hfill#1.} + + +% +% Remove References header completely +% Stolen from original article.cls +% +\makeatletter +\renewenvironment{thebibliography}[1]{% +% \usection{\refname}% +% \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m} + {\def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist} +\makeatother diff --git a/doc/gost/gost-7-32-captions.sty b/doc/gost/gost-7-32-captions.sty new file mode 100644 index 0000000..3720026 --- /dev/null +++ b/doc/gost/gost-7-32-captions.sty @@ -0,0 +1,28 @@ +\ProvidesPackage{gost-7-32-captions}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{caption} +\RequirePackage{subcaption} + +% +% Table caption aligned to the left with dash as a separator +% +\captionsetup[table]{labelsep=endash, justification=centering, singlelinecheck=off} + +% +% Dash as separator in figure caption and centering +% +\captionsetup[figure]{labelsep=endash, justification=centering} +\addto\captionsrussian{\renewcommand{\figurename}{Рис.}} + +% +% Listing caption +% +\captionsetup[listing]{labelsep=endash, skip=-0.5em, singlelinecheck=off, position=above} +\addto\captionsrussian{\captionsetup[listing]{name=Рис.}} +\makeatletter +\AtBeginDocument{% + \let\c@figure\c@listing + \let\thefigure\thelisting + \let\ftype@listing\ftype@figure +} +\makeatother diff --git a/doc/gost/gost-7-32-counters.sty b/doc/gost/gost-7-32-counters.sty new file mode 100644 index 0000000..ee95480 --- /dev/null +++ b/doc/gost/gost-7-32-counters.sty @@ -0,0 +1,44 @@ +\ProvidesPackage{gost-7-32-counters}[2022/01/29 GOST 7.32-2017] + +% +% Values for capital russian letters counter +% +\makeatletter +\newcommand\AlphRus[1]{% + \expandafter \@AlphRus \csname c@#1\endcsname +} + +\newcommand\@AlphRus[1]{% + \ifcase #1% + \or А\or Б\or В\or Г\or Д\or Е\or Ж\or И\or К\or + Л\or М\or Н\or П\or Р\or С\or Т\or У\or Ф\or + Х\or Ц\or Ш\or Щ\or Э\or Ю\or Я% + \else \@ctrerr +\fi +} +\makeatother + +% +% Values for lowercase russian letters counter +% +\makeatletter +\newcommand\alphRus[1]{% + \expandafter \@alphRus \csname c@#1\endcsname +} + +\newcommand\@alphRus[1]{% + \ifcase #1% + \or а\or б\or в\or г\or д\or е\or ж\or и\or к\or + л\or м\or н\or п\or р\or с\or т\or у\or ф\or + х\or ц\or ш\or щ\or э\or ю\or я% + \else \@ctrerr +\fi +} +\makeatother + +% Increment figure counter when using lstlisting +% \let\oldlstlisting\lstlisting +% \renewcommand{\lstlisting}[1][]{% +% \refstepcounter{figure} +% \oldlstlisting[#1] +% } diff --git a/doc/gost/gost-7-32-headings.sty b/doc/gost/gost-7-32-headings.sty new file mode 100644 index 0000000..033f4a8 --- /dev/null +++ b/doc/gost/gost-7-32-headings.sty @@ -0,0 +1,106 @@ +\ProvidesPackage{gost-7-32-headings}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{titlesec} +\RequirePackage{titling} +\RequirePackage{setspace} + +\RequirePackage{gost-7-32-counters} + +% +% Set custom formatting to well-known LaTeX commands: section, subsection and subsubsection +% +\titleformat{\section}[block]{\centering\large\setstretch{1}\bfseries}{\thesection}{0.5em}{} +\titlespacing*{\section}{0cm}{0cm}{0.5cm} +\newcommand{\sectionbreak}{\clearpage} + +\titleformat{\subsection}[block]{\normalsize\bfseries}{\thesubsection}{0.5em}{} +\titlespacing{\subsection}{0cm}{0.5cm}{0.5cm} + +\titleformat{\subsubsection}[runin]{\normalsize\bfseries}{\thesubsubsection}{0.5em}{}[\newline\indent] +\titlespacing{\subsubsection}{1.25cm}{0.5em}{0cm} + +\makeatletter +\let\oldsection\section +\newcommand{\@sectionnostar}[1]{\phantomsection\oldsection*{#1}\addcontentsline{toc}{section}{#1}} +\newcommand{\@sectionstar}[1]{\oldsection{#1}} +\renewcommand{\section}{\sectionbreak\@ifstar{\@sectionnostar}{\@sectionstar}} +\makeatother + +% +% Make special headings, that have their own formatting rules: +% - centered +% - all-caps +% - bold +% +% Only three of them must appear in TOC: introduction, conclusion and references +% +\newcommand{\introduction}{ + \addcontentsline{toc}{section}{ВВЕДЕНИЕ} + \begin{center} + \bfseries\large + ВВЕДЕНИЕ + \end{center} +} + +\newcommand{\conclusion}{ + \addcontentsline{toc}{section}{ЗАКЛЮЧЕНИЕ} + \begin{center} + \bfseries\large + ЗАКЛЮЧЕНИЕ + \end{center} +} + +\newcommand{\references}{ + \addcontentsline{toc}{section}{СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ} + \begin{center} + \bfseries\large + СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ + \end{center} +} + +\newcommand{\essay}{ + \begin{center} + \bfseries\large + РЕФЕРАТ + \end{center} +} + +\newcommand{\definitions}{ + \begin{center} + \bfseries\large + ОПРЕДЕЛЕНИЯ + \end{center} +} + +\newcommand{\abbreviations}{ + \begin{center} + \bfseries\large + ОБОЗНАЧЕНИЯ И СОКРАЩЕНИЯ + \end{center} +} + +\newcommand{\defsabbrs}{ + \begin{center} + \bfseries\large + ОПРЕДЕЛЕНИЯ, ОБОЗНАЧЕНИЯ И СОКРАЩЕНИЯ + \end{center} +} + +% +% Appendices headings. Appendices have autoincrementing number, +% that is represented with russian letter. +% This heading must appear in TOC +% +\newcounter{appendixcnt} +\setcounter{appendixcnt}{1} + +\renewcommand{\appendix}[1]{ + \addcontentsline{toc}{section}{ПРИЛОЖЕНИЕ \AlphRus{appendixcnt}. #1} + \begin{center} + \bfseries\large + ПРИЛОЖЕНИЕ \AlphRus{appendixcnt} + + #1 + \end{center} + \stepcounter{appendixcnt} +} diff --git a/doc/gost/gost-7-32-lists.sty b/doc/gost/gost-7-32-lists.sty new file mode 100644 index 0000000..6f41980 --- /dev/null +++ b/doc/gost/gost-7-32-lists.sty @@ -0,0 +1,17 @@ +\ProvidesPackage{gost-7-32-lists}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{enumitem} +\RequirePackage{gost-7-32-counters} + +\AddEnumerateCounter*{\alphRus}{\c@alphRus}{1} + +\setlist{nosep} +\setlist[itemize, 1]{label=\textendash} +\setlist[itemize, 2]{label=\bullet} +\setlist[itemize, 3]{label=\bullet} + +\setlist[enumerate, 2]{label=\alphRus*)} + +\setlist[1]{wide=\parindent} +\setlist[2]{wide=2\parindent, leftmargin=\parindent} +\setlist[3]{wide=2\parindent} diff --git a/doc/gost/gost-7-32-tables.sty b/doc/gost/gost-7-32-tables.sty new file mode 100644 index 0000000..750ab75 --- /dev/null +++ b/doc/gost/gost-7-32-tables.sty @@ -0,0 +1,29 @@ +\ProvidesPackage{gost-7-32-tables}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{tabularx} + +% +% Center-aligned column with automatic width +% +\newcolumntype{Y}{>{\centering\arraybackslash}X} + +% +% Right-aligned column with automatic width +% +\newcolumntype{Z}{>{\raggedleft\arraybackslash}X} + +% +% Table with designations +% +\newenvironment{designations}{ + \noindent + \tabularx{\textwidth}{@{} + >{\raggedright \arraybackslash \hsize=0.25\hsize}X + >{\centering \arraybackslash \hsize=0.05\hsize}X + >{\arraybackslash \hsize=0.70\hsize}X + } +}{ + \endtabularx +} + +\newcommand{\designation}[2]{#1 &---& #2. \\} diff --git a/doc/gost/gost-7-32-toc.sty b/doc/gost/gost-7-32-toc.sty new file mode 100644 index 0000000..328079d --- /dev/null +++ b/doc/gost/gost-7-32-toc.sty @@ -0,0 +1,34 @@ +\ProvidesPackage{gost-7-32-toc}[2022/01/28 GOST 7.32-2017] + +\RequirePackage{tocloft} +\RequirePackage[ + bookmarks=true, + colorlinks=true, + unicode=true, + urlcolor=black, + linkcolor=black, + anchorcolor=black, + citecolor=black, + menucolor=black, + filecolor=black, + hidelinks +]{hyperref} + +% +% Set custom font styles +% +\renewcommand{\cftsecfont}{\normalfont} +\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} +\renewcommand{\cftsecpagefont}{\normalsize} +\renewcommand{\cftaftertoctitle}{\hfill\hfill} +\renewcommand{\cfttoctitlefont}{\hfill\normalfont\large\bfseries} +\titleformat{\tableofcontents}[block]{\centering\large\bfseries}{\thesection}{0.5em}{} +\titlespacing{\tableofcontents}{0cm}{0cm}{1cm} + +% +% Set indents and line spacing +% +\setlength{\cftbeforesecskip}{0cm} +\setlength{\cftbeforesubsecskip}{0cm} +\setlength{\cftbeforesubsubsecskip}{0cm} +\setlength{\cftbeforeparaskip}{0cm} diff --git a/doc/gost/gost-7-32.cls b/doc/gost/gost-7-32.cls new file mode 100644 index 0000000..5cfca06 --- /dev/null +++ b/doc/gost/gost-7-32.cls @@ -0,0 +1,63 @@ +% https://github.com/weterans/gost +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{gost-7-32}[2022/01/28 GOST 7.32-2017] + +% +% Supported font sizes: 12pt, 14pt +% +\DeclareOption{12pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} +\DeclareOption{14pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} + +\ProcessOptions\relax + +% +% Set A4 paper format +% +\LoadClass[a4paper]{extarticle} + +% +% Use 1.5 line spacing +% +\RequirePackage{setspace} +\spacing{1.5} + +% +% First paragraph indentation +% +\RequirePackage{indentfirst} +\setlength{\parindent}{12.5mm} + +% +% Page margin +% +\RequirePackage[ + left=2.5cm, + right=2cm, + top=2cm, + bottom=2cm, + footskip=1cm, +]{geometry} + +% +% Use TMR-like font +% +\RequirePackage{fontspec} +\RequirePackage{xunicode} +\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase,Mapping=tex-text} +\setmainfont{Times New Roman} + +% +% Use russian language +% +\RequirePackage[main=russian, english]{babel} +\babelhyphenation[russian]{} + +% +% gost-7-32 packages +% +\RequirePackage{gost-7-32-headings} +\RequirePackage{gost-7-32-toc} +\RequirePackage{gost-7-32-lists} +% \RequirePackage{gost-7-32-bibliography} +\RequirePackage{gost-7-32-captions} +\RequirePackage{gost-7-32-tables} diff --git a/doc/ox-init.el b/doc/ox-init.el new file mode 100644 index 0000000..a7cfed5 --- /dev/null +++ b/doc/ox-init.el @@ -0,0 +1,30 @@ +;;; ox-init.el --- Initialization script for async org exprort session +;;; Commentary: +;;; Code: +(org-babel-do-load-languages + 'org-babel-load-languages + '((latex . t) + (haskell . t))) + +(require 'ox-extra) +(ox-extras-activate '(ignore-headlines)) + +(setq org-latex-src-block-backend 'minted) + +(require 'oc-bibtex) +(setq org-latex-bib-compiler "biber") + +(setq org-latex-remove-logfiles nil) + +(setq org-latex-caption-above '(table src-block special-block)) + +(setq org-latex-pdf-process '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f" + "%bib %b" + "%latex -shell-escape -interaction nonstopmode -output-directory %o %f")) +(setq org-latex-classes '(("spbstu-report" "\\documentclass[12pt]{spbstu-report}" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))) +;;; ox-init.el ends here diff --git a/doc/report.org b/doc/report.org new file mode 100644 index 0000000..101ec1e --- /dev/null +++ b/doc/report.org @@ -0,0 +1,235 @@ +#+title: Тестирование в Haskell +#+author: Михалец М. +#+latex_header: \reportof{О ВЫПОЛНЕНИИ ЛАБОРАТОРНОЙ РАБОТЫ №4} +#+latex_header: \subject{по дисциплине «Функциональное программирование»} +#+latex_header: \university{Федеральное государственное автономное образовательное учреждение высшего образования \enquote{Санкт-Петербургский политехнический университет Петра Великого}} +#+latex_header: \institute{Институт компьютерных наук и кибербезопасности} +#+latex_header: \school{Высшая школа технологии искусственного интеллекта} +#+latex_header: \direction{02.03.01 Математика и компьютерные науки} +#+latex_header: \reviewertitle{}\reviewer{Моторин Д.Е.} +#+latex_header: \city{Санкт-Петербург} +#+date: 2024 + +#+setupfile: setup.org +#+latex: \sloppy + +* ВВЕДЕНИЕ +:PROPERTIES: +:UNNUMBERED: t +:END: +В данном отчете, описана реализация и результаты тестирования +~QuickCheck~. Тестирование реализовано для двух заданных математических +функций, на проверку их свойств. Все тесты были записаны в =Spec.hs=. + +Ограничения: +- Функции нужно записать в библиотеку =Lib.hs= и ограничить доступ к + вспомогательным функциям. + +* Постановка задачи +Для реализации данной лабораторной работы, необходимо создать проект в +=stack=. В проекте =stack=, есть директория =tests=, в которой есть файл +=Spec.hs=, где можно так же прописать ~main~, для вывода результатов +тестирования. Необходимо проверить две функции: +1. ~isCongruent :: Int -> Int -> Int -> Bool~ +2. ~zipWithSum :: [Int] -> [Int] -> [Int]~ + +** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ +Функция проверки равенства по модулю ~isCongruent :: Int -> Int -> Int +-> Bool Int -> Bool~ --- проверяет, равны ли два числа по модулю +третьего числа. + +Используя ~QuickCheck~, проверьте следующие свойства: +1. Если два числа равны по модулю, то их разность делится на модуль: + - ~isCongruent a b m == (modulus (a - b) m == 0)~. +2. Равенство по модулю является симметричным: + - ~isCongruent a b m == isCongruent b a m~. +3. Если одно число равно другому, то они равны по любому модулю: + - если a = b, то ~isCongruent a b m == True~. + +** ~zipWithSum :: [Int] -> [Int] -> [Int]~ +функция ~zipWithSum :: [Int] -> [Int] -> [Int]~ --- принимает два списка +целых чисел и возвращает новый список, где каждый элемент является +суммой соответствующих элементов двух списков. Если длины списков +различаются, остатки более длинного списка должны быть добавлены в +конец результата. + +Используя ~QuickCheck~, проверьте следующие свойства: +1. Длины результата равна максимальной длине входных списков: + - ~length (zipWithSum xs ys) == max (length xs) (length ys)~. +2. Если один из списков пустой, то результат совпадает с непустым + списком: + - если ~xs~ пустой, то ~zipWithSum [] ys == ys~. +3. Сумма элементов результата равна сумме всех элементов входных + списков: + - ~sum (zipWithSum xs ys) == sum xs + sum ys~. + +* Реализация функций +Функция реализована в =Lib.hs=. +** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ +#+include: "../src/Lib.hs" src haskell :lines "6-8" + +Функция проверяет равенство ~a~ и ~b~ по модулю ~m~. + +Пример: +1. ~isCongruent 2 5 3~ +2. ~(2 `mod` 3) == (5 `mod` 3)~ +3. ~2 == 2~ +4. ~True~ + +** ~zipWithSum :: [Int] -> [Int] -> [Int]~ +#+include: "../src/Lib.hs" src haskell :lines "9-" + +Функция принимает два списка целых чисел и возвращает новый список, +где каждый элемент является суммой соответствующих элементов двух +списков. Если длины списков различаются, остатки более длинного +списка должны быть добавлены в конец результата. + +Пример: ~zipWithSum [0, 3] [1, 2, 3] == [1,5,3]~ + +* Тестирование функций +В тестах необходимо проверить свойства описанные в пункте [[* Постановка +задачи]], соответственно. + +Функций реализованы в =Spec.hs=. + +** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ +*** ~prop_isCongruent_diffDivisible :: Int -> Int -> Int -> Property~ +#+include: "../test/Spec.hs" src haskell :lines "7-10" + +Если два числа равны по модулю, то их разность делится на модуль. + +~isCongruent a b m == (modulus (a - b) m == 0)~. + +*** ~prop_isCongruent_symmetry :: Int -> Int -> Int -> Property~ +#+include: "../test/Spec.hs" src haskell :lines "14-17" + +Равенство по модулю является симметричным. + +~isCongruent a b m == isCongruent b a m~. + +*** ~prop_isCongruent_equalAlwaysCongruent :: Int -> Int -> Property~ +#+include: "../test/Spec.hs" src haskell :lines "21-23" + +Если одно число равно другому, то они равны по любому модулю. + +Если $a = b$, то ~isCongruent a b m == True~. + +** ~zipWithSum :: [Int] -> [Int] -> [Int]~ +*** ~prop_zipWithSum_length :: [Int] -> [Int] -> Bool~ +#+include: "../test/Spec.hs" src haskell :lines "27-30" + +Длины результата равна максимальной длине входных списков. + +~length (zipWithSum xs ys) == max (length xs) (length ys)~ + +*** ~prop_zipWithSum_emptyList :: [Int] -> Bool~ +#+include: "../test/Spec.hs" src haskell :lines "35-37" + +Если один из списков пустой, то результат совпадает с непустым +списком. + +Если ~xs~ пустой, то ~zipWithSum [] ys == ys~. + +*** ~prop_zipWithSum_sum :: [Int] -> [Int] -> Bool~ +#+include: "../test/Spec.hs" src haskell :lines "42-44" + +Сумма элементов результата равна сумме всех элементов входных списков. + +~sum (zipWithSum xs ys) == sum xs + sum ys~ + +** ~main :: IO ()~ +#+include: "../test/Spec.hs" src haskell :lines "45-" + +Выводит заголовки для каждой группы тестов (для функций ~isCongruent~ и +~zipWithSum~). Вызывает ~QuickCheck~ для каждого свойства, чтобы +проверить его на большом наборе случайных данных. + +Если тесты проходят, QuickCheck сообщает об успешных проверках. Если +находятся ошибки, QuickCheck выведет пример, на котором свойство +нарушается. + +* Результаты тестирования +Для тестирования функций необходимо в директории папки с проектом +запустить команду: ~stack test~ + +После чего увидим результаты тестов прописанных в =Spec.hs=: +#+begin_example +lab4> test (suite: lab4-test) + ++++ OK, passed 100 tests; 15 discarded. ++++ OK, passed 100 tests; 12 discarded. ++++ OK, passed 100 tests; 14 discarded. ++++ OK, passed 100 tests. ++++ OK, passed 100 tests. ++++ OK, passed 100 tests. + + + +lab4> Test suite lab4-test passed +Completed 2 action(s). +#+end_example + +Здесь $N$ =discarded= --- означает, что ~QuickCheck~ сгенерировал $N$ +случайных наборов данных, которые не соответствовали условиям теста, +например, потому что $m \ne 0$ для тестов ~isCongruent~. ~QuickCheck~ +продолжает генерировать данные, пока не наберёт достаточно случаев, +которые проходят проверку условия. + +#+latex: \clearpage + +Чтобы доказать, что тесты реально проверяются, введём изменения, +которые прекратят выполнение исключительно одного теста, допустим +~prop_zipWithSum_sum~: +#+attr_latex: :options linenos=false +#+begin_src haskell +zipWithSum (x:xs) (y:ys) = (x + y + 1) : zipWithSum xs ys +#+end_src +Здесь мы дополнительно добавляем к сумме единицу, что помещает +исключительно одному тесту, так как только одно из свойств смотрит на +значения обрабатываемых списков. + +После запуска проверки мы получает следующий результат: +#+begin_example +lab4> test (suite: lab4-test) + ++++ OK, passed 100 tests; 11 discarded. ++++ OK, passed 100 tests; 12 discarded. ++++ OK, passed 100 tests; 12 discarded. ++++ OK, passed 100 tests. ++++ OK, passed 100 tests. +,*** Failed! Falsified (after 3 tests and 2 shrinks): +[0] +[0] + + + +lab4> Test suite lab4-test passed +Completed 2 action(s). +#+end_example + +* ЗАКЛЮЧЕНИЕ +:PROPERTIES: +:UNNUMBERED: t +:END: +В результате выполнения данной лабораторной работы, были изучены +основы тестирования ПО, на языке Haskell, с использованием библиотеки +~QuickCheck~ написанный в stack проекте в =Spec.hs=. + +Были протестированы две функции на их свойства: +1. ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~ +2. ~zipWithSum :: [Int] -> [Int] -> [Int]~ + +В ходе тестирования, обе функции «прошли» все тесты. Что подтверждает +корректность свойств функций в нашей программе. + +# * СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ +# :PROPERTIES: +# :UNNUMBERED: t +# :END: +# #+print_bibliography: :heading none + +# Local Variables: +# org-confirm-babel-evaluate: nil +# org-export-async-init-file: "ox-init.el" +# org-export-in-background: t +# End: diff --git a/doc/setup.org b/doc/setup.org new file mode 100644 index 0000000..2daa8e8 --- /dev/null +++ b/doc/setup.org @@ -0,0 +1,24 @@ +#+options: ':nil *:t -:t ::t <:t H:3 \n:nil ^:{} arch:headline +#+options: author:t broken-links:nil c:nil creator:nil +#+options: d:(not "LOGBOOK") date:t e:t email:nil f:t inline:f num:t +#+options: p:nil pri:nil prop:nil stat:f tags:f tasks:f tex:t +#+options: timestamp:nil title:t toc:t todo:t |:t +#+creator: Emacs 29.4 (Org mode 9.7.14) + +#+select_tags: export +#+exclude_tags: noexport + +#+bibliography: biblio.bib +#+cite_export: biblatex + +#+latex_compiler: xelatex +#+latex_class: spbstu-report +# #+latex_class_options: [draft] +#+latex_header: \usepackage{enumitem} +#+latex_header: \usepackage[newfloat]{minted} +#+latex_header: \usemintedstyle{bw} +#+latex_header: \setminted{baselinestretch=1,linenos,breaklines,escapeinside=\#\#,ignorelexererrors} +#+latex_header: \renewcommand\theFancyVerbLine{\large\arabic{FancyVerbLine}} +#+latex_header: \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase,Mapping=tex-text} +#+latex_header: \setmainfont{Times New Roman} +#+latex_header: \setmonofont{Iosevka Term Slab}[Contextuals=AlternateOff] diff --git a/doc/spbstu-report.cls b/doc/spbstu-report.cls new file mode 100644 index 0000000..7ae6b05 --- /dev/null +++ b/doc/spbstu-report.cls @@ -0,0 +1,74 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{spbstu-report}[2023/05/12 Класс для отчетов] + +% +% Support font sizes: 12pt, 14pt +% +\DeclareOption{12pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} +\DeclareOption{14pt}{\PassOptionsToClass{\CurrentOption}{extarticle}} + +\ProcessOptions\relax + +\LoadClass[a4paper]{gost-7-32} + +\RequirePackage{csquotes} +\RequirePackage{amsmath} +\RequirePackage{adjustbox} +\RequirePackage{setspace} + +\newcommand{\@reportof}{}\newcommand{\reportof}[1]{\renewcommand{\@reportof}{#1}} +\newcommand{\@university}{}\newcommand{\university}[1]{\renewcommand{\@university}{#1}} +\newcommand{\@institute}{}\newcommand{\institute}[1]{\renewcommand{\@institute}{#1}} +\newcommand{\@school}{}\newcommand{\school}[1]{\renewcommand{\@school}{#1}} +\newcommand{\@direction}{}\newcommand{\direction}[1]{\renewcommand{\@direction}{#1}} +\newcommand{\@subject}{}\newcommand{\subject}[1]{\renewcommand{\@subject}{#1}} +\newcommand{\@reviewer}{}\newcommand{\reviewer}[1]{\renewcommand{\@reviewer}{#1}} +\newcommand{\@reviewertitle}{}\newcommand{\reviewertitle}[1]{\renewcommand{\@reviewertitle}{#1}} +\newcommand{\signdate}{$\underset{\centering\text{\normalsize подпись, дата}}{\underline{\hspace{5cm}}}$} +\newcommand{\@city}{}\newcommand{\city}[1]{\renewcommand{\@city}{#1}} +\renewcommand{\maketitle}{ + \begin{titlepage} + \begin{center} + \vspace{2cm} + \small{МИНИСТЕРСТВО НАУКИ И ВЫСШЕГО ОБРАЗОВАНИЯ РОССИЙСКОЙ ФЕДЕРАЦИИ} + + \normalsize{\@university} + + \vspace{0.5cm} + \normalsize{\@institute} + + \normalsize{\@school} + + \normalsize{Направление \@direction} + + \vspace{2cm} + \LARGE{ОТЧЁТ} + + \normalsize{\@reportof} + + \large{\@subject} + + \large{\textit{\@title}} + \end{center} + + \vspace{3cm} + \small{ + \begin{tabular}{lrrl} + \!\!\!Студент, & \hspace{2cm} & & \\ + \!\!\!группы 5130201/20102 & \hspace{2cm} & \underline{\hspace{3cm}} & \@author \\\\ + \!\!\!Преподаватель, & \hspace{2cm} & \\ + \!\!\!\@reviewertitle & \hspace{2cm} & \underline{\hspace{3cm}} & \@reviewer \\\\ + &&\hspace{5cm} + \end{tabular} + \begin{flushright} + \enquote{\underline{\hspace{1cm}}}\underline{\hspace{2.5cm}} \@date г. + \end{flushright} + } + + \vspace*{\fill} + \begin{center} + \small{\@city, \@date} + \end{center} + \end{titlepage} + \setcounter{page}{2} +} -- cgit v1.3.1