Пример #1
0
    def test_call_instance_methods(self):
        s = String('hello')
        self.assertTrue(s.regionMatches(1, 1, 'ell', 0, 3),
                        'method call with boolean true')
        self.assertTrue(s.regionMatches(0, 1, 'ell', 0, 3),
                        'method call with boolean false')
        self.assertTrue(s.regionMatches(1, 'ell', 0, 3),
                        'method call no boolean')

        self.assertTrue(s.regionMatches(1, 1, 'eLl', 0, 3),
                                        'method call ignore case')
        self.assertFalse(s.regionMatches(1, 'eLl', 0, 3), 'should ignore case')
Пример #2
0
    def test_call_instance_methods(self):
        s = String('hello')
        self.assertTrue(s.regionMatches(1, 1, 'ell', 0, 3),
                        'method call with boolean true')
        self.assertTrue(s.regionMatches(0, 1, 'ell', 0, 3),
                        'method call with boolean false')
        self.assertTrue(s.regionMatches(1, 'ell', 0, 3),
                        'method call no boolean')

        self.assertTrue(s.regionMatches(1, 1, 'eLl', 0, 3),
                        'method call ignore case')
        self.assertFalse(s.regionMatches(1, 'eLl', 0, 3), 'should ignore case')
Пример #3
0
assert BigInteger([0x11, 0x11,
                   0x11]).intValue() == 0x111111, 'BigInteger(byte[])'
assert BigInteger(
    -1, [0x11, 0x11, 0x11]).intValue() == -0x111111, 'BigInteger(int, byte[])'

print_test('call static methods')
s1 = String.valueOf(['1', '2', '3'])
s2 = String.valueOf('123')
s3 = String.valueOf(123)
s4 = String.valueOf(123l)
s5 = String.valueOf(['0', '1', '2', '3', 'a', 'b'], 1, 3)
assert s1 == s2 == s3 == s4 == s5, 'String.valueOf method with different arguments'

print_test('call instance methods')
s = String('hello')
assert s.regionMatches(1, 1, 'ell', 0, 3), 'method call with boolean true'
assert s.regionMatches(0, 1, 'ell', 0, 3), 'method call with boolean false'
assert s.regionMatches(1, 'ell', 0, 3), 'method call no boolean'

assert s.regionMatches(1, 1, 'eLl', 0, 3), 'method call ignore case'
assert not s.regionMatches(1, 'eLl', 0, 3), 'should ignore case'

from java.awt import Dimension

print_test('get/set fields')
d = Dimension(3, 9)
assert d.width == 3 and d.height == 9, 'getting fields'
d.width = 42
assert d.width == 42 and d.height == 9, 'setting fields'

#Make sure non-existent fields fail
Пример #4
0
assert BigInteger('1234', 10).intValue() == 1234, 'BigInteger(string)'
assert BigInteger([0x11, 0x11, 0x11]).intValue() == 0x111111, 'BigInteger(byte[])'
assert BigInteger(-1, [0x11, 0x11, 0x11]).intValue() == -0x111111, 'BigInteger(int, byte[])'

print 'call static methods'
s1 = String.valueOf(['1', '2', '3'])
s2 = String.valueOf('123')
s3 = String.valueOf(123)
s4 = String.valueOf(123l)
s5 = String.valueOf(['0', '1', '2', '3', 'a', 'b'], 1, 3)
assert s1 == s2 == s3 == s4 == s5, 'String.valueOf method with different arguments'

print 'call instance methods'
s = String('hello')
assert s.regionMatches(1, 1, 'ell', 0, 3), 'method call with boolean true'
assert s.regionMatches(0, 1, 'ell', 0, 3), 'method call with boolean false'
assert s.regionMatches(1, 'ell', 0, 3), 'method call no boolean'

assert s.regionMatches(1, 1, 'eLl', 0, 3), 'method call ignore case'
assert not s.regionMatches(1, 'eLl', 0, 3), 'should ignore case'

from java.awt import Dimension

print 'get/set fields'
d = Dimension(3,9)
assert d.width == 3 and d.height == 9, 'getting fields'
d.width = 42
assert d.width == 42 and d.height == 9, 'setting fields'

#Make sure non-existent fields fail