aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/php/overload_template_fast_runme.php
blob: 7aa19f693cf53b569cb658ea0a1e4a6bc25bd103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php

require "tests.php";

$f = foo();

$a = maximum(3, 4);
$b = maximum(3.4, 5.2);

# mix 1
check::equal(mix1("hi"), 101, "mix1(const char*)");

check::equal(mix1(1.0, 1.0), 102, "mix1(double, const double &)");

check::equal(mix1(1.0), 103, "mix1(double)");

# mix 2
check::equal(mix2("hi"), 101, "mix2(const char*)");

check::equal(mix2(1.0, 1.0), 102, "mix2(double, const double &)");

check::equal(mix2(1.0), 103, "mix2(double)");

# mix 3
check::equal(mix3("hi"), 101, "mix3(const char*)");

check::equal(mix3(1.0, 1.0), 102, "mix3(double, const double &)");

check::equal(mix3(1.0), 103, "mix3(double)");

# Combination 1
check::equal(overtparams1(100), 10, "overtparams1(int)");

check::equal(overtparams1(100.0, 100), 20, "overtparams1(double, int)");

# Combination 2
check::equal(overtparams2(100.0, 100), 40, "overtparams2(double, int)");

# Combination 3
check::equal(overloaded(), 60, "overloaded()");

check::equal(overloaded(100.0, 100), 70, "overloaded(double, int)");

# Combination 4
check::equal(overloadedagain("hello"), 80, "overloadedagain(const char *)");

check::equal(overloadedagain(), 90, "overloadedagain(double)");

# specializations
check::equal(specialization(10), 202, "specialization(int)");

check::equal(specialization(10.0), 203, "specialization(double)");

check::equal(specialization(10, 10), 204, "specialization(int, int)");

check::equal(specialization(10.0, 10.0), 205, "specialization(double, double)");

check::equal(specialization("hi", "hi"), 201, "specialization(const char *, const char *)");

# simple specialization
xyz();
xyz_int();
xyz_double();

# a bit of everything
check::equal(overload("hi"), 0, "overload()");

check::equal(overload(1), 10, "overload(int t)");

check::equal(overload(1, 1), 20, "overload(int t, const int &)");

check::equal(overload(1, "hello"), 30, "overload(int t, const char *)");

$k = new Klass();
check::equal(overload($k), 10, "overload(Klass t)");

check::equal(overload($k, $k), 20, "overload(Klass t, const Klass &)");

check::equal(overload($k, "hello"), 30, "overload(Klass t, const char *)");

check::equal(overload(10.0, "hi"), 40, "overload(double t, const char *)");

check::equal(overload(), 50, "overload(const char *)");

# everything put in a namespace
check::equal(nsoverload("hi"), 1000, "nsoverload()");

check::equal(nsoverload(1), 1010, "nsoverload(int t)");

check::equal(nsoverload(1, 1), 1020, "nsoverload(int t, const int &)");

check::equal(nsoverload(1, "hello"), 1030, "nsoverload(int t, const char *)");

check::equal(nsoverload($k), 1010, "nsoverload(Klass t)");

check::equal(nsoverload($k, $k), 1020, "nsoverload(Klass t, const Klass &)");

check::equal(nsoverload($k, "hello"), 1030, "nsoverload(Klass t, const char *)");

check::equal(nsoverload(10.0, "hi"), 1040, "nsoverload(double t, const char *)");

check::equal(nsoverload(), 1050, "nsoverload(const char *)");


A::foo(1);
$b = new B();
$b->foo(1);


check::done();