Debian Codegraph @

pypy/module/_cffi_backend/test/test_unicode_literals.py

raw symbols SCIP
1 #
2 # ----------------------------------------------
3 # WARNING, ALL LITERALS IN THIS FILE ARE UNICODE
4 # ----------------------------------------------
5 #
6 from __future__ import unicode_literals
7 #
8 #
9 #
10 from pypy.module._cffi_backend.newtype import _clean_cache
11
12
13 class AppTestUnicodeLiterals:
14 spaceconfig = dict(usemodules=('_cffi_backend', ))
15
16 def teardown_method(self, meth):
17 _clean_cache(self.space)
18
19 def test_cast(self):
20 from _cffi_backend import FFI
21 ffi = FFI()
22 assert int(ffi.cast("int", 3.14)) == 3 # unicode literal
23
24 def test_new(self):
25 from _cffi_backend import FFI
26 ffi = FFI()
27 assert ffi.new("int[]", [3, 4, 5])[2] == 5 # unicode literal
28
29 def test_typeof(self):
30 from _cffi_backend import FFI
31 ffi = FFI()
32 tp = ffi.typeof("int[51]") # unicode literal
33 assert tp.length == 51
34
35 def test_sizeof(self):
36 from _cffi_backend import FFI
37 ffi = FFI()
38 assert ffi.sizeof("int[51]") == 51 * 4 # unicode literal
39
40 def test_alignof(self):
41 from _cffi_backend import FFI
42 ffi = FFI()
43 assert ffi.alignof("int[51]") == 4 # unicode literal
44
45 def test_getctype(self):
46 from _cffi_backend import FFI
47 ffi = FFI()
48 assert ffi.getctype("int**") == "int * *" # unicode literal
49 assert type(ffi.getctype("int**")) is str
50
51 def test_callback(self):
52 from _cffi_backend import FFI
53 ffi = FFI()
54 cb = ffi.callback("int(int)", # unicode literal
55 lambda x: x + 42)
56 assert cb(5) == 47