当前位置: 首页>>代码示例>>Python>>正文


Python System.Int64方法代码示例

本文整理汇总了Python中System.Int64方法的典型用法代码示例。如果您正苦于以下问题:Python System.Int64方法的具体用法?Python System.Int64怎么用?Python System.Int64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System的用法示例。


在下文中一共展示了System.Int64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_complex

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_complex(self):
        # Complex tests
        self.assertTrue((2+4j)/(1+1j) == (3+1j))
        self.assertTrue((2+10j)/4.0 == (0.5+2.5j))
        self.assertEqual(1j ** 2, (-1.0+0j))
        self.assertEqual(pow(1j, 2), (-1.0+0j))
        self.assertEqual(1+0j, 1)
        self.assertEqual(1+0j, 1.0)
        self.assertEqual(1+0j, long(1))
        self.assertEqual((1+1j)/long(1), (1+1j))
        self.assertEqual((1j) + long(1), (1+1j))
        self.assertEqual(0j ** 0, 1)
        self.assertEqual(0j ** 0j, 1)
        self.assertEqual(pow(0j, 0), 1)
        self.assertEqual(pow(0j, 0j), 1)

        if is_cli: self.assertEqual((1j) + Int64(), 1j)

        self.assertRaises(TypeError, (lambda:(1+1j)+[]))
        self.assertRaises(TypeError, lambda : type(2j).__dict__['real'].__set__, 2j, 0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_math.py

示例2: test_z_cli_tests

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_z_cli_tests(self):    # runs last to prevent tainting the module w/ CLR names
        import clr
        import System
        self.load_iron_python_test()
        from IronPythonTest import WriteOnly
        if is_netcoreapp:
            clr.AddReference("System.IO.Compression")

        with stdout_trapper() as output:
            help(WriteOnly)
            help(System.IO.Compression)
            help(System.Int64)
        
        x = self.run_help(System.String.Format)
        self.assertTrue(x.find('Format(format: str, arg0: object) -> str') != -1)
        
        x = self.run_help('u.u'.Split('u'))
        # requires std lib
        self.assertTrue('Help on Array[str] object' in x, x)

        # https://github.com/IronLanguages/ironpython2/issues/359
        if not is_mono:
            from System.IO import MemoryStream
            x_class = self.run_help(MemoryStream.Write)

            x_instance = self.run_help(MemoryStream().Write)

            self.assertEqual(x_class, x_instance.replace("built-in function Write", "method_descriptor"))

        #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=11883
        self.assertEqual(dir(System).count('Action'), 1)
        with stdout_trapper() as output: 
            help(System.Action)
        
        self.assertEqual(dir(System).count('Action'), 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:37,代码来源:test_help.py

示例3: test_more_complex

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_more_complex(self):
        self.assertEqual((12+3j)/long(3), (4+1j))
        self.assertEqual(3j - long(5), -5+3j)
        if is_cli: self.assertEqual(3j - Int64(), 3j)
        self.assertRaises(TypeError, (lambda:3j-[]))
        if is_cli: self.assertEqual(pow(5j, Int64()), (1+0j))
        self.assertEqual(pow(5j, long(0)), (1+0j))
        self.assertRaises(TypeError, (lambda:pow(5j, [])))
        if is_cli: self.assertEqual(5j * Int64(), 0)
        self.assertEqual(5j * long(3), 15j)
        self.assertRaises(TypeError, (lambda:(5j*[]))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_math.py

示例4: test_cp13401

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_cp13401(self):
        import System
        import copy
        
        #A few special cases
        self.assertEqual(System.Char.MinValue, copy.copy(System.Char.MinValue))
        self.assertTrue(System.Char.MinValue != copy.copy(System.Char.MaxValue))
        self.assertEqual(System.StringSplitOptions.None, copy.copy(System.StringSplitOptions.None))
        self.assertEqual(System.StringSplitOptions.RemoveEmptyEntries, copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        self.assertTrue(System.StringSplitOptions.None != copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        
        #Normal cases
        test_dict = {   System.Byte : [System.Byte.MinValue, System.Byte.MinValue+1, System.Byte.MaxValue, System.Byte.MaxValue-1],
                        System.Char : [],
                        System.Boolean : [True, False],
                        System.SByte   : [System.SByte.MinValue, System.SByte.MinValue+1, System.SByte.MaxValue, System.SByte.MaxValue-1],
                        System.UInt32  : [System.UInt32.MinValue, System.UInt32.MinValue+1, System.UInt32.MaxValue, System.UInt32.MaxValue-1],
                        System.Int64   : [System.Int64.MinValue, System.Int64.MinValue+1, System.Int64.MaxValue, System.Int64.MaxValue-1],
                        System.Double  : [0.00, 3.14],
                        }
        
        for key in test_dict.keys():
            temp_type = key
            self.assertTrue(hasattr(temp_type, "__reduce_ex__"), 
                "%s has no attribute '%s'" % (str(temp_type), "__reduce_ex__"))
        
            for temp_value in test_dict[key]:
                x = temp_type(temp_value)
                x_copy = copy.copy(x)
                self.assertEqual(x, x_copy)
                self.assertEqual(x, temp_value) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:test_stdmodules.py

示例5: get_values

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def get_values(values, itypes, ftypes):
    """
    This will return structure of values converted to variety of types as a list of tuples:
    [ ...
    ( python_value, [ all_values ] ),
    ... ]

    all_values: Byte, UInt16, UInt32, UInt64, SByte, Int16, Int32, Int64, Single, Double, myint, mylong, myfloat
    """
    all = []
    for v in values:
        sv  = str(v)
        py  = int(v)
        clr = get_clr_values(sv, itypes)
        clr.append(long(py))
        clr.append(myint(py))
        clr.append(mylong(py))
        all.append( (py, clr) )

        py  = long(v)
        clr = get_clr_values(sv, itypes)
        clr.append(py)
        clr.append(myint(py))
        clr.append(mylong(py))
        all.append( (py, clr) )

        py  = float(v)
        clr = get_clr_values(sv, ftypes)
        clr.append(myfloat(py))
        all.append( (py, clr) )

        for imag in [0j, 1j, -1j]:
            py = complex(v + imag)
            all.append( (py, [ py, mycomplex(py) ] ) )

    all.append( (True, [ True ] ))
    all.append( (False, [ False ] ))

    return all 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:41,代码来源:test_numtypes.py

示例6: validate_constructors

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def validate_constructors(self, values):
        types = [Byte, UInt16, UInt32, UInt64, SByte, Int16, Int32, Int64]
        total = 0
        for value in values:
            for first in types:
                v1 = first(value)
                for second in types:
                    v2 = first(second((value)))
                total += 1
        return total 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_numtypes.py

示例7: test_cp34770

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_cp34770(self):
        # Entries added with Int64/UInt64 should be findable with Python long
        from System import Int64, UInt64
        i64 = Int64(1110766100758387874)
        u64 = UInt64(9223372036854775808)

        m = {}
        m[i64] = 'a'
        self.assertEqual(m[long(1110766100758387874)], 'a')

        m[u64] = 'b'
        self.assertEqual(m[long(9223372036854775808)], 'b') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_dict.py

示例8: test_primitive_inheritance

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_primitive_inheritance(self):
        import System
        
        def InheritFromType(t):
            class InheritedType(t): pass
            return InheritedType
        
        self.assertRaises(TypeError, InheritFromType, System.Int64)
        self.assertRaises(TypeError, InheritFromType, System.Boolean)
        
        # isinstance
        
        self.assertTrue(isinstance(System.Int64(), System.Int64) == True)
        self.assertTrue(isinstance(System.Boolean(), System.Boolean) == True)
        
        self.assertTrue(isinstance(1, System.Int64) == False)
        self.assertTrue(isinstance(1, System.Boolean) == False)
        
        class userClass(object): pass
        self.assertTrue(isinstance(userClass(), System.Int64) == False)
        self.assertTrue(isinstance(userClass(), System.Boolean) == False)
        
        # issubclass
        
        self.assertTrue(issubclass(System.Int64, System.Int64) == True)
        self.assertTrue(issubclass(System.Boolean, System.Boolean) == True)
        
        self.assertTrue(issubclass(type(1), System.Int64) == False)
        self.assertTrue(issubclass(type(1), System.Boolean) == False)
        
        self.assertTrue(issubclass(userClass, System.Int64) == False)
        self.assertTrue(issubclass(userClass, System.Boolean) == False) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:34,代码来源:test_isinstance.py

示例9: test_big_1

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_big_1(self):
        from System import SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64
        from System.Numerics import BigInteger
        for (a, m, t,x) in [
                            (7, "ToSByte",  SByte,2),
                            (8, "ToByte",   Byte, 0),
                            (15, "ToInt16", Int16,2),
                            (16, "ToUInt16", UInt16,0),
                            (31, "ToInt32", Int32,2),
                            (32, "ToUInt32", UInt32,0),
                            (63, "ToInt64", Int64,2),
                            (64, "ToUInt64", UInt64,0)
                        ]:

            b = BigInteger(-x ** a )
            left = getattr(b, m)(self.p)
            right = t.MinValue
            self.assertEqual(left, right)

            b = BigInteger(2 ** a -1)
            left = getattr(b, m)(self.p)
            right = t.MaxValue
            self.assertEqual(left, right)

            b = BigInteger(long(0))
            left = getattr(b, m)(self.p)
            right = t.MaxValue - t.MaxValue
            self.assertEqual(left, 0)

            self.assertRaises(OverflowError,getattr(BigInteger(2 ** a ), m),self.p)
            self.assertRaises(OverflowError,getattr(BigInteger(-1 - x ** a ), m),self.p) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:test_ironmath.py

示例10: test_big_2

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_big_2(self):
        from System import Int32, UInt32, Int64, UInt64
        from System.Numerics import BigInteger
        for (a, m, t,x) in [
                            (31, "ToInt32",Int32,2),
                            (32, "ToUInt32",UInt32,0),
                            (63, "ToInt64",Int64,2),
                            (64, "ToUInt64",UInt64,0)
                        ]:

            b = BigInteger(-x ** a )
            left = getattr(b, m)()
            right = t.MinValue
            self.assertEqual(left, right)

            b = BigInteger(2 ** a -1)
            left = getattr(b, m)()
            right = t.MaxValue
            self.assertEqual(left, right)

            b = BigInteger(long(0))
            left = getattr(b, m)()
            right = t.MaxValue - t.MaxValue
            self.assertEqual(left, right)

            self.assertRaises(OverflowError,getattr(BigInteger(2 ** a ), m))
            self.assertRaises(OverflowError,getattr(BigInteger(-1 - x ** a ), m)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:29,代码来源:test_ironmath.py

示例11: test_nonzero

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_nonzero(self):
        from System import Single, Byte, SByte, Int16, UInt16, Int64, UInt64
        for t in [Single, Byte, SByte, Int16, UInt16, Int64, UInt64]:
            self.assertTrue(hasattr(t, '__nonzero__'))
            if t(0): self.assertUnreachable()
            if not t(1): self.assertUnreachable() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_cliclass.py

示例12: validate

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def validate(self, obj, value):
            if isinstance(value, int):
                return value
            if isinstance(value, long):
                # downcast longs that fit in int:
                # note that int(n > sys.maxint) returns a long, so
                # we don't need a condition on this cast
                return int(value)
            if sys.platform == "cli":
                from System import Int64
                if isinstance(value, Int64):
                    return int(value)
            self.error(obj, value) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:traitlets.py

示例13: replaceDict

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def replaceDict(x):
	if hasattr(x,'__iter__'): return map(replaceDict, x)
	if isinstance(x, dsDict): return dict(zip(x.Keys, replaceDict(x.Values)))
	if isinstance(x, Int64): return int(x)
	return x 
开发者ID:dimven,项目名称:SpringNodes,代码行数:7,代码来源:List.ToString.py

示例14: test_z_cli_tests

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_z_cli_tests(self):    # runs last to prevent tainting the module w/ CLR names
        import clr
        import System
        self.load_iron_python_test()
        from IronPythonTest import WriteOnly
        if is_netcoreapp:
            clr.AddReference("System.IO.Compression")

        with stdout_trapper() as output:
            help(WriteOnly)
            help(System.IO.Compression)
            help(System.Int64)
        
        x = self.run_help(System.String.Format)
        self.assertIn('Format(format: str, arg0: object) -> str', x)
        
        x = self.run_help('u.u'.Split('u'))
        # requires std lib
        self.assertTrue('Help on Array[str] object' in x, x)

        #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=4190
        from System.IO import MemoryStream
        x_class = self.run_help(MemoryStream.Write)

        x_instance = self.run_help(MemoryStream().Write)

        self.assertEqual(x_class, x_instance.replace("built-in function Write", "method_descriptor").replace(" method of {}.MemoryStream instance".format(MemoryStream.__module__), ""))

        #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=11883
        self.assertEqual(dir(System).count('Action'), 1)
        with stdout_trapper() as output: 
            help(System.Action)
        
        self.assertEqual(dir(System).count('Action'), 1) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:36,代码来源:test_help.py

示例15: test_cp13401

# 需要导入模块: import System [as 别名]
# 或者: from System import Int64 [as 别名]
def test_cp13401(self):
        import System
        import copy
        
        #A few special cases
        StringSplitOptions_None = getattr(System.StringSplitOptions, "None")
        self.assertEqual(System.Char.MinValue, copy.copy(System.Char.MinValue))
        self.assertTrue(System.Char.MinValue != copy.copy(System.Char.MaxValue))
        self.assertEqual(StringSplitOptions_None, copy.copy(StringSplitOptions_None))
        self.assertEqual(System.StringSplitOptions.RemoveEmptyEntries, copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        self.assertTrue(StringSplitOptions_None != copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        
        #Normal cases
        test_dict = {   System.Byte : [System.Byte.MinValue, System.Byte.MinValue+1, System.Byte.MaxValue, System.Byte.MaxValue-1],
                        System.Char : [],
                        System.Boolean : [True, False],
                        System.SByte   : [System.SByte.MinValue, System.SByte.MinValue+1, System.SByte.MaxValue, System.SByte.MaxValue-1],
                        System.UInt32  : [System.UInt32.MinValue, System.UInt32.MinValue+1, System.UInt32.MaxValue, System.UInt32.MaxValue-1],
                        System.Int64   : [System.Int64.MinValue, System.Int64.MinValue+1, System.Int64.MaxValue, System.Int64.MaxValue-1],
                        System.Double  : [0.00, 3.14],
                        }
        
        for key in test_dict.keys():
            temp_type = key
            self.assertTrue(hasattr(temp_type, "__reduce_ex__"), 
                "%s has no attribute '%s'" % (str(temp_type), "__reduce_ex__"))
        
            for temp_value in test_dict[key]:
                x = temp_type(temp_value)
                x_copy = copy.copy(x)
                self.assertEqual(x, x_copy)
                self.assertEqual(x, temp_value) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:34,代码来源:test_stdmodules.py


注:本文中的System.Int64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。