1
from __future__ import division
4
from pypy.objspace.flow.model import Constant, Variable
5
from pypy.translator.llvm.test import llvmsnippet
7
from pypy.translator.llvm.test.runtest import *
9
class TestLLVMArray(object):
10
def test_char_array(self):
11
from pypy.rpython.lltypesystem import lltype
12
A = lltype.GcArray(lltype.Char)
14
a = lltype.malloc(A, 5)
21
fp = compile_function(fn, [int])
26
f = compile_function(llvmsnippet.array_simple, [])
29
def test_array1(self):
30
f = compile_function(llvmsnippet.array_simple1, [int])
34
def test_array_setitem(self):
35
f = compile_function(llvmsnippet.array_setitem, [int])
40
def test_array_add(self):
41
f = compile_function(llvmsnippet.array_add, [int, int, int, int, int])
42
assert f(1,2,3,4,0) == 1
43
assert f(1,2,3,4,1) == 2
44
assert f(1,2,3,4,2) == 3
45
assert f(1,2,5,6,3) == 6
47
def test_array_double(self):
48
f = compile_function(llvmsnippet.double_array, [])
51
def test_bool_array(self):
52
f = compile_function(llvmsnippet.bool_array, [])
55
def test_array_arg(self):
56
f = compile_function(llvmsnippet.array_arg, [int])
59
def test_array_len(self):
60
f = compile_function(llvmsnippet.array_len, [])
63
def test_array_append(self):
64
f = compile_function(llvmsnippet.array_append, [int])
69
def test_array_reverse(self):
70
f = compile_function(llvmsnippet.array_reverse, [int])
75
f = compile_function(llvmsnippet.rangetest, [int])
79
def test_array_pop(self):
80
f = compile_function(llvmsnippet.array_pop, [int])
85
def test_newlist_zero_arg(self):
86
f = compile_function(llvmsnippet.newlist_zero_arg, [int])
90
def test_big_array(self):
91
f = compile_function(llvmsnippet.big_array, [int])
95
def test_access_global_array(self):
96
f = compile_function(llvmsnippet.access_global_array, [int, int, int])
99
assert f(i, j, i + j) == i
102
assert f(i, j, 0) == i + j
104
def test_circular_list(self):
105
f = compile_function(llvmsnippet.circular_list, [int])
111
class TestTuple(object):
113
f = compile_function(llvmsnippet.tuple_f1, [int])
118
f = compile_function(llvmsnippet.tuple_f3, [int])
123
def test_constant_tuple(self):
124
f = compile_function(llvmsnippet.constant_tuple, [int])
125
for i in range(3, 7):