~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to pypy/translator/llvm/test/test_class.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import division
 
2
 
 
3
import py
 
4
from pypy.objspace.flow.model import Constant, Variable
 
5
from pypy.translator.llvm.test import llvmsnippet
 
6
 
 
7
from pypy.translator.llvm.test.runtest import *
 
8
 
 
9
class TestClass(object):
 
10
    def test_classsimple(self):
 
11
        f = compile_function(llvmsnippet.class_simple, [])
 
12
        assert f() == 14
 
13
 
 
14
    def test_classsimple1(self):
 
15
        f = compile_function(llvmsnippet.class_simple1, [int])
 
16
        assert f(2) == 10
 
17
 
 
18
    def test_id_int(self):
 
19
        f = compile_function(llvmsnippet.id_int, [int])
 
20
        for i in range(1, 20):
 
21
            assert f(i) == i
 
22
 
 
23
    def test_classsimple2(self):
 
24
        f = compile_function(llvmsnippet.class_simple2, [int])
 
25
        assert f(2) == 10
 
26
 
 
27
    def test_inherit1(self):
 
28
        f = compile_function(llvmsnippet.class_inherit1, [])
 
29
        assert f() == 11
 
30
 
 
31
    def test_inherit2(self):
 
32
        f = compile_function(llvmsnippet.class_inherit2, [])
 
33
        assert f() == 1
 
34
 
 
35
    def test_method_of_base_class(self):
 
36
        f = compile_function(llvmsnippet.method_of_base_class, [])
 
37
        assert f() == 14
 
38
 
 
39
    def test_attribute_from_base_class(self):
 
40
        f = compile_function(llvmsnippet.attribute_from_base_class, [])
 
41
        assert f() == 4
 
42
 
 
43
    def test_direct_call_of_virtual_method(self):
 
44
        f = compile_function(llvmsnippet.direct_call_of_virtual_method, [])
 
45
        assert f() == 14
 
46
 
 
47
    def test_flow_type(self):
 
48
        f = compile_function(llvmsnippet.flow_type, [])
 
49
        assert f() == 16
 
50
 
 
51
    def test_merge_class(self):
 
52
        f = compile_function(llvmsnippet.merge_classes, [bool])
 
53
        assert f(True) == 1
 
54
        assert f(False) == 2
 
55
 
 
56
    def test_attribute_instance(self):
 
57
        f = compile_function(llvmsnippet.attribute_instance, [bool])
 
58
        assert f(True) == 1
 
59
        assert f(False) == 2
 
60
 
 
61
    def test_global_instance(self):
 
62
        f = compile_function(llvmsnippet.global_instance, [int])
 
63
        assert f(-1) == llvmsnippet.global_instance(-1)
 
64
        for i in range(20):
 
65
            x = f(i)
 
66
            y = llvmsnippet.global_instance(i)
 
67
            assert x == y
 
68
 
 
69
    def test_getset(self):
 
70
        f = compile_function(llvmsnippet.testgetset, [int])
 
71
        assert f(15) == 25
 
72
 
 
73
    def test_call_degrading_func(self):
 
74
        f = compile_function(llvmsnippet.call_degrading_func, [bool])
 
75
        assert f(True) == llvmsnippet.call_degrading_func(True)
 
76
        assert f(False) == llvmsnippet.call_degrading_func(False)
 
77
    
 
78
    def test_circular_classdef(self):
 
79
        f = compile_function(llvmsnippet.circular_classdef, [])
 
80
        assert f() == 10