~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Examples/test-suite/lua/overload_template_fast_runme.lua

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-06 10:27:08 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206102708-t37t62i45n595w0e
Tags: 1.3.33-2ubuntu1
* Merge with Debian; remaining changes:
  - Drop support for pike.
  - Use python2.5 instead of python2.4.
  - Clean Runtime/ as well.
  - Force a few environment variables.
* debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require("import")       -- the import fn
 
2
import("overload_template_fast")        -- import code
 
3
for k,v in pairs(overload_template_fast) do _G[k]=v end -- move to global
 
4
 
 
5
-- lua has only one numeric type, so max(int,int) and max(double,double) are the same
 
6
-- whichever one was wrapper first will be used (which is int)
 
7
 
 
8
f = foo()
 
9
 
 
10
a = max(3,4)
 
11
 
 
12
-- mix 1
 
13
assert(mix1("hi") == 101)
 
14
assert(mix1(1.0, 1.0) == 102)
 
15
assert(mix1(1.0) == 103)
 
16
 
 
17
-- mix 2
 
18
assert(mix2("hi") == 101)
 
19
assert(mix2(1.0, 1.0) == 102)
 
20
assert(mix2(1.0) == 103)
 
21
 
 
22
-- mix 3
 
23
assert(mix3("hi") == 101)
 
24
assert(mix3(1.0, 1.0) == 102)
 
25
assert(mix3(1.0) == 103)
 
26
 
 
27
-- Combination 1
 
28
assert(overtparams1(100) == 10)
 
29
assert(overtparams1(100.0, 100) == 20)
 
30
 
 
31
-- Combination 2
 
32
assert(overtparams2(100.0, 100) == 40)
 
33
 
 
34
-- Combination 3
 
35
assert(overloaded() == 60)
 
36
assert(overloaded(100.0, 100) == 70)
 
37
 
 
38
-- Combination 4
 
39
assert(overloadedagain("hello") == 80)
 
40
assert(overloadedagain() == 90)
 
41
 
 
42
-- specializations
 
43
assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works
 
44
assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto
 
45
assert(specialization("hi", "hi") == 201)
 
46
 
 
47
-- simple specialization
 
48
xyz()
 
49
xyz_int()
 
50
xyz_double()
 
51
 
 
52
-- a bit of everything
 
53
assert(overload("hi") == 0)
 
54
assert(overload(1) == 10)
 
55
assert(overload(1, 1) == 20)
 
56
assert(overload(1, "hello") == 30)
 
57
 
 
58
k = Klass()
 
59
assert(overload(k) == 10)
 
60
assert(overload(k, k) == 20)
 
61
assert(overload(k, "hello") == 30)
 
62
-- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c)
 
63
--print(overload(10.0, "hi"))
 
64
--assert(overload(10.0, "hi") == 40)
 
65
assert(overload() == 50)
 
66
 
 
67
-- everything put in a namespace
 
68
assert(nsoverload("hi") == 1000,"nsoverload()")
 
69
assert(nsoverload(1) == 1010,"nsoverload(int t)")
 
70
assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)")
 
71
assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)")
 
72
assert(nsoverload(k) == 1010,"nsoverload(Klass t)")
 
73
assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)")
 
74
assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)")
 
75
-- again this one fails
 
76
--assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)")
 
77
assert(nsoverload() == 1050,"nsoverload(const char *)")
 
78
 
 
79
A_foo(1)
 
80
b = B()
 
81
b:foo(1)