@@ -12,11 +12,41 @@ def canonizeStringList (stringList):
12
12
return [canonizeString (aString ) for aString in stringList ]
13
13
14
14
def run (autoTester ):
15
- autoTester .check ('min' , min (- 1.1 , - 1 , - 3 ))
16
- autoTester .check ('max' , max (- 1.1 , - 1 , - 3 ))
15
+ autoTester .check ('min' ,
16
+ min (- 1.1 , - 1 , - 3 ),
17
+ min ([- 1.1 , - 1 , - 3 ]),
18
+ min ((- 1.1 , - 1 , - 3 )),
19
+ min ('abc' , 'ABC' , 'xyz' , 'XYZ' ),
20
+ min ('abc' , 'ABC' , 'xyz' , 'XYZ' , key = lambda v : v [1 ]),
21
+ min (['abc' , 'ABC' , 'xyz' , 'XYZ' ]),
22
+ min ([5 ,6 ,7 ,8 ,9 ],[1 ,2 ,3 ,4 ],key = len ),
23
+ min ([[5 ,6 ,7 ,8 ,9 ],[1 ,2 ,3 ,4 ]],default = [1 ,1 ,1 ],key = len ),
24
+ min ([], default = 'zzz' ),
25
+ )
26
+
27
+ autoTester .check ('max' ,
28
+ max (- 1.1 , - 1 , - 3 ),
29
+ max ([- 1.1 , - 1 , - 3 ]),
30
+ max ((- 1.1 , - 1 , - 3 )),
31
+ max ('abc' , 'ABC' , 'xyz' , 'XYZ' ),
32
+ max ('abc' , 'ABC' , 'xyz' , 'XYZ' , key = lambda v : v [1 ]),
33
+ max (['abc' , 'ABC' , 'xyz' , 'XYZ' ]),
34
+ max ([5 ,6 ,7 ,8 ,9 ],[1 ,2 ,3 ,4 ],key = len ),
35
+ max ([[5 ,6 ,7 ,8 ,9 ],[1 ,2 ,3 ,4 ]],default = [1 ,1 ,1 ],key = len ),
36
+ max ([], default = 'zzz' ),
37
+ )
38
+ # autoTester.check ('max', autoTester.expectException(lambda: max () ))
39
+ # autoTester.check ('max', autoTester.expectException(lambda: max (1,2,3,4, default=5) ))
40
+ # autoTester.check ('max', autoTester.expectException(lambda: max (default=5)))
41
+ # autoTester.check ('max', autoTester.expectException(lambda: max ([])))
42
+ # autoTester.check ('max', autoTester.expectException(lambda: max([5,6,7,8,9],[1,2,3,4],default=[1,1,1],key=len) ))
43
+ # autoTester.check ('max', autoTester.expectException(lambda: max ([4, 5, 'xyz', 'XYZ']) ))
44
+
17
45
autoTester .check ('abs' , abs (- 1 ), abs (1 ), abs (0 ), abs (- 0.1 ), abs (0.1 ))
46
+
18
47
autoTester .check ('ord' , ord ('a' ), ord ('e´' [0 ])) # This is the 2 codepoint version
19
-
48
+ autoTester .check ('chr' , chr (97 ), chr (122 ), chr (65 ), chr (90 )) # a z A Z
49
+
20
50
autoTester .check ('round' ,
21
51
round (4.006 ),
22
52
round (4.006 , 2 ),
@@ -104,63 +134,75 @@ def run (autoTester):
104
134
'<br>'
105
135
)
106
136
107
- autoTester .check ("" .isalpha ())
108
- autoTester .check ("123" .isalpha ())
109
- autoTester .check ("abc" .isalpha ())
110
- autoTester .check ("abc123" .isalpha ())
137
+ autoTester .check ("isalpha" ,
138
+ "" .isalpha (),
139
+ "123" .isalpha (),
140
+ "abc" .isalpha (),
141
+ "abc123" .isalpha (),
142
+ )
111
143
112
144
enumerate_list = ['a' , 'b' , 'c' , 'd' , 'e' ]
113
145
# JS does not have tuples so coerce to list of lists
114
- autoTester .check ([list (item ) for item in enumerate (enumerate_list )])
115
- autoTester .check ([list (item ) for item in enumerate (enumerate_list , 1 )])
116
- autoTester .check ([list (item ) for item in enumerate (enumerate_list , start = 2 )])
146
+ autoTester .check ("enumerate" ,
147
+ [list (item ) for item in enumerate (enumerate_list )],
148
+ [list (item ) for item in enumerate (enumerate_list , 1 )],
149
+ [list (item ) for item in enumerate (enumerate_list , start = 2 )]
150
+ )
117
151
118
152
replace_test = "abcabcabcabc"
119
- autoTester .check (replace_test .replace ("c" , "x" ))
120
- autoTester .check (replace_test .replace ("c" , "x" , - 1 ))
121
- autoTester .check (replace_test .replace ("c" , "x" , 0 ))
122
- autoTester .check (replace_test .replace ("c" , "x" , 1 ))
123
- autoTester .check (replace_test .replace ("c" , "x" , 2 ))
124
- autoTester .check (replace_test .replace ("c" , "x" , 10 ))
153
+ autoTester .check ("replace" ,
154
+ replace_test .replace ("c" , "x" ),
155
+ replace_test .replace ("c" , "x" , - 1 ),
156
+ replace_test .replace ("c" , "x" , 0 ),
157
+ replace_test .replace ("c" , "x" , 1 ),
158
+ replace_test .replace ("c" , "x" , 2 ),
159
+ replace_test .replace ("c" , "x" , 10 ),
160
+ )
125
161
126
- autoTester .check (bin (42 ))
127
- autoTester .check (oct (42 ))
128
- autoTester .check (hex (42 ))
129
- autoTester .check (bin (0 ))
130
- autoTester .check (oct (0 ))
131
- autoTester .check (hex (0 ))
132
- autoTester .check (bin (- 42 ))
133
- autoTester .check (oct (- 42 ))
134
- autoTester .check (hex (- 42 ))
162
+ autoTester .check ("bin-oct-hex" ,
163
+ bin (42 ),
164
+ oct (42 ),
165
+ hex (42 ),
166
+ bin (0 ),
167
+ oct (0 ),
168
+ hex (0 ),
169
+ bin (- 42 ),
170
+ oct (- 42 ),
171
+ hex (- 42 ),
172
+ )
135
173
136
174
string_test = "abcdefghijkl"
137
- autoTester .check (string_test .startswith ("" ))
138
- autoTester .check (string_test .startswith ("abcd" ))
139
- autoTester .check (string_test .startswith ("efgh" ))
140
- autoTester .check (string_test .startswith ("efgh" , 2 ))
141
- autoTester .check (string_test .startswith ("efgh" , 4 ))
142
- autoTester .check (string_test .startswith ("abcd" , 0 , 3 ))
143
- autoTester .check (string_test .startswith ("abcd" , 0 , 5 ))
144
- autoTester .check (string_test .startswith ("efgh" , 4 , - 2 ))
145
- autoTester .check (string_test .startswith ("efgh" , 4 , - 6 ))
146
- autoTester .check (string_test .startswith (("abc" ,)))
147
- autoTester .check (string_test .startswith (("abc" , "de" , "gh" )))
148
- autoTester .check (string_test .startswith (("abc" , "de" , "gh" ), 2 ))
149
- autoTester .check (string_test .startswith (("abc" , "de" , "gh" ), 3 ))
150
- autoTester .check (string_test .startswith (("abc" , "defgh" ), 3 , 9 ))
151
- autoTester .check (string_test .startswith (("abc" , "defgh" ), 3 , 6 ))
175
+ autoTester .check ("startswith" ,
176
+ string_test .startswith ("" ),
177
+ string_test .startswith ("abcd" ),
178
+ string_test .startswith ("efgh" ),
179
+ string_test .startswith ("efgh" , 2 ),
180
+ string_test .startswith ("efgh" , 4 ),
181
+ string_test .startswith ("abcd" , 0 , 3 ),
182
+ string_test .startswith ("abcd" , 0 , 5 ),
183
+ string_test .startswith ("efgh" , 4 , - 2 ),
184
+ string_test .startswith ("efgh" , 4 , - 6 ),
185
+ string_test .startswith (("abc" ,)),
186
+ string_test .startswith (("abc" , "de" , "gh" )),
187
+ string_test .startswith (("abc" , "de" , "gh" ), 2 ),
188
+ string_test .startswith (("abc" , "de" , "gh" ), 3 ),
189
+ string_test .startswith (("abc" , "defgh" ), 3 , 9 ),
190
+ string_test .startswith (("abc" , "defgh" ), 3 , 6 ),
191
+ )
152
192
153
- autoTester .check (string_test .endswith ("" ))
154
- autoTester .check (string_test .endswith ("ijkl" ))
155
- autoTester .check (string_test .endswith ("efgh" ))
156
- autoTester .check (string_test .endswith ("efgh" , 2 ))
157
- autoTester .check (string_test .endswith ("abcd" , 0 , 3 ))
158
- autoTester .check (string_test .endswith ("abcd" , 0 , 4 ))
159
- autoTester .check (string_test .endswith ("efgh" , 4 , - 2 ))
160
- autoTester .check (string_test .endswith ("efgh" , 4 , - 4 ))
161
- autoTester .check (string_test .endswith (("ijkl" ,)))
162
- autoTester .check (string_test .endswith (("abc" , "de" , "gh" )))
163
- autoTester .check (string_test .endswith (("abc" , "de" , "gh" ), 3 , - 4 ))
164
- autoTester .check (string_test .endswith (("abc" , "de" , "gh" ), - 6 , - 4 ))
165
- autoTester .check (string_test .endswith (("abc" , "defgh" ), - 3 , 8 ))
166
- autoTester .check (string_test .endswith (("abc" , "defgh" ), - 9 , 8 ))
193
+ autoTester .check ("endswith" ,
194
+ string_test .endswith ("" ),
195
+ string_test .endswith ("ijkl" ),
196
+ string_test .endswith ("efgh" ),
197
+ string_test .endswith ("efgh" , 2 ),
198
+ string_test .endswith ("abcd" , 0 , 3 ),
199
+ string_test .endswith ("abcd" , 0 , 4 ),
200
+ string_test .endswith ("efgh" , 4 , - 2 ),
201
+ string_test .endswith ("efgh" , 4 , - 4 ),
202
+ string_test .endswith (("ijkl" ,)),
203
+ string_test .endswith (("abc" , "de" , "gh" )),
204
+ string_test .endswith (("abc" , "de" , "gh" ), 3 , - 4 ),
205
+ string_test .endswith (("abc" , "de" , "gh" ), - 6 , - 4 ),
206
+ string_test .endswith (("abc" , "defgh" ), - 3 , 8 ),
207
+ string_test .endswith (("abc" , "defgh" ), - 9 , 8 ),
208
+ )
0 commit comments