We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f11241 commit cd16663Copy full SHA for cd16663
unpythonic/tests/test_gmemo.py
@@ -92,6 +92,23 @@ def gen():
92
fail["Should have raised at the second next() call."] # pragma: no cover
93
test[total_evaluations == 2]
94
95
+ with testset("subscripting to get already computed items"):
96
+ @gmemoize
97
+ def gen():
98
+ yield from range(5)
99
+ g3 = gen()
100
+ test[len(g3) == 0]
101
+ next(g3)
102
+ test[len(g3) == 1]
103
104
+ test[len(g3) == 2]
105
106
+ test[len(g3) == 3]
107
+ test[g3[0] == 0]
108
+ test[g3[1] == 1]
109
+ test[g3[2] == 2]
110
+ test_raises[IndexError, g3[3]]
111
+
112
with testset("memoizing a sequence partially"):
113
# To do this, build a chain of generators, then memoize only the last one:
114
evaluations = Counter()
0 commit comments