"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/Examples/test-suite/lua/abstract_access_runme.lua" (30 Nov 2022, 544 Bytes) of package /linux/misc/swig-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "abstract_access_runme.lua": 3.0.12_vs_4.0.0.

    1 require("import")   -- the import fn
    2 import("abstract_access")   -- import code
    3 
    4 -- catch "undefined" global variables
    5 local env = _ENV -- Lua 5.2
    6 if not env then env = getfenv () end -- Lua 5.1
    7 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
    8 
    9 -- trying to instantiate pure virtual classes
   10 -- should fail
   11 assert(pcall(abstract_access.A)==false)
   12 assert(pcall(abstract_access.B)==false)
   13 assert(pcall(abstract_access.C)==false)
   14 
   15 -- instantiate object
   16 d=abstract_access.D()
   17 
   18 --call fn
   19 assert(d:do_x()==1)