def test_arg_ClrReference(self):
     import clr
     from IronPythonTest.BinderTest import C1, C2, COverloads_ClrReference
     target = COverloads_ClrReference()
     for (arg, mapping, funcTypeError, funcOverflowError) in [
         (
             lambda: None,
             _merge(_first('M100 M101 M107 '),
                    _second('M102 M104 M105 M106 ')),
             'M103 ',
             '',
         ),
         (
             lambda: clr.Reference[object](None),
             _second('M100 M104 M105 M107 '),
             'M101 M102 M103 M104 M106 ',
             '',
         ),
         (
             lambda: clr.Reference[object](None),
             _second('M100 M104 M105 M107 '),
             'M101 M102 M103 M106 ',
             '',
         ),
         (
             lambda: clr.Reference[int](9),
             _merge(_first('M100 M102 M103 M104 '), _second('M105 M107 ')),
             'M101 M106 ',
             '',
         ),
         (
             lambda: clr.Reference[bool](True),
             _merge(_first('M100 M105 '), _second('M101 M102 M104 M107 ')),
             'M103 M106 ',
             '',
         ),
         (
             lambda: clr.Reference[type](complex),
             _merge(_first('M100 '), _second('M104 M105 M107 ')),
             'M101 M102 M103 M106 ',
             '',
         ),
         (
             lambda: clr.Reference[C1](C1()),
             _merge(_first('M100 M106 M107 '), _second('M104 M105 ')),
             'M101 M102 M103 ',
             '',
         ),
         (
             lambda: clr.Reference[C1](C2()),
             _merge(_first('M100 M106 M107 '), _second('M104 M105 ')),
             'M101 M102 M103 ',
             '',
         ),
     ]:
         self._try_arg(target, arg, mapping, funcTypeError,
                       funcOverflowError)
    def test_other_concerns(self):
        from IronPythonTest.BinderTest import C1, C3, COtherOverloadConcern, Flag
        target = COtherOverloadConcern()
        
        # the one asking for Int32 is private
        target.M100(100)
        self.assertEqual(Flag.Value, 200); Flag.Value = 99
        
        # static / instance
        target.M110(target, 100)
        self.assertEqual(Flag.Value, 110); Flag.Value = 99
        COtherOverloadConcern.M110(100)
        self.assertEqual(Flag.Value, 210); Flag.Value = 99
        
        self.assertRaises(TypeError, COtherOverloadConcern.M110, target, 100)
        
        # static / instance 2
        target.M111(100)
        self.assertEqual(Flag.Value, 111); Flag.Value = 99
        COtherOverloadConcern.M111(target, 100)
        self.assertEqual(Flag.Value, 211); Flag.Value = 99
            
        self.assertRaises(TypeError, target.M111, target, 100)
        self.assertRaises(TypeError, COtherOverloadConcern.M111, 100)
        
        # statics
        target.M120(target, 100)
        self.assertEqual(Flag.Value, 120); Flag.Value = 99
        target.M120(100)
        self.assertEqual(Flag.Value, 220); Flag.Value = 99

        COtherOverloadConcern.M120(target, 100)
        self.assertEqual(Flag.Value, 120); Flag.Value = 99
        COtherOverloadConcern.M120(100)
        self.assertEqual(Flag.Value, 220); Flag.Value = 99
        
        # generic
        target.M130(100)
        self.assertEqual(Flag.Value, 130); Flag.Value = 99

        target.M130(100.1234)
        self.assertEqual(Flag.Value, 230); Flag.Value = 99

        target.M130(C1())
        self.assertEqual(Flag.Value, 230); Flag.Value = 99

        for x in [100, 100.1234]:
            target.M130[int](x)
            self.assertEqual(Flag.Value, 230); Flag.Value = 99

        class PT_C3_int(C3):
            def __int__(self): return 1
        
        # narrowing levels and __int__ conversion
        target.M140(PT_C3_int(), PT_C3_int())
        self.assertEqual(Flag.Value, 140); Flag.Value = 99
 def test_arg_UserDefined(self):
     from IronPythonTest.BinderTest import C1, C2, C3, C6, S1, COverloads_UserDefined
     target = COverloads_UserDefined()
     for (arg, mapping, funcTypeError, funcOverflowError) in [
         (           C1(), _merge(_first('M101 M102 M103 M104 '), _second('M100 ')), 'M105 ', '', ),
         (           C2(), _merge(_first('M102 M103 '), _second('M100 M101 M104 ')), 'M105 ', '', ),
         (           C3(), _second('M103 '), 'M100 M101 M102 M104 M105 ', '', ),
         (           S1(), _first('M100 M101 M102 M103 '), 'M104 M105 ', '', ),
         (           C6(), _second('M103 M105 '), 'M100 M101 M102 M104 ', '', ),
         (     self.pt_i,  _first('M100 M101 M102 M103 '), 'M104 M105 ', '', ),
         (     self.pt_c1, _merge(_first('M101 M102 M103 M104 '), _second('M100 ')), 'M105 ', '', ),
         (  self.pt_i_int, _first('M100 M101 M102 M103 '), 'M104 M105 ', '', ),
         (self.pt_int_old, _second('M102 M103 '), 'M100 M101 M104 M105 ', '', ),
         (self.pt_int_new, _second('M102 M103 '), 'M100 M101 M104 M105 ', '', ),
         ]:
         self._try_arg(target, arg, mapping, funcTypeError, funcOverflowError)