rapydscript-ns 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/.agignore +1 -0
  2. package/.gitattributes +4 -0
  3. package/.github/workflows/ci.yml +38 -0
  4. package/.github/workflows/web-repl-page-deploy.yml +42 -0
  5. package/=template.pyj +5 -0
  6. package/CHANGELOG.md +456 -0
  7. package/CONTRIBUTORS +13 -0
  8. package/HACKING.md +103 -0
  9. package/LICENSE +24 -0
  10. package/README.md +2512 -0
  11. package/TODO.md +327 -0
  12. package/add-toc-to-readme +2 -0
  13. package/bin/export +75 -0
  14. package/bin/rapydscript +70 -0
  15. package/bin/web-repl-export +102 -0
  16. package/build +3 -0
  17. package/package.json +46 -0
  18. package/publish.py +37 -0
  19. package/release/baselib-plain-pretty.js +4370 -0
  20. package/release/baselib-plain-ugly.js +3 -0
  21. package/release/compiler.js +18394 -0
  22. package/release/signatures.json +31 -0
  23. package/session.vim +4 -0
  24. package/setup.cfg +2 -0
  25. package/src/ast.pyj +1356 -0
  26. package/src/baselib-builtins.pyj +279 -0
  27. package/src/baselib-containers.pyj +723 -0
  28. package/src/baselib-errors.pyj +37 -0
  29. package/src/baselib-internal.pyj +421 -0
  30. package/src/baselib-itertools.pyj +97 -0
  31. package/src/baselib-str.pyj +798 -0
  32. package/src/compiler.pyj +36 -0
  33. package/src/errors.pyj +30 -0
  34. package/src/lib/aes.pyj +646 -0
  35. package/src/lib/collections.pyj +695 -0
  36. package/src/lib/elementmaker.pyj +83 -0
  37. package/src/lib/encodings.pyj +126 -0
  38. package/src/lib/functools.pyj +148 -0
  39. package/src/lib/gettext.pyj +569 -0
  40. package/src/lib/itertools.pyj +580 -0
  41. package/src/lib/math.pyj +193 -0
  42. package/src/lib/numpy.pyj +2101 -0
  43. package/src/lib/operator.pyj +11 -0
  44. package/src/lib/pythonize.pyj +20 -0
  45. package/src/lib/random.pyj +118 -0
  46. package/src/lib/re.pyj +470 -0
  47. package/src/lib/traceback.pyj +63 -0
  48. package/src/lib/uuid.pyj +77 -0
  49. package/src/monaco-language-service/analyzer.js +526 -0
  50. package/src/monaco-language-service/builtins.js +543 -0
  51. package/src/monaco-language-service/completions.js +498 -0
  52. package/src/monaco-language-service/diagnostics.js +643 -0
  53. package/src/monaco-language-service/dts.js +550 -0
  54. package/src/monaco-language-service/hover.js +121 -0
  55. package/src/monaco-language-service/index.js +386 -0
  56. package/src/monaco-language-service/scope.js +162 -0
  57. package/src/monaco-language-service/signature.js +144 -0
  58. package/src/output/__init__.pyj +0 -0
  59. package/src/output/classes.pyj +296 -0
  60. package/src/output/codegen.pyj +492 -0
  61. package/src/output/comments.pyj +45 -0
  62. package/src/output/exceptions.pyj +105 -0
  63. package/src/output/functions.pyj +491 -0
  64. package/src/output/literals.pyj +109 -0
  65. package/src/output/loops.pyj +444 -0
  66. package/src/output/modules.pyj +329 -0
  67. package/src/output/operators.pyj +429 -0
  68. package/src/output/statements.pyj +463 -0
  69. package/src/output/stream.pyj +309 -0
  70. package/src/output/treeshake.pyj +182 -0
  71. package/src/output/utils.pyj +72 -0
  72. package/src/parse.pyj +3106 -0
  73. package/src/string_interpolation.pyj +72 -0
  74. package/src/tokenizer.pyj +702 -0
  75. package/src/unicode_aliases.pyj +576 -0
  76. package/src/utils.pyj +192 -0
  77. package/test/_import_one.pyj +37 -0
  78. package/test/_import_two/__init__.pyj +11 -0
  79. package/test/_import_two/level2/__init__.pyj +0 -0
  80. package/test/_import_two/level2/deep.pyj +4 -0
  81. package/test/_import_two/other.pyj +6 -0
  82. package/test/_import_two/sub.pyj +13 -0
  83. package/test/aes_vectors.pyj +421 -0
  84. package/test/annotations.pyj +80 -0
  85. package/test/baselib.pyj +319 -0
  86. package/test/classes.pyj +452 -0
  87. package/test/collections.pyj +152 -0
  88. package/test/decorators.pyj +77 -0
  89. package/test/dict_spread.pyj +76 -0
  90. package/test/docstrings.pyj +39 -0
  91. package/test/elementmaker_test.pyj +45 -0
  92. package/test/ellipsis.pyj +49 -0
  93. package/test/functions.pyj +151 -0
  94. package/test/generators.pyj +41 -0
  95. package/test/generic.pyj +370 -0
  96. package/test/imports.pyj +72 -0
  97. package/test/internationalization.pyj +73 -0
  98. package/test/lint.pyj +164 -0
  99. package/test/loops.pyj +85 -0
  100. package/test/numpy.pyj +734 -0
  101. package/test/omit_function_metadata.pyj +20 -0
  102. package/test/regexp.pyj +55 -0
  103. package/test/repl.pyj +121 -0
  104. package/test/scoped_flags.pyj +76 -0
  105. package/test/starargs.pyj +506 -0
  106. package/test/starred_assign.pyj +104 -0
  107. package/test/str.pyj +198 -0
  108. package/test/subscript_tuple.pyj +53 -0
  109. package/test/unit/fixtures/fibonacci_expected.js +46 -0
  110. package/test/unit/index.js +2989 -0
  111. package/test/unit/language-service-builtins.js +815 -0
  112. package/test/unit/language-service-completions.js +1067 -0
  113. package/test/unit/language-service-dts.js +543 -0
  114. package/test/unit/language-service-hover.js +455 -0
  115. package/test/unit/language-service-scope.js +833 -0
  116. package/test/unit/language-service-signature.js +458 -0
  117. package/test/unit/language-service.js +705 -0
  118. package/test/unit/run-language-service.js +41 -0
  119. package/test/unit/web-repl.js +484 -0
  120. package/tools/build-language-service.js +190 -0
  121. package/tools/cli.js +547 -0
  122. package/tools/compile.js +219 -0
  123. package/tools/compiler.js +108 -0
  124. package/tools/completer.js +131 -0
  125. package/tools/embedded_compiler.js +251 -0
  126. package/tools/export.js +316 -0
  127. package/tools/gettext.js +185 -0
  128. package/tools/ini.js +65 -0
  129. package/tools/lint.js +705 -0
  130. package/tools/msgfmt.js +187 -0
  131. package/tools/repl.js +223 -0
  132. package/tools/self.js +162 -0
  133. package/tools/test.js +118 -0
  134. package/tools/utils.js +128 -0
  135. package/tools/web_repl.js +95 -0
  136. package/try +41 -0
  137. package/web-repl/env.js +74 -0
  138. package/web-repl/index.html +163 -0
  139. package/web-repl/language-service.js +4084 -0
  140. package/web-repl/main.js +254 -0
  141. package/web-repl/prism.css +139 -0
  142. package/web-repl/prism.js +113 -0
  143. package/web-repl/rapydscript.js +435 -0
  144. package/web-repl/sha1.js +25 -0
@@ -0,0 +1,80 @@
1
+ def add(a: int, b: float):
2
+ return a + b
3
+
4
+ assrt.ok(add.__annotations__)
5
+ assrt.equal(add.__annotations__['a'], int)
6
+ assrt.equal(add.__annotations__['b'], float)
7
+ assrt.equal(add.__annotations__['return'], undefined)
8
+
9
+ def sum(ls: list) -> int:
10
+ pass
11
+
12
+ assrt.ok(not (sum.__annotations__ == undefined))
13
+ assrt.deepEqual(sum.__annotations__, {
14
+ 'ls': list,
15
+ 'return': int
16
+ })
17
+
18
+ def optional(a:int=10):
19
+ return a
20
+
21
+ assrt.ok(not (optional.__annotations__ == undefined))
22
+ assrt.equal(optional.__annotations__.a, int)
23
+ assrt.equal(optional.__defaults__.a, 10)
24
+
25
+ def otherexpr(a:3+4) -> [1, 2]:
26
+ pass
27
+
28
+ assrt.ok(not (otherexpr.__annotations__ == undefined))
29
+ assrt.equal(otherexpr.__annotations__['a'], 7)
30
+ assrt.deepEqual(otherexpr.__annotations__['return'], [1, 2])
31
+
32
+ def basic(x:float):
33
+ pass
34
+
35
+ assrt.deepEqual(basic.__annotations__, {
36
+ 'x': float
37
+ })
38
+
39
+ def kwstarargs(*args:list, **kwargs:dict) -> int:
40
+ pass
41
+
42
+ assrt.equal(kwstarargs.__annotations__['return'], int)
43
+
44
+ def nothing():
45
+ pass
46
+
47
+ assrt.ok(nothing.__annotations__ == undefined)
48
+ assrt.throws(def():
49
+ nothing.__annotations__['return']
50
+ )
51
+
52
+ test = def(x: int):
53
+ pass
54
+
55
+ assrt.deepEqual(test.__annotations__, {
56
+ 'x': int
57
+ })
58
+
59
+ anonreturn = def() -> 'test':
60
+ pass
61
+
62
+ assrt.equal(anonreturn.__annotations__['return'], 'test')
63
+
64
+ assrt.equal(def asexpr(a: int):
65
+ a
66
+ .__annotations__['a'], int)
67
+
68
+ assrt.deepEqual(def(a: int) -> float:
69
+ a + 10.0
70
+ .__annotations__, {
71
+ 'a': int,
72
+ 'return': float
73
+ })
74
+
75
+ class A:
76
+
77
+ def f(self, a : int, b: 'x') -> float:
78
+ pass
79
+
80
+ assrt.deepEqual(A.prototype.f.__annotations__, {'a':int, 'b':'x', 'return': float})
@@ -0,0 +1,319 @@
1
+ # vim:fileencoding=utf-8
2
+ # globals: ρσ_iterator_symbol, ρσ_set_polyfill, ρσ_dict_polyfill, assrt
3
+ nonlocal ρσ_set_implementation, ρσ_dict_implementation
4
+
5
+ class CustomIterable:
6
+
7
+ def __init__(self, items):
8
+ self.items = items
9
+
10
+ def __iter__(self):
11
+ return iter(self.items)
12
+
13
+ t = []
14
+ q = [1,2,3]
15
+ for x in CustomIterable(q):
16
+ t.push(x)
17
+ assrt.deepEqual(q, t)
18
+
19
+ assrt.deepEqual(['a', 'b'], list('ab'))
20
+ assrt.ok(q is not list(q))
21
+ assrt.deepEqual(q, list(q))
22
+ assrt.ok(isinstance([], (String, list)))
23
+ assrt.ok(isinstance(1, int))
24
+ assrt.ok(not isinstance(v'new Number(1)', int))
25
+ assrt.ok(not isinstance(1.1, int))
26
+ assrt.ok(isinstance(1.1, float))
27
+ assrt.ok(not isinstance(v'new Number(1.1)', float))
28
+ m = Map()
29
+ m.set('a', 1)
30
+ assrt.equal(len(m), 1)
31
+ s = set()
32
+ s.add(1)
33
+ s.add(2)
34
+ assrt.equal(len(s), 2)
35
+ assrt.deepEqual(list(s), [1, 2])
36
+ assrt.deepEqual(s, {1, 2})
37
+
38
+ assrt.equal(chr(ord('a')), 'a')
39
+ assrt.equal(chr(ord('🐱')), '🐱')
40
+ assrt.equal(bin(3), '0b11')
41
+ assrt.equal(bin(-3), '-0b11')
42
+ assrt.equal(hex(10), '0xa')
43
+ assrt.equal(hex(-10), '-0xa')
44
+ t = []
45
+ for i in s:
46
+ t.push(i)
47
+ assrt.deepEqual(t, [1, 2])
48
+
49
+ t = []
50
+ for i in m:
51
+ t.push(i)
52
+ assrt.deepEqual(t, ['a'])
53
+ t = []
54
+ for c, i in enumerate(m):
55
+ t.push([c, i])
56
+ assrt.deepEqual(t, [[0, 'a']])
57
+ assrt.deepEqual(['y', 'x'], [x for x in reversed('xy')])
58
+
59
+ # Test that the iterator created by iter() is itself iterable
60
+ assrt.deepEqual(s, set(iter(s)))
61
+
62
+ # Test list index/remove/in use the same notion of equality
63
+ a = [1, 2]
64
+ b = [list(a), 3, 4]
65
+ assrt.ok(a in b)
66
+ assrt.equal(b.index(a), 0)
67
+ b.remove(a)
68
+ assrt.equal(len(b), 2)
69
+
70
+ assrt.ok('a' in m)
71
+ assrt.ok(1 in s)
72
+ assrt.ok('1' not in s)
73
+
74
+ # getattr()
75
+ a = {'x':2}
76
+ assrt.equal(getattr(a, 'x'), 2)
77
+ assrt.equal(getattr(a, 'x', 1), 2)
78
+ assrt.equal(getattr(a, 'y', 1), 1)
79
+ assrt.throws(def():getattr(a, 'y');, AttributeError)
80
+
81
+ # int()/float()
82
+ assrt.equal(int('a', 16), 10)
83
+ assrt.throws(def ():int('a');, ValueError)
84
+ assrt.equal(float('10.3'), 10.3)
85
+ assrt.throws(def ():float('a');, ValueError)
86
+ assrt.equal(int(2*1e-7), 0)
87
+ assrt.equal(int(10*1e-7), 0)
88
+ assrt.equal(float(3*1e-7), 3e-7)
89
+
90
+ # sum()
91
+ assrt.equal(6, sum([1, 2, 3]))
92
+ assrt.equal(6, sum(iter([1, 2, 3])))
93
+ assrt.equal(5, sum([1, 2, 3], -1))
94
+ assrt.equal(5, sum(iter([1, 2, 3]), -1))
95
+
96
+ # map()/filter()/zip()
97
+ assrt.deepEqual(list(map(def(a):return a*2;, [1, 2])), [2, 4])
98
+ assrt.deepEqual(list(map(def(a):return a*2;, iter([1, 2]))), [2, 4])
99
+ assrt.deepEqual(list(filter(def(a):return a > 1;, [1, 2])), [2])
100
+ assrt.deepEqual(list(filter(def(a):return a > 1;, iter([1, 2]))), [2])
101
+ assrt.deepEqual(list(zip([1,2], [3,4])), [[1,3], [2, 4]])
102
+
103
+ # lists
104
+ a = [1, 2]
105
+ a.extend([3, 4])
106
+ assrt.deepEqual(a, [1,2,3,4])
107
+ assrt.ok(a == [1,2,3,4])
108
+ s = set([5, 6])
109
+ a.extend(s)
110
+ assrt.deepEqual(a, [1,2,3,4,5,6])
111
+ a.extend('12')
112
+ assrt.deepEqual(a, [1,2,3,4,5,6,'1','2'])
113
+ a = [1,2,3,4]
114
+ for index, val in [[0, 1], [1, 2], [3, 4]]:
115
+ assrt.equal(a.index(val), index)
116
+ assrt.throws(def():a.index(8);, ValueError)
117
+ assrt.throws(def():a.index(1, 1);, ValueError)
118
+ assrt.throws(def():a.index(4, 1, 2);, ValueError)
119
+ assrt.equal(1, a.index(2, 1, 2))
120
+ assrt.throws(def():a.pypop(10);, IndexError)
121
+ assrt.equal(a.pypop(-1), 4)
122
+ assrt.deepEqual(a, [1,2,3])
123
+ assrt.equal(a.remove(2), None)
124
+ assrt.deepEqual(a, [1, 3])
125
+ assrt.throws(def():a.remove(2);, ValueError)
126
+ a = [1,2]
127
+ a.insert(0, 0)
128
+ assrt.deepEqual(a, [0, 1, 2])
129
+ a.insert(-1, 3)
130
+ assrt.deepEqual(a, [0, 1, 3, 2])
131
+ a.insert(a.length, 6)
132
+ assrt.deepEqual(a, [0, 1, 3, 2, 6])
133
+ assrt.deepEqual(a.copy(), a)
134
+ assrt.ok(a is not a.copy())
135
+ assrt.ok(a.copy().extend is not undefined)
136
+ a.clear()
137
+ assrt.equal(a.length, 0)
138
+ assrt.deepEqual(a.as_array(), a)
139
+ assrt.ok(a is not a.as_array())
140
+ assrt.ok(a.as_array().extend == undefined)
141
+ a = [1, 2, 1]
142
+ assrt.equal(a.count(1), 2)
143
+ a = [3, 2, 4, 1]
144
+ a.pysort()
145
+ assrt.deepEqual(a, [1,2,3,4])
146
+ a.pysort(reverse=True)
147
+ assrt.deepEqual(a, [4,3,2,1])
148
+ assrt.deepEqual(a, a.slice())
149
+ assrt.ok(a is not a.slice())
150
+ assrt.ok(a.slice().extend is not undefined)
151
+ assrt.deepEqual(a, a.concat())
152
+ assrt.ok(a is not a.concat())
153
+ assrt.ok(a.concat().extend is not undefined)
154
+ assrt.deepEqual(list(a[ρσ_iterator_symbol]()), a)
155
+ assrt.equal(a.length, a.__len__())
156
+ assrt.equal(a.length, len(a))
157
+ assrt.ok(a.__contains__(a[0]))
158
+ assrt.ok([x for x in [1]].extend is not undefined)
159
+
160
+ class C:
161
+ def __contains__(self, x):
162
+ return x == 1
163
+ assrt.ok(1 in C())
164
+ assrt.ok(2 not in C())
165
+
166
+ # sets
167
+ def test_sets():
168
+ a = set([1, 2, 3])
169
+ assrt.ok(isinstance(a, set))
170
+ assrt.ok(a.has(1))
171
+ assrt.ok(not a.has(9))
172
+ assrt.deepEqual(a, {1,2,3})
173
+ assrt.ok(len(a) == 3)
174
+ assrt.ok(a.length == 3)
175
+ assrt.ok(a.size == 3)
176
+ assrt.ok(not a.has('1'))
177
+ x = a.copy()
178
+ assrt.deepEqual(a, x)
179
+ assrt.ok(a is not x)
180
+ b, c = {}, {}
181
+ a.add(b)
182
+ assrt.ok(b in a)
183
+ assrt.ok(c not in a)
184
+ assrt.ok(None not in a)
185
+ a.add(None)
186
+ assrt.ok(None in a)
187
+ a.discard(None)
188
+ assrt.ok(None not in a)
189
+ a.clear()
190
+ assrt.ok(a.length == 0)
191
+ assrt.deepEqual({1,2,3}.difference({2}, {3}), {1})
192
+ a = {1, 2, 3}
193
+ a.difference_update({2}, {3})
194
+ assrt.deepEqual(a, {1})
195
+ assrt.deepEqual({1,2,3}.intersection({2, 3}, {3}), {3})
196
+ a = {1, 2, 3}
197
+ a.intersection_update({2, 3}, {3})
198
+ assrt.deepEqual(a, {3})
199
+ assrt.ok({1}.isdisjoint({2}))
200
+ assrt.ok(not {1}.isdisjoint({1}))
201
+ assrt.ok({1}.issubset({1, 2}))
202
+ assrt.ok({1}.issubset({1}))
203
+ assrt.ok(not {1}.issubset({2}))
204
+ assrt.ok({1, 2}.issuperset({1, 2}))
205
+ assrt.ok({1, 2}.issuperset({1}))
206
+ assrt.ok(not {1}.issuperset({2}))
207
+ a = set()
208
+ assrt.throws(def():a.pop();, KeyError)
209
+ assrt.equal({1}.pop(), 1)
210
+ assrt.throws(def ():a.remove(1);, KeyError)
211
+ a = {1}
212
+ a.remove(1)
213
+ assrt.equal(a.length, 0)
214
+ assrt.deepEqual({1,2,3}.symmetric_difference({2, 3, 4}), {1, 4})
215
+ a = {1, 2, 3}
216
+ a.symmetric_difference_update({2, 3, 4})
217
+ assrt.deepEqual(a, {1, 4})
218
+ assrt.deepEqual({1,2}.union({3, 4}, {1, 5}), {1, 2, 3, 4, 5})
219
+ a = {1}
220
+ a.update({1, 2})
221
+ assrt.deepEqual(a, {1, 2})
222
+
223
+ test_sets()
224
+ ρσ_set_implementation = ρσ_set_polyfill # noqa:undef
225
+ test_sets()
226
+ ρσ_set_implementation = Set
227
+
228
+ def test_dicts():
229
+ from __python__ import dict_literals, overload_getitem
230
+ assrt.deepEqual({1:1, 2:2}, {1:1, 2:2})
231
+ a = {1:1, 2:2}
232
+ assrt.ok(isinstance(a, dict))
233
+ assrt.ok(1 in a), assrt.ok(3 not in a), assrt.ok('1' not in a)
234
+ assrt.deepEqual(set(a), {1, 2})
235
+ assrt.ok(set(a) == {1, 2})
236
+ assrt.equal({1:2}[1], 2)
237
+ assrt.throws(def():a['1'];, KeyError)
238
+ assrt.equal(a.length, 2), assrt.equal(len(a), 2)
239
+ assrt.equal(a[1], 1)
240
+ a[1] = 3
241
+ assrt.equal(a[1], 3)
242
+ assrt.ok(a is not a.copy()), assrt.deepEqual(a, a.copy())
243
+ a.clear()
244
+ assrt.equal(a.length, 0), assrt.deepEqual(list(a), [])
245
+ a[1] = a[2] = 19
246
+ assrt.deepEqual(a, {1:19, 2:19})
247
+ assrt.deepEqual(set({1:9, 2:8}.keys()), {1, 2})
248
+ assrt.deepEqual(set({1:9, 2:8}.values()), {8, 9})
249
+ items = [list_wrap(x) for x in {1:9, 2:8}.items()]
250
+ items.sort()
251
+ assrt.deepEqual(items, [[1,9], [2, 8]])
252
+ a = {1:1, 2:2}
253
+ assrt.equal(a.get(1), 1), assrt.equal(a.get(3), None)
254
+ assrt.equal(a.setdefault(2, 2), 2)
255
+ assrt.equal(a.setdefault(3, 3), 3), assrt.equal(a[3], 3)
256
+ assrt.deepEqual(dict.fromkeys([1, 2], 3), {1:3, 2:3})
257
+ a = {1:3, 2:3}
258
+ assrt.equal(a.pop(2, 2), 3), assrt.equal(a.pop(2, 2), 2)
259
+ assrt.throws(def(): a.pop(2);, KeyError)
260
+ assrt.deepEqual(a.popitem(), v'[1, 3]')
261
+ assrt.throws(def():a.popitem();, KeyError)
262
+ a = {1:1}
263
+ a.update({2:2, 1:3})
264
+ assrt.deepEqual(a, {1:3, 2:2})
265
+
266
+ test_dicts()
267
+ ρσ_dict_implementation = ρσ_dict_polyfill # noqa:undef
268
+ test_dicts()
269
+ ρσ_dict_implementation = Map
270
+
271
+
272
+ a = {1:1}
273
+ b = None
274
+ assrt.equal(a == b, False)
275
+ assrt.equal(b == a, False)
276
+
277
+ a, b = range(1111111111)
278
+ assrt.equal(a, 0)
279
+ assrt.equal(b, 1)
280
+ assrt.equal(len(range(10)), 10)
281
+ assrt.equal(str(range(10)), 'range(0, 10, 1)')
282
+
283
+ assrt.deepEqual(divmod(7, 3), [2, 1])
284
+ assrt.deepEqual(divmod(-7, 3), [-3, 2])
285
+ assrt.deepEqual(divmod(-7, -3), [2, -1])
286
+ assrt.deepEqual(divmod(7, -3), [-3, -2])
287
+ assrt.throws(def():divmod(1, 0);, ZeroDivisionError)
288
+
289
+
290
+ assrt.equal(1, min(1, 2))
291
+ assrt.equal(2, max(1, 2))
292
+ assrt.equal(2, max(range(3)))
293
+ assrt.equal(0, min(range(3)))
294
+ assrt.equal(0, min([0, 1, 2]))
295
+ assrt.equal(2, max([0, 1, 2]))
296
+ assrt.throws(def(): min();, TypeError)
297
+ assrt.throws(def(): max([]);, TypeError)
298
+ assrt.equal(9, max(defval=9))
299
+ assrt.equal(9, max([], defval=9))
300
+ assrt.equal(1, max([{'k':0}, {'k':1}], key=def(x): return x.k;))
301
+
302
+ # any()/all()
303
+ assrt.equal(any([1, 2, 3]), True)
304
+ assrt.equal(any([0, 0, 1]), True)
305
+ assrt.equal(any([0, False, None, '']), False)
306
+ assrt.equal(any([]), False)
307
+ assrt.equal(any(iter([0, 3, 0])), True)
308
+ assrt.equal(any(iter([])), False)
309
+ assrt.equal(any(range(3)), True)
310
+ assrt.equal(any(range(0)), False)
311
+
312
+ assrt.equal(all([1, 2, 3]), True)
313
+ assrt.equal(all([1, 0, 3]), False)
314
+ assrt.equal(all([True, True, True]), True)
315
+ assrt.equal(all([]), True)
316
+ assrt.equal(all(iter([1, 2, 3])), True)
317
+ assrt.equal(all(iter([1, 0, 3])), False)
318
+ assrt.equal(all(range(1, 4)), True)
319
+ assrt.equal(all(range(0, 3)), False)