Debian Codegraph @

extra_tests/cffi_tests/cffi1/test_unicode_literals.py

raw symbols SCIP
1 # Generated by pypy/tool/import_cffi.py
2 #
3 # ----------------------------------------------
4 # WARNING, ALL LITERALS IN THIS FILE ARE UNICODE
5 # ----------------------------------------------
6 #
7 from __future__ import unicode_literals
8 #
9 #
10 #
11 from _cffi_backend import FFI
12
13
14 def test_cast():
15 ffi = FFI()
16 assert int(ffi.cast("int", 3.14)) == 3 # unicode literal
17
18 def test_new():
19 ffi = FFI()
20 assert ffi.new("int[]", [3, 4, 5])[2] == 5 # unicode literal
21
22 def test_typeof():
23 ffi = FFI()
24 tp = ffi.typeof("int[51]") # unicode literal
25 assert tp.length == 51
26
27 def test_sizeof():
28 ffi = FFI()
29 assert ffi.sizeof("int[51]") == 51 * 4 # unicode literal
30
31 def test_alignof():
32 ffi = FFI()
33 assert ffi.alignof("int[51]") == 4 # unicode literal
34
35 def test_getctype():
36 ffi = FFI()
37 assert ffi.getctype("int**") == "int * *" # unicode literal
38 assert type(ffi.getctype("int**")) is str
39
40 def test_callback():
41 ffi = FFI()
42 cb = ffi.callback("int(int)", # unicode literal
43 lambda x: x + 42)
44 assert cb(5) == 47