1
from __future__ import division
4
from pypy.translator.js.test.runtest import compile_function
5
from pypy.translator.llvm.test import llvmsnippet
7
class TestClass(object):
8
def test_classsimple(self):
9
f = compile_function(llvmsnippet.class_simple, [])
12
def test_classsimple1(self):
13
f = compile_function(llvmsnippet.class_simple1, [int])
16
def test_id_int(self):
17
#py.test.skip("Full list support not implemented")
18
f = compile_function(llvmsnippet.id_int, [int])
19
for i in range(1, 20):
22
def test_classsimple2(self):
23
f = compile_function(llvmsnippet.class_simple2, [int])
26
def test_inherit1(self):
27
f = compile_function(llvmsnippet.class_inherit1, [])
30
def test_inherit2(self):
31
#py.test.skip("Inheritance not implemented")
32
#py.test.skip("issue 'null' for Ptr's? or recurse into Ptr.TO?) see: opwriter.py")
33
f = compile_function(llvmsnippet.class_inherit2, [])
36
def test_method_of_base_class(self):
37
#py.test.skip("Inheritance not implemented")
38
#py.test.skip("issue 'null' for Ptr's? or recurse into Ptr.TO?) see: opwriter.py")
39
f = compile_function(llvmsnippet.method_of_base_class, [])
42
def test_attribute_from_base_class(self):
43
#py.test.skip("Inheritance not implemented")
44
f = compile_function(llvmsnippet.attribute_from_base_class, [])
47
def test_direct_call_of_virtual_method(self):
48
#py.test.skip("Inheritance not implemented")
49
#py.test.skip("issue 'null' for Ptr's? or recurse into Ptr.TO?) see: opwriter.py")
50
f = compile_function(llvmsnippet.direct_call_of_virtual_method, [])
53
def test_flow_type(self):
54
#py.test.skip("isinstanceof not implemented")
55
f = compile_function(llvmsnippet.flow_type, [])
58
def test_merge_class(self):
59
#py.test.skip("Inheritance not implemented")
60
f = compile_function(llvmsnippet.merge_classes, [bool])
64
def test_attribute_instance(self):
65
#py.test.skip("Inheritance not implemented")
66
f = compile_function(llvmsnippet.attribute_instance, [bool])
70
def test_global_instance(self): #issue we restart every test with a fresh set of globals
71
f = compile_function(llvmsnippet.global_instance, [int])
72
assert f(-1) == llvmsnippet.global_instance(-1)
75
y = llvmsnippet.global_instance(i)
78
def test_getset(self):
79
#py.test.skip("Basic arguments of const objects not implemented")
80
f = compile_function(llvmsnippet.testgetset, [int])
83
def test_call_degrading_func(self):
84
#py.test.skip("isinstanceof not implemented")
85
f = compile_function(llvmsnippet.call_degrading_func, [bool])
86
assert f(True) == llvmsnippet.call_degrading_func(True)
87
assert f(False) == llvmsnippet.call_degrading_func(False)
89
def test_circular_classdef(self):
90
#py.test.skip("Problems with constant names")
91
#py.test.skip("Inheritance not implemented")
92
f = compile_function(llvmsnippet.circular_classdef, [])
96
def __init__(self, a):
105
def test_circular_class():
106
def circular_class():
110
fn = compile_function(circular_class, [])
117
self.a = [INIT_VAL] * 30
121
def test_init_list():
127
fn = compile_function(init_list, [int])
128
assert fn(3) == INIT_VAL
134
def test_instance_str():
138
fn = compile_function(instance_str, [])
139
assert fn() == '<pypy_translator_js_test_test_class_C instance>'
141
def test_instance_ret():
145
fn = compile_function(instance_ret, [])
146
assert fn() == '<pypy_translator_js_test_test_class_C instance>'