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

« back to all changes in this revision

Viewing changes to Examples/test-suite/lua/li_std_string_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:
8
8
 
9
9
-- helper to check type
10
10
function is_std_string(s) 
11
 
        return type(s)=='userdata' and swig_type(s)=='_p_std__string'
 
11
        return type(s)=='userdata' and swig_type(s)=='std::string *'
12
12
end
13
13
 
14
14
-- std::string by value is just a Lua string
49
49
ok,ex=pcall(test_const_reference_throw)
50
50
assert(ok==false and type(ex)=="string")        -- failed & threw string
51
51
 
 
52
-- const ptrs are now converted to lua strings
 
53
-- they used to be std::string*
52
54
ok,ex=pcall(test_const_pointer_throw)
53
 
assert(ok==false and type(ex)=="userdata")      -- failed & threw object
 
55
assert(ok==false and type(ex)=="string")        -- failed & threw object
54
56
 
55
57
-- ditto non const ptrs 
56
58
ok,ex=pcall(test_pointer_throw)
57
 
assert(ok==false and type(ex)=="userdata")      -- failed & threw object
 
59
assert(ok==false and type(ex)=="string")        -- failed & threw object
58
60
 
59
61
-- testing std::string variables
60
62
-- Global variables
85
85
assert(type(struc.MemberString2)=="string") -- typemaps make this a string
86
86
assert(type(struc.ConstMemberString)=="string")
87
87
 
88
 
struc.ConstMemberString="c"     -- silently ignored
 
88
-- set a const (should fail with error)
 
89
assert(pcall(function () struc.ConstMemberString="c" end)==false)
89
90
--print(struc.MemberString:data(),struc.MemberString2,struc.ConstMemberString:data())
90
91
 
91
92
--check type again
100
100
assert(type(li_std_string.Structure_StaticMemberString2)=="string")
101
101
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
102
102
 
 
103
-- try setting (should fail with error)
103
104
--li_std_string.Structure_StaticMemberString2='e'
104
 
li_std_string.Structure_ConstStaticMemberString='f' -- silently ignored
 
105
assert(pcall(function () li_std_string.Structure_ConstStaticMemberString='f' end)==false)
105
106
--[[print(li_std_string.Structure_StaticMemberString:data(),
106
107
                li_std_string.Structure_StaticMemberString2,
107
108
                li_std_string.Structure_ConstStaticMemberString:data())]]
111
111
assert(type(li_std_string.Structure_StaticMemberString)=="string")
112
112
assert(type(li_std_string.Structure_StaticMemberString2)=="string")
113
113
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
114