Ejemplo n.º 1
0
    def test_new_style_classes(self):
        class testnewstyle(object):
            pass

        class testnewstyleString(str):
            pass

        class testnewstyleInt(int):
            pass

        strType = type("")
        intType = type(6)

        nobj = testnewstyle()
        self.assertTrue(DemoExtension.newstyleCheck(nobj))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, strType))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))

        nobj = testnewstyleString()
        self.assertTrue(DemoExtension.newstyleCheck(nobj))
        self.assertTrue(DemoExtension.newstyleCheckSubtype(nobj, strType))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))

        nobj = testnewstyleInt()
        self.assertTrue(DemoExtension.newstyleCheck(nobj))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, strType))
        self.assertTrue(DemoExtension.newstyleCheckSubtype(nobj, intType))
Ejemplo n.º 2
0
	def test_new_style_classes(self):

		class testnewstyle(object):
			pass

		class testnewstyleString(str):
			pass

		class testnewstyleInt(int):
			pass

		strType = type("")
		intType = type(6)

		nobj = testnewstyle()
		self.assertTrue(DemoExtension.newstyleCheck(nobj))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, strType))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))

		nobj = testnewstyleString()
		self.assertTrue(DemoExtension.newstyleCheck(nobj))
		self.assertTrue(DemoExtension.newstyleCheckSubtype(nobj, strType))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))

		nobj = testnewstyleInt()
		self.assertTrue(DemoExtension.newstyleCheck(nobj))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, strType))
		self.assertTrue(DemoExtension.newstyleCheckSubtype(nobj, intType))
Ejemplo n.º 3
0
    def test_custom_classes(self):
        from JyNI import JyNIImporter, PyShadowString

        strType = type("")
        intType = type(6)

        nobj = JyNIImporter()
        self.assertTrue(DemoExtension.newstyleCheck(nobj))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, strType))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))

        nobj = PyShadowString("a", "b")
        self.assertTrue(DemoExtension.newstyleCheck(nobj))
        self.assertTrue(DemoExtension.newstyleCheckSubtype(nobj, strType))
        self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))
Ejemplo n.º 4
0
	def test_custom_classes(self):
		from JyNI import JyNIImporter, PyShadowString

		strType = type("")
		intType = type(6)

		nobj = JyNIImporter()
		self.assertTrue(DemoExtension.newstyleCheck(nobj))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, strType))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))

		nobj = PyShadowString("a", "b")
		self.assertTrue(DemoExtension.newstyleCheck(nobj))
		self.assertTrue(DemoExtension.newstyleCheckSubtype(nobj, strType))
		self.assertFalse(DemoExtension.newstyleCheckSubtype(nobj, intType))
Ejemplo n.º 5
0
print ""
print "--------Unicode testing----------"
uc = u'a\xac\u1234\u20ac\U00008000'
print type(uc)
print uc
uc2 = DemoExtension.unicodeTest(uc)
print uc2

print ""
print "--------New-style classes---------"

class testnewstyle(str):
	pass

nobj = testnewstyle()
print "Check conversion of new-style class: "+str(DemoExtension.newstyleCheck(nobj))
print "Check new-style is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj, type("")))

# Let's test instances of custom type that is not necessarily new-style class:
# from JyNI import PyShadowString
# nobj2 = PyShadowString("a", "b")

# print "Check conversion of Java-custom class: "+str(DemoExtension.newstyleCheck(nobj2))
# print "Check custom class is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj2, type("")))
# print "Check custom class is int-subtype (shouldn't be): "+str(DemoExtension.newstyleCheckSubtype(nobj2, type(6)))

print ""
print "======in JyNI-case expect native output after these lines on some consoles======"
print "=====(it is JNI-behavior that native output is displayed after Java output)====="
Ejemplo n.º 6
0
print fruit

print ""
print "--------Unicode testing----------"
uc = u'a\xac\u1234\u20ac\U00008000'
print type(uc)
print uc
uc2 = DemoExtension.unicodeTest(uc)
print uc2

print ""
print "--------New-style classes---------"

class testnewstyle(str):
	pass

nobj = testnewstyle()
print "Check conversion of new-style class: "+str(DemoExtension.newstyleCheck(nobj))
print "Check new-style is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj, type("")))

# Let's test instances of custom type that is not necessarily new-style class:
from JyNI import PyShadowString
nobj2 = PyShadowString("a", "b")

print "Check conversion of Java-custom class: "+str(DemoExtension.newstyleCheck(nobj2))
print "Check custom class is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj2, type("")))
print "Check custom class is int-subtype (shouldn't be): "+str(DemoExtension.newstyleCheckSubtype(nobj2, type(6)))

print ""
print "======in JyNI-case expect native output after these lines on some consoles====="
print "=====(it is a JNI issue that native output is displayed after java output)====="
Ejemplo n.º 7
0
print type(uc)
print uc
uc2 = DemoExtension.unicodeTest(uc)
print uc2

print ""
print "--------New-style classes---------"


class testnewstyle(str):
    pass


nobj = testnewstyle()
print "Check conversion of new-style class: " + str(
    DemoExtension.newstyleCheck(nobj))
print "Check new-style is string-subtype: " + str(
    DemoExtension.newstyleCheckSubtype(nobj, type("")))

# Let's test instances of custom type that is not necessarily new-style class:
# from JyNI import PyShadowString
# nobj2 = PyShadowString("a", "b")

# print "Check conversion of Java-custom class: "+str(DemoExtension.newstyleCheck(nobj2))
# print "Check custom class is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj2, type("")))
# print "Check custom class is int-subtype (shouldn't be): "+str(DemoExtension.newstyleCheckSubtype(nobj2, type(6)))

print ""
print "======in JyNI-case expect native output after these lines on some consoles======"
print "=====(it is JNI-behavior that native output is displayed after Java output)====="
Ejemplo n.º 8
0
print ""
print "--------Unicode testing----------"
uc = u'a\xac\u1234\u20ac\U00008000'
print type(uc)
print uc
uc2 = DemoExtension.unicodeTest(uc)
print uc2

print ""
print "--------New-style classes---------"

class testnewstyle(str):
	pass

nobj = testnewstyle()
print "Check conversion of new-style class: "+str(DemoExtension.newstyleCheck(nobj))
print "Check new-style is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj, type("")))

# Let's test instances of custom type that is not necessarily new-style class:
from JyNI import PyShadowString
nobj2 = PyShadowString("a", "b")

print "Check conversion of Java-custom class: "+str(DemoExtension.newstyleCheck(nobj2))
print "Check custom class is string-subtype: "+str(DemoExtension.newstyleCheckSubtype(nobj2, type("")))
print "Check custom class is int-subtype (shouldn't be): "+str(DemoExtension.newstyleCheckSubtype(nobj2, type(6)))

print ""
print "======in JyNI-case expect native output after these lines on some consoles======"
print "=====(it is JNI-behavior that native output is displayed after Java output)====="