1 from builtins
import object
3 from full_physics
import *
4 from nose.plugins.skip
import Skip, SkipTest
7 test_data = os.path.dirname(__file__) +
"/../../test/unit/data/" 9 if(
not have_full_physics_swig):
16 LuaCallback.__init__(self, ls)
19 def call(self, obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8,obj9,obj10):
20 return LuabindObject(self.
ls, 1)
25 LuaCallback.__init__(self, ls)
28 def call(self, obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8,obj9,obj10):
30 return LuabindObject(self.
ls, 2)
34 if(
not have_full_physics_swig):
36 self.
ls = LuaState(test_data)
40 self.
ls.run(
"test_var = {}\n")
41 test_var = self.
ls.globals.test_var
42 test_var.v1 =
"hi there" 45 t = HeritageFile(test_data +
"heritage_file_test.run")
46 assert t.value_int(
"ALGORITHMS/points_sun") == 10000
48 assert self.
ls.globals.test_var.v1 ==
"hi there" 49 assert self.
ls.globals.test_var.v2 == 1
50 assert self.
ls.globals.test_var.v3 == 2.0
51 assert self.
ls.globals.test_var.test_obj.value_int(
"ALGORITHMS/points_sun") == 10000
53 test_list = [
"a",
"b",
"abc"]
54 test_var.test_list = test_list
55 for l_idx, l_val
in enumerate(test_list):
56 assert self.
ls.globals.test_var.test_list[l_idx+1] == test_list[l_idx]
58 test_dict = {
"k1":
"abc",
"k2":
"cde", 1:
"blah"}
59 test_var.test_dict = test_dict
60 for l_key, l_val
in list(test_dict.items()):
61 assert self.
ls.globals.test_var.test_dict[l_key] == test_dict[l_key]
65 self.
ls.do_file(test_data +
"config.lua")
66 assert self.
ls.globals.config.atmosphere.pressure.surface_pressure.value.value == 96716.6249
71 self.
ls.run(
"test_var = {}\n")
72 test_var = self.
ls.globals.test_var
78 self.
ls.run(
"test_v = test_var.f0()")
79 assert self.
ls.globals.test_v == 1
80 self.
ls.run(
"test_v = test_var:f1()")
81 assert self.
ls.globals.test_v == 2
82 assert test_var.v3 ==
"hi there" 96 def f3(self, v1, v2, v3):
114 self.
ls.run(
"f0(nil,nil,nil,nil,nil,nil,nil,nil,nil)")
116 self.
ls.run(
"f1(3.5)")
118 self.
ls.run(
"f2(3, 4)")
119 assert test_v == 3 + 4
120 self.
ls.run(
"f3(3, 4, 5)")
121 assert test_v == 3 + 4 + 5
122 self.
ls.run(
"val = f3_return(3, 4, 5)")
123 assert g.val == 3 + 4 + 5
128 function test_func(v1, v2) 131 tf = self.
ls.globals.test_func
132 assert tf(1, 2) == 1 + 2 * 2
134 function test_func2() 137 tf2 = self.
ls.globals.test_func2
138 assert tf2() ==
"blah"
def f3_return(self, v1, v2, v3)
def call(self, obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10)
def test_read_and_write(self)
def call(self, obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10)
def test_callback_object(self)