2013-06-24 07:36:31 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-05-01 21:57:22 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import absolute_import
|
2017-07-04 03:51:04 +00:00
|
|
|
import sys
|
2012-08-18 02:14:53 +00:00
|
|
|
import unittest
|
|
|
|
from jnius.reflect import autoclass
|
|
|
|
|
2012-08-26 13:53:11 +00:00
|
|
|
|
2012-08-18 02:14:53 +00:00
|
|
|
class ImplementationTest(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_println(self):
|
|
|
|
# System.out.println implies recursive lookup, and j_self assignation.
|
|
|
|
# It was crashing during the implementation :/
|
|
|
|
System = autoclass('java.lang.System')
|
|
|
|
System.out.println('')
|
2012-08-26 13:53:11 +00:00
|
|
|
|
|
|
|
def test_printf(self):
|
|
|
|
System = autoclass('java.lang.System')
|
|
|
|
System.out.printf('hi\n')
|
2012-08-26 15:52:19 +00:00
|
|
|
System.out.printf('hi %s %s\n', 'jnius', 'other string')
|
2013-04-17 15:03:20 +00:00
|
|
|
|
|
|
|
def test_unicode(self):
|
|
|
|
System = autoclass('java.lang.System')
|
2013-06-24 07:36:31 +00:00
|
|
|
System.out.printf(u'é')
|
2017-07-04 03:51:04 +00:00
|
|
|
|
|
|
|
Stack = autoclass('java.util.Stack')
|
|
|
|
stack = Stack()
|
|
|
|
emoji = u'\U0001F602'
|
|
|
|
stack.push(emoji)
|
|
|
|
popped = stack.pop()
|
|
|
|
if sys.version_info < (3, 0):
|
|
|
|
popped = popped.decode('utf-8')
|
|
|
|
self.assertEquals(emoji, popped)
|