Example #1
0
    def test_get_set(self):
        d = Dimension(3, 9)
        self.assertEqual(d.width, 3)
        self.assertEqual(d.height, 9)
        d.width = 42
        self.assertEqual(d.width, 42)
        self.assertEqual(d.height, 9)

        try:
            d.foo
        except AttributeError:
            pass
        else:
            raise AssertionError('d.foo should throw type error')
Example #2
0
    def test_get_set(self):
        d = Dimension(3, 9)
        self.assertEquals(d.width, 3)
        self.assertEquals(d.height, 9)
        d.width = 42
        self.assertEquals(d.width, 42)
        self.assertEquals(d.height, 9)

        try:
            d.foo
        except AttributeError:
            pass
        else:
            raise AssertionError('d.foo should throw type error')
Example #3
0
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
try:
    print d.foo
except AttributeError:
    pass
else:
    raise AssertionError, 'd.foo should throw type error'

print_test('get/set bean properties')

from javax import swing
b1 = swing.JButton()
b1.label = 'foo'
Example #4
0
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
try:
    print d.foo
except AttributeError:
    pass
else:
    raise AssertionError, 'd.foo should throw type error'

print 'get/set bean properties'

from javax import swing
b1 = swing.JButton()
b1.label = 'foo'