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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- demo of lua swig capacilities (operator overloading)
 
2
require("import")       -- the import fn
 
3
import("exception_order")       -- import lib into global
 
4
eo=exception_order --alias
 
5
 
 
6
-- catching undefined variables
 
7
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
 
8
 
 
9
a = eo.A()
 
10
 
 
11
function try1()
 
12
        a:foo()
 
13
end
 
14
 
 
15
ok,ex=pcall(try1)
 
16
assert(ok==false and swig_type(ex)==swig_type(eo.E1()))
 
17
 
 
18
function try2()
 
19
        a:bar()
 
20
end
 
21
ok,ex=pcall(try2)
 
22
assert(ok==false and swig_type(ex)==swig_type(eo.E2()))
 
23
 
 
24
function try3()
 
25
        a:foobar()
 
26
end
 
27
ok,ex=pcall(try3)
 
28
assert(ok==false and type(ex)=="string")
 
29
-- the SWIG_exception is just an error string
 
30