Repository navigation
Expand file tree
/
Copy pathtest_methodbinder1.py
More file actions
1147 lines (978 loc) · 56.1 KB
/
Copy pathtest_methodbinder1.py
File metadata and controls
1147 lines (978 loc) · 56.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#####################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you cannot locate the Apache License, Version 2.0, please send an email to
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
# by the terms of the Apache License, Version 2.0.
#
# You must not remove this notice, or any other, from this software.
#
#
#####################################################################################
#
# PART 1. how IronPython choose the CLI method, treat parameters WHEN NO OVERLOADS PRESENT
#
from iptest.assert_util import *
from iptest.type_util import *
skiptest("win32")
load_iron_python_test()
from IronPythonTest.BinderTest import *
myint1, myint2 = myint(20), myint(-20)
mylong1, mylong2 = mylong(3), mylong(-4)
myfloat1, myfloat2 = myfloat(4.5), myfloat(-4.5)
mycomplex1 = mycomplex(3)
funcs = '''
M100 M201 M202 M203 M204 M205 M301 M302 M303 M304
M310 M311 M312 M313 M320 M321 M400 M401 M402 M403
M404 M410 M411 M450 M451
M500 M510 M600 M610 M611 M620 M630
M650 M651 M652 M653
M680 M700 M701
M710 M715
'''.split()
args = '''
NoArg Int32 Double BigInt Bool String SByte Int16 Int64 Single
Byte UInt16 UInt32 UInt64 Char Decml Object I C1 C2
S1 A C6 E1 E2
ArrInt32 ArrI ParamArrInt32 ParamArrI ParamArrS Int32ParamArrInt32 IParamArrI
IListInt Array IEnumerableInt IEnumeratorInt
NullableInt RefInt32 OutInt32
DefValInt32 Int32DefValInt32
'''.split()
arg2func = dict(zip(args, funcs))
func2arg = dict(zip(funcs, args))
TypeE = TypeError
OverF = OverflowError
def _get_funcs(args): return [arg2func[x] for x in args.split()]
def _self_defined_method(name): return len(name) == 4 and name[0] == "M"
def _my_call(func, arg):
if isinstance(arg, tuple):
l = len(arg)
# by purpose
if l == 0: func()
elif l == 1: func(arg[0])
elif l == 2: func(arg[0], arg[1])
elif l == 3: func(arg[0], arg[1], arg[2])
elif l == 4: func(arg[0], arg[1], arg[2], arg[3])
elif l == 5: func(arg[0], arg[1], arg[2], arg[3], arg[4])
elif l == 6: func(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5])
else: func(*arg)
else:
func(arg)
def _helper(func, positiveArgs, flagValue, negativeArgs, exceptType):
for arg in positiveArgs:
try:
_my_call(func, arg)
except Exception, e:
Fail("unexpected exception %s when calling %s with %s\n%s" % (e, func, arg, func.__doc__))
else:
AreEqual(Flag.Value, flagValue)
Flag.Value = -188
for arg in negativeArgs:
try:
_my_call(func, arg)
except Exception, e:
if not isinstance(e, exceptType):
Fail("expected '%s', but got '%s' when calling %s with %s\n%s" % (exceptType, e, func, arg, func.__doc__))
else:
Fail("expected exception (but didn't get one) when calling func %s on args %s\n%s" % (func, arg, func.__doc__))
def test_this_matrix():
'''
This will test the full matrix.
To print the matrix, enable the following flag
'''
print_the_matrix = False
funcnames = "M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400".split()
matrix = (
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( "SByteMax", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "ByteMax", True, True, True, True, True, TypeE, OverF, True, True, True, True, True, True, True, TypeE, True, True, ),
( "Int16Max", True, True, True, True, True, TypeE, OverF, True, True, True, OverF, True, True, True, TypeE, True, True, ),
( "UInt16Max", True, True, True, True, True, TypeE, OverF, OverF, True, True, OverF, True, True, True, TypeE, True, True, ),
( "intMax", True, True, True, True, True, TypeE, OverF, OverF, True, True, OverF, OverF, True, True, TypeE, True, True, ),
( "UInt32Max", OverF, OverF, True, True, True, TypeE, OverF, OverF, True, True, OverF, OverF, True, True, TypeE, True, True, ),
( "Int64Max", OverF, OverF, True, True, True, TypeE, OverF, OverF, True, True, OverF, OverF, OverF, True, TypeE, True, True, ),
( "UInt64Max", OverF, OverF, True, True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, True, TypeE, True, True, ),
( "DecimalMax", OverF, OverF, True, True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "SingleMax", OverF, OverF, True, True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, OverF, TypeE, OverF, True, ),
( "floatMax", OverF, OverF, True, True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, OverF, TypeE, OverF, True, ),
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( "SByteMin", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "ByteMin", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "Int16Min", True, True, True, True, True, TypeE, OverF, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "UInt16Min", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "intMin", True, True, True, True, True, TypeE, OverF, OverF, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "UInt32Min", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "Int64Min", OverF, OverF, True, True, True, TypeE, OverF, OverF, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "UInt64Min", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "DecimalMin", OverF, OverF, True , True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, OverF, TypeE, True , True, ),
( "SingleMin", OverF, OverF, True, True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, OverF, TypeE, OverF, True, ),
( "floatMin", OverF, OverF, True, True, True, TypeE, OverF, OverF, OverF, True, OverF, OverF, OverF, OverF, TypeE, OverF, True, ),
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( "SBytePlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "BytePlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "Int16PlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "UInt16PlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "intPlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( myint1, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "UInt32PlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "Int64PlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "UInt64PlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "DecimalPlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "SinglePlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( "floatPlusOne", True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( myfloat1, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( "SByteMinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "Int16MinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "intMinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( myint2, True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "Int64MinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "DecimalMinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "SingleMinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( "floatMinusOne", True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( myfloat2, True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
################################################## pass in bool #########################################################
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( True, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( False, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
################################################## pass in BigInt #########################################################
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
( 10L, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( -10L, True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
( 1234567890123456L, OverF, OverF, True , True, True, TypeE, OverF, OverF, True, True, OverF, OverF, OverF, True, TypeE, True, True, ),
( mylong1, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
( mylong2, True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ),
################################################## pass in Complex #########################################################
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( (3+0j), TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, ),
( (3+1j), TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, ),
( mycomplex1, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, )
)
if is_silverlight==False:
InvariantCulture = System.Globalization.CultureInfo.InvariantCulture
matrix = list(matrix)
################################################## pass in char #########################################################
#### M201 M680 M202 M203 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
matrix.append((System.Char.Parse('A'), TypeE, TypeE, TypeE, TypeE, True, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, True, True, ))
################################################## pass in float #########################################################
#### single/double becomes Int32, but this does not apply to other primitive types
#### int int? double bigint bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
matrix.append((System.Single.Parse("8.01", InvariantCulture), True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ))
matrix.append((System.Double.Parse("10.2", InvariantCulture), True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ))
matrix.append((System.Single.Parse("-8.1", InvariantCulture), True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ))
matrix.append((System.Double.Parse("-1.8", InvariantCulture), True, True, True, True, True, TypeE, True, True, True, True, OverF, OverF, OverF, OverF, TypeE, True, True, ))
matrix = tuple(matrix)
for scenario in matrix:
if isinstance(scenario[0], str):
value = clr_numbers[scenario[0]]
if print_the_matrix: print '(%18s,' % ('"'+ scenario[0] +'"'),
else:
value = scenario[0]
if print_the_matrix: print '(%18s,' % value ,
for i in range(len(funcnames)):
funcname = funcnames[i]
func = getattr(target, funcname)
if print_the_matrix:
try:
func(value)
print "True, ",
except TypeError:
print "TypeE,",
except OverflowError:
print "OverF,",
print "),"
else:
try:
func(value)
except Exception,e:
if scenario[i+1] not in [TypeE, OverF]:
Fail("unexpected exception %s, when func %s on arg %s (%s)\n%s" % (e, funcname, scenario[0], type(value), func.__doc__))
if isinstance(e, scenario[i+1]): pass
else: Fail("expect %s, but got %s when func %s on arg %s (%s)\n%s" % (scenario[i+1], e, funcname, scenario[0], type(value), func.__doc__))
else:
if scenario[i+1] in [TypeE, OverF]:
Fail("expect %s, but got none when func %s on arg %s (%s)\n%s" % (scenario[i+1], funcname, scenario[0], type(value), func.__doc__))
left = Flag.Value ; Flag.Value = -99 # reset
right = int(funcname[1:])
if left != right:
Fail("left %s != right %s when func %s on arg %s (%s)\n%s" % (left, right, funcname, scenario[0], type(value), func.__doc__))
# these funcs should behavior same as M201(Int32)
# should have NullableInt too ?
for funcname in _get_funcs('RefInt32 ParamArrInt32 Int32ParamArrInt32'):
for scenario in matrix:
if isinstance(scenario[0], str): value = clr_numbers[scenario[0]]
else: value = scenario[0]
func = getattr(target, funcname)
if scenario[1] not in [TypeE, OverF]:
func(value)
left = Flag.Value
right = int(funcname[1:])
if left != right:
Fail("left %s != right %s when func %s on arg %s" % (left, right, funcname, scenario[0]))
Flag.Value = -99 # reset
else:
try: func(value)
except scenario[1]: pass # 1 is M201
else: Fail("expect %s, but got none when func %s on arg %s" % (scenario[1], funcname, scenario[0]))
def test_char_string_asked():
# char asked
_helper(target.M320, ['a', System.Char.MaxValue, System.Char.MinValue, 'abc'[2]], 320, ['abc', ('a b')], TypeError)
# string asked
_helper(target.M205, ['a', System.Char.MaxValue, System.Char.MinValue, 'abc'[2], 'abc', 'a b' ], 205, [('a', 'b'), 23, ], TypeError)
def test_pass_extensible_types():
# number covered by that matrix
# string or char
mystr1, mystr2 = mystr('a'), mystr('abc')
_helper(target.M205, [mystr1, mystr2, ], 205, [], TypeError) # String
_helper(target.M320, [mystr1, ], 320, [mystr2, ], TypeError) # Char
# check the bool conversion result
def test_bool_asked():
for arg in ['a', 3, object(), True]:
target.M204(arg)
Assert(Flag.BValue, "argument is %s" % arg)
Flag.BValue = False
if is_silverlight==False:
for arg in [0, System.Byte.Parse('0'), System.UInt64.Parse('0'), 0.0, 0L, False, None, tuple(), list()]:
target.M204(arg)
Assert(not Flag.BValue, "argument is %s" % (arg,))
Flag.BValue = True
def test_user_defined_conversion():
class CP1:
def __int__(self): return 100
class CP2(object):
def __int__(self): return 99
class CP3: pass
cp1, cp2, cp3 = CP1(), CP2(), CP3()
### 1. not work for Nullable<Int32> required (?)
### 2. (out int): should pass in nothing
### int params int int? ref int defVal int+defVal
works = 'M201 M600 M680 M620 M700 M710 M715'
for fn in works.split():
_helper(getattr(target, fn), [cp1, cp2, ], int(fn[1:]), [cp3, ], TypeError)
for fn in dir(target):
### bool obj
if _self_defined_method(fn) and fn not in (works + 'M204 M400 '):
_helper(getattr(target, fn), [], 0, [cp1, cp2, cp3, ], TypeError)
def test_pass_in_derived_python_types():
class CP1(I): pass
class CP2(C1): pass
class CP3(C2): pass
class CP4(C6, I): pass
cp1, cp2, cp3, cp4 = CP1(), CP2(), CP3(), CP4()
# I asked
_helper(target.M401, [C1(), C2(), S1(), cp1, cp2, cp3, cp4,], 401,[C3(), object()], TypeError)
# C2 asked
_helper(target.M403, [C2(), cp3, ], 403, [C3(), object(), C1(), cp1, cp2, cp4, ], TypeError)
class CP1(A): pass
class CP2(C6): pass
cp1, cp2 = CP1(), CP2()
# A asked
_helper(target.M410, [C6(), cp1, cp2, cp4,], 410, [C3(), object(), C1(), cp3, ], TypeError)
# C6 asked
_helper(target.M411, [C6(), cp2, cp4, ], 411, [C3(), object(), C1(), cp1, cp3,], TypeError)
def test_nullable_int():
_helper(target.M680, [None, 100, 100L, System.Byte.MaxValue, System.UInt32.MinValue, myint1, mylong2, 3.6, ], 680, [(), 3+1j], TypeError)
def test_out_int():
if is_silverlight==False:
_helper(target.M701, [], 701, [1, 10L, None, System.Byte.Parse('3')], TypeError) # not allow to pass in anything
def test_collections():
arrayInt = array_int((10, 20))
tupleInt = ((10, 20), )
listInt = ([10, 20], )
tupleBool = ((True, False, True, True, False), )
tupleLong1, tupleLong2 = ((10L, 20L), ), ((System.Int64.MaxValue, System.Int32.MaxValue * 2),)
arrayByte = array_byte((10, 20))
arrayObj = array_object(['str', 10])
# IList<int>
_helper(target.M650, [arrayInt, tupleInt, listInt, arrayObj, tupleLong1, tupleLong2, ], 650, [arrayByte, ], TypeError)
# arrayObj, tupleLong1, tupleLong2 : conversion happens late
# Array
_helper(target.M651, [arrayInt, arrayObj, arrayByte, ], 651, [listInt, tupleInt, tupleLong1, tupleLong2, ], TypeError)
# IEnumerable[int]
_helper(target.M652, [arrayInt, arrayObj, arrayByte, listInt, tupleInt, tupleLong1, tupleLong2, ], 652, [], TypeError)
# IEnumerator[int]
_helper(target.M653, [], 653, [arrayInt, arrayObj, arrayByte, listInt, tupleInt, tupleLong1, tupleLong2, ], TypeError)
# Int32[]
_helper(target.M500, [arrayInt, tupleInt, tupleLong1, tupleBool, ], 500, [listInt, arrayByte, arrayObj, ], TypeError)
_helper(target.M500, [], 500, [tupleLong2, ], OverflowError)
# params Int32[]
_helper(target.M600, [arrayInt, tupleInt, tupleLong1, tupleBool, ], 600, [listInt, arrayByte, arrayObj, ], TypeError)
_helper(target.M600, [], 600, [tupleLong2, ], OverflowError)
# Int32, params Int32[]
_helper(target.M620, [(10, 10), (10L, 10), (10L, 10L), (10, 10L), (10, arrayInt), (10, (10, 20)), ], 620, [(10, [10, 20]), ], TypeError)
_helper(target.M620, [], 620, [(10, 123456789101234L), ], OverflowError)
arrayI1 = System.Array[I]( (C1(), C2()) )
arrayI2 = System.Array[I]( () )
arrayObj3 = System.Array[object]( (C1(), C2()) )
tupleI = ((C1(), C2()),)
listI = ([C1(), C2()],)
_helper(target.M510, [arrayI1, arrayI2, tupleI, ], 510, [arrayObj3, listI, ], TypeError) # I[]
_helper(target.M610, [arrayI1, arrayI2, tupleI, ], 610, [arrayObj3, listI, ], TypeError) # params I[]
def test_no_arg_asked():
# no args asked
_helper(target.M100, [()], 100, [2, None, (2, None)], TypeError)
def test_enum():
# E1 asked
_helper(target.M450, [E1.A, ], 450, [10, E2.A], TypeError)
# E2: ushort asked
if is_silverlight==False:
_helper(target.M451, [E2.A, ], 451, [10, E1.A, System.UInt16.Parse("3")], TypeError)
def _repeat_with_one_arg(goodStr, getArg):
passSet = _get_funcs(goodStr)
skipSet = []
for fn in passSet:
if fn in skipSet: continue
arg = getArg()
getattr(target, fn)(arg)
left = Flag.Value
right = int(fn[1:])
if left != right:
Fail("left %s != right %s when func %s on arg %s" % (left, right, fn, arg))
for fn in dir(target):
if _self_defined_method(fn) and (fn not in passSet) and (fn not in skipSet):
arg = getArg()
try: getattr(target, fn)(arg)
except TypeError : pass
else: Fail("expect TypeError, but got none when func %s on arg %s" % (fn, arg))
def test_pass_in_none():
test_str = '''
Bool String Object I C1 C2 A C6
ArrInt32 ArrI ParamArrInt32 ParamArrI ParamArrS IParamArrI
IListInt Array IEnumerableInt IEnumeratorInt NullableInt
'''
# Big integers are only nullable in CLR 2
if not is_net40:
test_str = "BigInt " + test_str
_repeat_with_one_arg(test_str, lambda : None)
def test_pass_in_clrReference():
import clr
_repeat_with_one_arg('Object RefInt32 OutInt32', lambda : clr.Reference[int](0))
_repeat_with_one_arg('Object', lambda : clr.Reference[object](None))
_repeat_with_one_arg('Object RefInt32 OutInt32', lambda : clr.Reference[int](10))
_repeat_with_one_arg('Object ', lambda : clr.Reference[float](123.123))
_repeat_with_one_arg('Object', lambda : clr.Reference[type](str)) # ref.Value = (type)
def test_pass_in_nothing():
passSet = _get_funcs('NoArg ParamArrInt32 ParamArrS ParamArrI OutInt32 DefValInt32')
skipSet = [ ] # be empty before release
for fn in passSet:
if fn in skipSet: continue
getattr(target, fn)()
left = Flag.Value
right = int(fn[1:])
if left != right:
Fail("left %s != right %s when func %s on arg Nothing" % (left, right, fn))
for fn in dir(target):
if _self_defined_method(fn) and (fn not in passSet) and (fn not in skipSet):
try: getattr(target, fn)()
except TypeError : pass
else: Fail("expect TypeError, but got none when func %s on arg Nothing" % fn)
def test_other_concern():
target = COtherConcern()
# static void M100()
target.M100()
AreEqual(Flag.Value, 100); Flag.Value = 99
COtherConcern.M100()
AreEqual(Flag.Value, 100); Flag.Value = 99
AssertError(TypeError, target.M100, target)
AssertError(TypeError, COtherConcern.M100, target)
# static void M101(COtherConcern arg)
target.M101(target)
AreEqual(Flag.Value, 101); Flag.Value = 99
COtherConcern.M101(target)
AreEqual(Flag.Value, 101); Flag.Value = 99
AssertError(TypeError, target.M101)
AssertError(TypeError, COtherConcern.M101)
# void M102(COtherConcern arg)
target.M102(target)
AreEqual(Flag.Value, 102); Flag.Value = 99
COtherConcern.M102(target, target)
AreEqual(Flag.Value, 102); Flag.Value = 99
AssertError(TypeError, target.M102)
AssertError(TypeError, COtherConcern.M102, target)
# generic method
target.M200[int](100)
AreEqual(Flag.Value, 200); Flag.Value = 99
target.M200[int](100.1234)
AreEqual(Flag.Value, 200); Flag.Value = 99
target.M200[long](100)
AreEqual(Flag.Value, 200); Flag.Value = 99
AssertError(OverflowError, target.M200[System.Byte], 300)
AssertError(OverflowError, target.M200[int], 12345678901234)
# We should ignore Out attribute on non-byref.
# It's used in native interop scenarios to designate a buffer (StringBUilder, arrays, etc.)
# the caller allocates, passes to the method and expects the callee to populate it with data.
AssertError(TypeError, target.M222)
AreEqual(target.M222(0), None)
AreEqual(Flag.Value, 222)
# what does means when passing in None
target.M300(None)
AreEqual(Flag.Value, 300); Flag.Value = 99
AreEqual(Flag.BValue, True)
target.M300(C1())
AreEqual(Flag.BValue, False)
# void M400(ref Int32 arg1, out Int32 arg2, Int32 arg3) etc...
AreEqual(target.M400(1, 100), (100, 100))
AreEqual(target.M401(1, 100), (100, 100))
AreEqual(target.M402(100, 1), (100, 100))
# default Value
target.M450()
AreEqual(Flag.Value, 80); Flag.Value = 99
# 8 args
target.M500(1,2,3,4,5,6,7,8)
AreEqual(Flag.Value, 500)
AssertError(TypeError, target.M500)
AssertError(TypeError, target.M500, 1)
AssertError(TypeError, target.M500, 1,2,3,4,5,6,7,8,9)
# IDictionary
for x in [ {1:1}, {"str": 3} ]:
target.M550(x)
AreEqual(Flag.Value, 550); Flag.Value = 99
AssertError(TypeError, target.M550, [1, 2])
# not supported
for fn in (target.M600, target.M601, target.M602):
for l in ( {1:'a'}, [1,2], (1,2) ):
AssertError(TypeError, fn, l)
# delegate
def f(x): return x * x
AssertError(TypeError, target.M700, f)
from IronPythonTest import IntIntDelegate
for x in (lambda x: x, lambda x: x*2, f):
target.M700(IntIntDelegate(x))
AreEqual(Flag.Value, x(10)); Flag.Value = 99
target.M701(lambda x: x*2)
AreEqual(Flag.Value, 20); Flag.Value = 99
AssertError(TypeError, target.M701, lambda : 10)
# keywords
x = target.M800(arg1 = 100, arg2 = 200L, arg3 = 'this'); AreEqual(x, 'THIS')
x = target.M800(arg3 = 'Python', arg1 = 100, arg2 = 200L); AreEqual(x, 'PYTHON')
x = target.M800(100, arg3 = 'iron', arg2 = C1()); AreEqual(x, 'IRON')
try: target.M800(100, 'Yes', arg2 = C1())
except TypeError: pass
else: Fail("expect: got multiple values for keyword argument arg2")
# more ref/out sanity check
import clr
def f1(): return clr.Reference[object](None)
def f2(): return clr.Reference[int](10)
def f3(): return clr.Reference[S1](S1())
def f4(): return clr.Reference[C1](C2()) # C2 inherits C1
for (f, a, b, c, d) in [
('M850', False, False, True, False),
('M851', False, False, False, True),
('M852', False, False, True, False),
('M853', False, False, False, True),
]:
expect = (f in 'M850 M852') and S1 or C1
func = getattr(target, f)
for i in range(4):
ref = (f1, f2, f3, f4)[i]()
if (a,b,c,d)[i]:
func(ref); AreEqual(type(ref.Value), expect)
else:
AssertError(TypeError, func, ref)
# call 854
AssertError(TypeError, target.M854, clr.Reference[object](None))
AssertError(TypeError, target.M854, clr.Reference[int](10))
# call 855
AssertError(TypeError, target.M855, clr.Reference[object](None))
AssertError(TypeError, target.M855, clr.Reference[int](10))
# call 854 and 855 with Reference[bool]
target.M854(clr.Reference[bool](True)); AreEqual(Flag.Value, 854)
target.M855(clr.Reference[bool](True)); AreEqual(Flag.Value, 855)
# practical
ref = clr.Reference[int](0)
ref2 = clr.Reference[int](0)
ref.Value = 300
ref2.Value = 100
## M860(ref arg1, arg2, out arg3): arg3 = arg1 + arg2; arg1 = 100;
x = target.M860(ref, 200, ref2)
AreEqual(x, None)
AreEqual(ref.Value, 100)
AreEqual(ref2.Value, 500)
# pass one clr.Reference(), and leave the other one open
ref.Value = 300
AssertError(TypeError, target.M860, ref, 200)
# the other way
x = target.M860(300, 200)
AreEqual(x, (100, 500))
# GOtherConcern<T>
target = GOtherConcern[int]()
for x in [100, 200L, 4.56, myint1]:
target.M100(x)
AreEqual(Flag.Value, 100); Flag.Value = 99
GOtherConcern[int].M100(target, 200)
AreEqual(Flag.Value, 100); Flag.Value = 99
AssertError(TypeError, target.M100, 'abc')
AssertError(OverflowError, target.M100, 12345678901234)
def test_iterator_sequence():
class C:
def __init__(self): self.x = 0
def __iter__(self): return self
def next(self):
if self.x < 10:
y = self.x
self.x += 1
return y
else:
self.x = 0
raise StopIteration
def __len__(self): return 10
# different size
c = C()
list1 = [1, 2, 3]
tuple1 = [4, 5, 6, 7]
str1 = "890123"
all = (list1, tuple1, str1, c)
target = COtherConcern()
for x in all:
# IEnumerable / IEnumerator
target.M620(x)
AreEqual(Flag.Value, len(x)); Flag.Value = 0
# built in types are not IEnumerator, they are enumerable
if not isinstance(x, C):
AssertError(TypeError, target.M621, x)
else:
target.M621(x)
AreEqual(Flag.Value, len(x))
# IEnumerable<char> / IEnumerator<char>
target.M630(x)
AreEqual(Flag.Value, len(x)); Flag.Value = 0
AssertError(TypeError, target.M631, x)
# IEnumerable<int> / IEnumerator<int>
target.M640(x)
AreEqual(Flag.Value, len(x)); Flag.Value = 0
AssertError(TypeError, target.M641, x)
# IList / IList<char> / IList<int>
for x in (list1, tuple1):
target.M622(x)
AreEqual(Flag.Value, len(x))
target.M632(x)
AreEqual(Flag.Value, len(x))
target.M642(x)
AreEqual(Flag.Value, len(x))
for x in (str1, c):
AssertError(TypeError, target.M622, x)
AssertError(TypeError, target.M632, x)
AssertError(TypeError, target.M642, x)
def test_explicit_inheritance():
target = CInheritMany1()
Assert(hasattr(target, "M"))
target.M()
AreEqual(Flag.Value, 100)
I1.M(target); AreEqual(Flag.Value, 100); Flag.Value = 0
target = CInheritMany2()
target.M(); AreEqual(Flag.Value, 201)
I1.M(target); AreEqual(Flag.Value, 200)
target = CInheritMany3()
Assert(not hasattr(target, "M"))
try: target.M()
except AttributeError: pass
else: Fail("Expected AttributeError, got none")
I1.M(target); AreEqual(Flag.Value, 300)
I2.M(target); AreEqual(Flag.Value, 301)
target = CInheritMany4()
target.M(); AreEqual(Flag.Value, 401)
I3[object].M(target); AreEqual(Flag.Value, 400)
AssertError(TypeError, I3[int].M, target)
target = CInheritMany5()
I1.M(target); AreEqual(Flag.Value, 500)
I2.M(target); AreEqual(Flag.Value, 501)
I3[object].M(target); AreEqual(Flag.Value, 502)
target.M(); AreEqual(Flag.Value, 503)
target = CInheritMany6[int]()
target.M(); AreEqual(Flag.Value, 601)
I3[int].M(target); AreEqual(Flag.Value, 600)
AssertError(TypeError, I3[object].M, target)
target = CInheritMany7[int]()
Assert(hasattr(target, "M"))
target.M(); AreEqual(Flag.Value, 700)
I3[int].M(target); AreEqual(Flag.Value, 700)
target = CInheritMany8()
Assert(not hasattr(target, "M"))
try: target.M()
except AttributeError: pass
else: Fail("Expected AttributeError, got none")
I1.M(target); AreEqual(Flag.Value, 800); Flag.Value = 0
I4.M(target, 100); AreEqual(Flag.Value, 801)
# target.M(100) ????
# original repro
from System.Collections.Generic import Dictionary
d = Dictionary[object,object]()
d.GetEnumerator() # not throw
def test_nullable_property_double():
from IronPythonTest import NullableTest
nt = NullableTest()
nt.DProperty = 1
AreEqual(nt.DProperty, 1.0)
nt.DProperty = 2.0
AreEqual(nt.DProperty, 2.0)
nt.DProperty = None
AreEqual(nt.DProperty, None)
@disabled("Merlin 309716")
def test_nullable_property_long():
from IronPythonTest import NullableTest
nt = NullableTest()
nt.LProperty = 1
AreEqual(nt.LProperty, 1L)
nt.LProperty = 2L
AreEqual(nt.LProperty, 2L)
nt.LProperty = None
AreEqual(nt.LProperty, None)
def test_nullable_property_bool():
from IronPythonTest import NullableTest
nt = NullableTest()
nt.BProperty = 1.0
AreEqual(nt.BProperty, True)
nt.BProperty = 0.0
AreEqual(nt.BProperty, False)
nt.BProperty = True
AreEqual(nt.BProperty, True)
nt.BProperty = None
AreEqual(nt.BProperty, None)
def test_nullable_property_enum():
from IronPythonTest import NullableTest
nt = NullableTest()
nt.EProperty = NullableTest.NullableEnums.NE1
AreEqual(nt.EProperty, NullableTest.NullableEnums.NE1)
nt.EProperty = None
AreEqual(nt.EProperty, None)
def test_nullable_parameter():
from IronPythonTest import NullableTest
nt = NullableTest()
result = nt.Method(1)
AreEqual(result, 1.0)
result = nt.Method(2.0)
AreEqual(result, 2.0)
result = nt.Method(None)
AreEqual(result, None)
# Skip on silverlight because the System.Configuration is not available
@skip("silverlight")
def test_xequals_call_for_optimization():
"""
Testing specifically for System.Configuration.ConfigurationManager
because currently its .Equals method will throw null reference
exception when called with null argument. This is a case that could
slip through our dynamic site checks.
"""
import clr
clr.AddReference("System.Configuration");
from System.Configuration import ConfigurationManager
c = ConfigurationManager.ConnectionStrings
#Invoke tests multiple times to make sure DynamicSites are utilized
for i in xrange(3):
AreEqual(1, c.Count)
for i in xrange(3):
count = c.Count
AreEqual(1, count)
AreEqual(c.Count, count)
for i in xrange(3):
#just ensure it doesn't throw
c[0].Name
#Just to be sure this doesn't throw...
c.Count
c.Count
def test_interface_only_access():
pc = InterfaceOnlyTest.PrivateClass
# property set
pc.Hello = InterfaceOnlyTest.PrivateClass
# property get
AreEqual(pc.Hello, pc)
# method call w/ interface param
pc.Foo(pc)
# method call w/ interface ret val
AreEqual(pc.RetInterface(), pc)
# events
global fired
fired = False
def fired(*args):
global fired
fired = True
return args[0]
# add event
pc.MyEvent += fired
# fire event
AreEqual(pc.FireEvent(pc.GetEventArgs()), pc)
AreEqual(fired, True)
# remove event
pc.MyEvent -= fired
def test_ref_bytearr():
target = COtherConcern()
arr = System.Array[System.Byte]((2,3,4))
res = target.M702(arr)
AreEqual(Flag.Value, 702)
AreEqual(type(res), System.Array[System.Byte])
AreEqual(len(res), 0)
i, res = target.M703(arr)
AreEqual(Flag.Value, 703)
AreEqual(i, 42)
AreEqual(type(res), System.Array[System.Byte])
AreEqual(len(res), 0)
i, res = target.M704(arr, arr)
AreEqual(Flag.Value, 704)
AreEqual(i, 42)
AreEqual(arr, res)
sarr = clr.StrongBox[System.Array[System.Byte]](arr)
res = target.M702(sarr)
AreEqual(Flag.Value, 702)
AreEqual(res, None)
res = sarr.Value
AreEqual(type(res), System.Array[System.Byte])
AreEqual(len(res), 0)
sarr.Value = arr
i = target.M703(sarr)
AreEqual(Flag.Value, 703)
AreEqual(i, 42)
AreEqual(len(sarr.Value), 0)
i = target.M704(arr, sarr)
AreEqual(Flag.Value, 704)
AreEqual(i, 42)
AreEqual(sarr.Value, arr)
def test_struct_prop_assign():
from IronPythonTest.BinderTest import SOtherConcern
a = SOtherConcern()
a.P100 = 42
AreEqual(a.P100, 42)
def test_generic_type_inference():
from IronPythonTest import GenericTypeInference, GenericTypeInferenceInstance, SelfEnumerable
from System import Array, Exception, ArgumentException
from System.Collections.Generic import IEnumerable, List
from System.Collections.Generic import Dictionary as Dict
class UserGenericType(GenericTypeInferenceInstance): pass
# public PythonType MInst<T>(T x) -> pytype(T)
AreEqual(UserGenericType().MInst(42), int)
class UserObject(object): pass
userInst = UserObject()
userInt, userLong, userFloat, userComplex, userStr = myint(), mylong(), myfloat(), mycomplex(), mystr()
userTuple, userList, userDict = mytuple(), mylist(), mydict()
objArray = System.Array[object]( (1,2,3) )
doubleArray = System.Array[float]( (1.0,2.0,3.0) )
for target in [GenericTypeInference, GenericTypeInferenceInstance(), UserGenericType()]:
tests = [
# simple single type tests, no constraints
# public static PythonType M0<T>(T x) -> pytypeof(T)
# target method, args, Result, KeywordCall, Exception
(target.M0, (1, ), int, True, None),
(target.M0, (userInst, ), object, True, None),
(target.M0, (userInt, ), object, True, None),
(target.M0, (userStr, ), object, True, None),
(target.M0, (userLong, ), object, True, None),
(target.M0, (userFloat, ), object, True, None),
(target.M0, (userComplex, ), object, True, None),
(target.M0, (userTuple, ), tuple, True, None),
(target.M0, (userList, ), list, True, None),
(target.M0, (userDict, ), dict, True, None),
(target.M0, ((), ), tuple, True, None),
(target.M0, ([], ), list, True, None),
(target.M0, ({}, ), dict, True, None),
# multiple arguments
# public static PythonType M1<T>(T x, T y) -> pytypeof(T)
# public static PythonType M2<T>(T x, T y, T z) -> pytypeof(T)
(target.M1, (1, 2), int, True, None),
(target.M2, (1, 2, 3), int, True, None),
(target.M1, (userInst, userInst), object, True, None),
(target.M2, (userInst, userInst, userInst), object, True, None),
(target.M1, (1, 2.0), None, True, TypeError),
(target.M1, (1, 'abc'), None, True, TypeError),
(target.M1, (object(), userInst), object, True, None),
(target.M1, ([], userList), list, True, None),
# params arguments
# public static PythonType M3<T>(params T[] args) -> pytypeof(T)
(target.M3, (), None, False, TypeError),
(target.M3, (1, ), int, False, None),
(target.M3, (1, 2), int, False, None),
(target.M3, (1, 2, 3), int, False, None),
(target.M3, (1, 2.0), object, False, TypeError),
(target.M3, (1, 'abc'), object, False, TypeError),
(target.M3, (object(), userInst), object, False, None),
(target.M3, ([], userList), list, False, None),
# public static PythonType M4<T>(T x, params T[] args) -> pytypeof(T)
(target.M4, (1, 2), int, False, None),
(target.M4, (1, 2.0), object, False, TypeError),
(target.M4, (1, 'abc'), object, False, TypeError),
(target.M4, (object(), userInst), object, False, None),
(target.M4, ([], userList), list, False, None),
# simple constraints
# public static PythonType M5<T>(T x) where T : class -> pytype(T)
# public static PythonType M6<T>(T x) where T : struct -> pytype(T)
# public static PythonType M7<T>(T x) where T : IList -> pytype(T)
(target.M5, (1, ), None, False, TypeError),
(target.M6, ('abc', ), None, False, TypeError),
(target.M7, (object(), ), None, False, TypeError),
(target.M7, (2, ), None, False, TypeError),
(target.M5, ('abc', ), str, False, None),
(target.M5, (object(), ), object, False, None),
(target.M6, (1, ), int, False, None),
(target.M7, ([], ), list, False, None),
(target.M7, (objArray, ), type(objArray),False, None),
# simple dependent constraints
# public static PythonTuple M8<T0, T1>(T0 x, T1 y) where T0 : T1 -> (pytype(T0), pytype(T1))
(target.M8, (1, 2), (int, int), False, None),
(target.M8, ('abc', object()), (str, object),False, None),
(target.M8, (object(), 'abc'), None, False, TypeError),
(target.M8, (1, object()), (int, object),False, None),
(target.M8, (object(), 1), None, False, TypeError),
# no types can be inferred, error
# public static PythonTuple M9<T0, T1>(object x, T1 y) where T0 : T1
# public static PythonTuple M9b<T0, T1>(T0 x, object y) where T0 : T1
# public static PythonType M11<T>(object x)
# public static PythonType M12<T0, T1>(T0 x, object y)
(target.M9, (1, 2), None, False, TypeError),
(target.M9b, (1, 2), None, False, TypeError),
(target.M9, (object(), object()), None, True, TypeError),
(target.M9b, (object(), object()), None, True, TypeError),
(target.M11, (1, ), None, False, TypeError),
(target.M12, (1, 2), None, False, TypeError),
# multiple dependent constraints
# public static PythonTuple M10<T0, T1, T2>(T0 x, T1 y, T2 z) where T0 : T1 where T1 : T2 -> (pytype(T0), pytype(T1), pytype(T2))
(target.M10, (ArgumentException(), Exception(), object()), (ArgumentException, Exception, object),False, None),
(target.M10, (Exception(), ArgumentException(), object()), None,False, TypeError),
(target.M10, (ArgumentException(), object(), Exception()), None,False, TypeError),
(target.M10, (object(), ArgumentException(), Exception()), None,False, TypeError),
(target.M10, (object(), Exception(), ArgumentException()), None,False, TypeError),
# public static PythonType M11<T>(object x) -> pytypeof(T)
# public static PythonType M12<T0, T1>(T0 x, object y) -> pytypeof(T0)
(target.M11, (object(), ), None, True, TypeError),
(target.M12, (3, object()), None, True, TypeError),
# public static PythonType M13<T>(T x, Func<T> y) -> pytype(T), func()
# public static PythonType M14<T>(T x, Action<T> y) -> pytype(T)
# public static PythonTuple M15<T>(T x, IList<T> y) -> pytype, list...
# public static PythonType M16<T>(T x, Dictionary<T, IList<T>> list) -> pytype, listKeys...
(target.M13, (1, lambda: 42), (object, 42), False, None),