Commit MetaInfo

Revision7d9c15e382f8af33f4a759e0df5910b8707fdf11 (tree)
Time2022-06-25 18:20:19
AuthorAntoon Pardon <aej@pard...>
CommiterAntoon Pardon

Log Message

Made tests somewhat more extensive

Change Summary

Incremental Difference

diff -r a56dc73f7d46 -r 7d9c15e382f8 source/release.cfg
--- a/source/release.cfg Thu Jun 23 16:28:15 2022 +0200
+++ b/source/release.cfg Sat Jun 25 11:20:19 2022 +0200
@@ -1,3 +1,3 @@
1-version = '0.01.01j'
2-modified = '2022-06-23 @ 16:23:51'
1+version = '0.01.02g'
2+modified = '2022-06-25 @ 11:14:01'
33 installed = '*********************'
diff -r a56dc73f7d46 -r 7d9c15e382f8 tests/iterators.py
--- a/tests/iterators.py Thu Jun 23 16:28:15 2022 +0200
+++ b/tests/iterators.py Sat Jun 25 11:20:19 2022 +0200
@@ -3,6 +3,7 @@
33
44 from unittest import TestCase, main as unitmain
55 from random import shuffle
6+from itertools import product
67
78 from typing import List
89
@@ -10,6 +11,9 @@
1011 from AGPlib.iterators import PipeIterator, Apply, Map, concat, SubMap, Select, Discard
1112 # pylint: enable=unused-import
1213
14+SIZE_LIMIT = 101
15+
16+
1317 def shuffled_range_list(*args) -> List[int]:
1418 step = 1
1519 start = 0
@@ -50,65 +54,71 @@
5054 """
5155
5256 def test_apply(s):
53- source = shuffled_range_list(100)
54- for function in list, sum:
55- Function = Apply(function)
56- result1 = function(source)
57- result2 = source | Function
58- result3 = source >> Function
59- s.assertEqual(result1, result2)
60- s.assertEqual(result1, result3)
57+ for size in range(SIZE_LIMIT):
58+ source = shuffled_range_list(size)
59+ for function in list, sum:
60+ Function = Apply(function)
61+ result1 = function(source)
62+ result2 = source | Function
63+ result3 = source >> Function
64+ s.assertEqual(result1, result2)
65+ s.assertEqual(result1, result3)
6166
6267 def test_map(s):
63- source = shuffled_range_list(100)
64- for function in square, cube, is_odd, collatz:
65- result0 = list(map(function, source))
66- result1 = source | Map(function) | Apply(list)
67- s.assertEqual(result0, result1)
68- result2 = source >> Map(function) >> Apply(list)
69- s.assertEqual(result0, result2)
68+ for size in range(SIZE_LIMIT):
69+ source = shuffled_range_list(size)
70+ for function in square, cube, is_odd, collatz:
71+ result0 = list(map(function, source))
72+ result1 = source | Map(function) | Apply(list)
73+ s.assertEqual(result0, result1)
74+ result2 = source >> Map(function) >> Apply(list)
75+ s.assertEqual(result0, result2)
7076
7177 def test_concat(s):
7278 # pylint: disable=redefined-outer-name
7379 List = Apply(list)
74- source_list = [shuffled_range_list(100) for _ in range(100)]
75- result0 = list(concater(source_list))
76- result1 = source_list | concat | List
77- s.assertEqual(result0, result1)
78- result2 = source_list >> concat >> List
79- s.assertEqual(result0, result2)
80+ for list_size, sub_size in product(range(0, SIZE_LIMIT, 5), range(0, SIZE_LIMIT, 4)):
81+ source_list = [shuffled_range_list(sub_size) for _ in range(list_size)]
82+ result0 = list(concater(source_list))
83+ result1 = source_list | concat | List
84+ s.assertEqual(result0, result1)
85+ result2 = source_list >> concat >> List
86+ s.assertEqual(result0, result2)
8087
8188 def test_submap(s):
8289 # pylint: disable=redefined-outer-name
8390 List = Apply(list)
84- source_list = [shuffled_range_list(100) for _ in range(100)]
85- for function in square, cube, is_odd, collatz:
86- result0 = [list(map(function, lst)) for lst in source_list]
87- result1 = source_list | SubMap(function) | Map(list) | List
88- result2 = source_list >> SubMap(function) >> Map(list) >> List
89- s.assertEqual(result0, result1)
90- s.assertEqual(result0, result2)
91+ for list_size, sub_size in product(range(0, SIZE_LIMIT, 5), range(0, SIZE_LIMIT, 4)):
92+ source_list = [shuffled_range_list(sub_size) for _ in range(list_size)]
93+ for function in square, cube, is_odd, collatz:
94+ result0 = [list(map(function, lst)) for lst in source_list]
95+ result1 = source_list | SubMap(function) | Map(list) | List
96+ result2 = source_list >> SubMap(function) >> Map(list) >> List
97+ s.assertEqual(result0, result1)
98+ s.assertEqual(result0, result2)
9199
92100 def test_select(s):
93101 # pylint: disable=redefined-outer-name
94102 List = Apply(list)
95- source = shuffled_range_list(100)
96- for condition in [is_odd, is_larger_than_50]:
97- result0 = [nr for nr in source if condition(nr)]
98- result1 = source | Select(condition) | List
99- result2 = source >> Select(condition) >> List
100- s.assertEqual(result0, result1)
101- s.assertEqual(result0, result2)
103+ for size in range(SIZE_LIMIT):
104+ source = shuffled_range_list(size)
105+ for condition in [is_odd, is_larger_than_50]:
106+ result0 = [nr for nr in source if condition(nr)]
107+ result1 = source | Select(condition) | List
108+ result2 = source >> Select(condition) >> List
109+ s.assertEqual(result0, result1)
110+ s.assertEqual(result0, result2)
102111
103112 def test_discard(s):
104113 # pylint: disable=redefined-outer-name
105114 List = Apply(list)
106- source = shuffled_range_list(100)
107- for condition in [is_odd, is_larger_than_50]:
108- result0 = [nr for nr in source if not condition(nr)]
109- result1 = source | Discard(condition) | List
110- result2 = source >> Discard(condition) >> List
111- s.assertEqual(result0, result1)
112- s.assertEqual(result0, result2)
115+ for size in range(SIZE_LIMIT):
116+ source = shuffled_range_list(size)
117+ for condition in [is_odd, is_larger_than_50]:
118+ result0 = [nr for nr in source if not condition(nr)]
119+ result1 = source | Discard(condition) | List
120+ result2 = source >> Discard(condition) >> List
121+ s.assertEqual(result0, result1)
122+ s.assertEqual(result0, result2)
113123
114124 unitmain()
Show on old repository browser