aboutsummaryrefslogtreecommitdiff
path: root/README.org
diff options
context:
space:
mode:
Diffstat (limited to 'README.org')
-rw-r--r--README.org57
1 files changed, 57 insertions, 0 deletions
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..71ad41b
--- /dev/null
+++ b/README.org
@@ -0,0 +1,57 @@
1#+title: Testing in Haskell
2#+date: 2024H2
3
4* Task
5:PROPERTIES:
6:CUSTOM_ID: task
7:END:
8Create a project in =stack=. In the =stack= project, there is a =tests=
9directory, which contains the file =Spec.hs=, where you can also write
10~main~ to display the test results. You need to test two functions:
111. ~isCongruent :: Int -> Int -> Int -> Bool~
122. ~zipWithSum :: [Int] -> [Int] -> [Int]~
13
14** ~isCongruent :: Int -> Int -> Int -> Bool Int -> Bool~
15The modulo equality check function ~isCongruent :: Int -> Int -> Int ->
16Bool Int -> Bool~ checks whether two numbers are congruent modulo a
17third number.
18
19Using ~QuickCheck~, verify the following properties:
201. If two numbers are congruent modulo, then their difference is
21 divisible by the modulus:
22 - ~isCongruent a b m == (modulus (a - b) m == 0)~.
232. Equality modulo is symmetric:
24 - ~isCongruent a b m == isCongruent b a m~.
253. If one number is equal to another, then they are equal modulo any
26 value:
27 - if a = b, then ~isCongruent a b m == True~.
28
29** ~zipWithSum :: [Int] -> [Int] -> [Int]~
30The function ~zipWithSum :: [Int] -> [Int] -> [Int]~ takes two lists of
31integers and returns a new list where each element is the sum of the
32corresponding elements of the two lists. If the list lengths differ,
33the remaining elements of the longer list should be added to the end
34of the result.
35
36 Using ~QuickCheck~, verify the following properties:
371. The length of the result is equal to the maximum length of the
38 input lists:
39 - ~length (zipWithSum xs ys) == max (length xs) (length ys)~.
402. If one of the lists is empty, then the result is the same as the
41 non‑empty list:
42 - if ~xs~ is empty, then ~zipWithSum [] ys == ys~.
433. The sum of the elements of the result is equal to the sum of all
44 elements of the input lists:
45 - ~sum (zipWithSum xs ys) == sum xs + sum ys~.
46
47* Documentation
48:PROPERTIES:
49:CUSTOM_ID: documentation
50:END:
51The exported report can be found at [[https://git.michalec.dev/files/uni/term-05/func-prog/lab-04/report.pdf][this link]].
52
53* Unlicense
54:PROPERTIES:
55:CUSTOM_ID: unlicense
56:END:
57#+include: UNLICENSE verse