PageRenderTime 22ms CodeModel.GetById 1ms app.highlight 15ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/python/overload_template_runme.py

#
Python | 145 lines | 89 code | 45 blank | 11 comment | 39 complexity | c228dd7ca81071543f7f76df065dea06 MD5 | raw file
  1from overload_template import *
  2f = foo()
  3
  4a = maximum(3,4)
  5b = maximum(3.4,5.2)
  6
  7# mix 1
  8if (mix1("hi") != 101):
  9  raise RuntimeError, ("mix1(const char*)")
 10
 11if (mix1(1.0, 1.0) != 102):
 12  raise RuntimeError, ("mix1(double, const double &)")
 13
 14if (mix1(1.0) != 103):
 15  raise RuntimeError, ("mix1(double)")
 16
 17# mix 2
 18if (mix2("hi") != 101):
 19  raise RuntimeError, ("mix2(const char*)")
 20
 21if (mix2(1.0, 1.0) != 102):
 22  raise RuntimeError, ("mix2(double, const double &)")
 23
 24if (mix2(1.0) != 103):
 25  raise RuntimeError, ("mix2(double)")
 26
 27# mix 3
 28if (mix3("hi") != 101):
 29  raise RuntimeError, ("mix3(const char*)")
 30
 31if (mix3(1.0, 1.0) != 102):
 32  raise RuntimeError, ("mix3(double, const double &)")
 33
 34if (mix3(1.0) != 103):
 35  raise RuntimeError, ("mix3(double)")
 36
 37# Combination 1
 38if (overtparams1(100) != 10):
 39  raise RuntimeError, ("overtparams1(int)")
 40
 41if (overtparams1(100.0, 100) != 20):
 42  raise RuntimeError, ("overtparams1(double, int)")
 43
 44# Combination 2
 45if (overtparams2(100.0, 100) != 40):
 46  raise RuntimeError, ("overtparams2(double, int)")
 47
 48# Combination 3
 49if (overloaded() != 60):
 50  raise RuntimeError, ("overloaded()")
 51
 52if (overloaded(100.0, 100) != 70):
 53  raise RuntimeError, ("overloaded(double, int)")
 54
 55# Combination 4
 56if (overloadedagain("hello") != 80):
 57  raise RuntimeError, ("overloadedagain(const char *)")
 58
 59if (overloadedagain() != 90):
 60  raise RuntimeError, ("overloadedagain(double)")
 61
 62# specializations
 63if (specialization(10) != 202):
 64  raise RuntimeError, ("specialization(int)")
 65
 66if (specialization(10.0) != 203):
 67  raise RuntimeError, ("specialization(double)")
 68
 69if (specialization(10, 10) != 204):
 70  raise RuntimeError, ("specialization(int, int)")
 71
 72if (specialization(10.0, 10.0) != 205):
 73  raise RuntimeError, ("specialization(double, double)")
 74
 75if (specialization("hi", "hi") != 201):
 76  raise RuntimeError, ("specialization(const char *, const char *)")
 77
 78
 79# simple specialization
 80xyz()
 81xyz_int()
 82xyz_double()
 83
 84# a bit of everything
 85if (overload("hi") != 0):
 86  raise RuntimeError, ("overload()")
 87
 88if (overload(1) != 10):
 89  raise RuntimeError, ("overload(int t)")
 90
 91if (overload(1, 1) != 20):
 92  raise RuntimeError, ("overload(int t, const int &)")
 93
 94if (overload(1, "hello") != 30):
 95  raise RuntimeError, ("overload(int t, const char *)")
 96
 97k = Klass()
 98if (overload(k) != 10):
 99  raise RuntimeError, ("overload(Klass t)")
100
101if (overload(k, k) != 20):
102  raise RuntimeError, ("overload(Klass t, const Klass &)")
103
104if (overload(k, "hello") != 30):
105  raise RuntimeError, ("overload(Klass t, const char *)")
106
107if (overload(10.0, "hi") != 40):
108  raise RuntimeError, ("overload(double t, const char *)")
109
110if (overload() != 50):
111  raise RuntimeError, ("overload(const char *)")
112
113
114# everything put in a namespace
115if (nsoverload("hi") != 1000):
116  raise RuntimeError, ("nsoverload()")
117
118if (nsoverload(1) != 1010):
119  raise RuntimeError, ("nsoverload(int t)")
120
121if (nsoverload(1, 1) != 1020):
122  raise RuntimeError, ("nsoverload(int t, const int &)")
123
124if (nsoverload(1, "hello") != 1030):
125  raise RuntimeError, ("nsoverload(int t, const char *)")
126
127if (nsoverload(k) != 1010):
128  raise RuntimeError, ("nsoverload(Klass t)")
129
130if (nsoverload(k, k) != 1020):
131  raise RuntimeError, ("nsoverload(Klass t, const Klass &)")
132
133if (nsoverload(k, "hello") != 1030):
134  raise RuntimeError, ("nsoverload(Klass t, const char *)")
135
136if (nsoverload(10.0, "hi") != 1040):
137  raise RuntimeError, ("nsoverload(double t, const char *)")
138
139if (nsoverload() != 1050):
140  raise RuntimeError, ("nsoverload(const char *)")
141
142
143A_foo(1)
144b = B()
145b.foo(1)