summaryrefslogtreecommitdiff
path: root/Examples/test-suite/lua
diff options
context:
space:
mode:
authorArtem Serebriyskiy <v.for.vandal@gmail.com>2014-05-16 13:00:14 +0400
committerArtem Serebriyskiy <v.for.vandal@gmail.com>2014-05-28 22:01:23 +0400
commit2b4c49d017f526f6622cd54547ab9fab31941176 (patch)
treeca8fc33369273de0198f5f51232f2b0b8636e1d6 /Examples/test-suite/lua
parent68347cb723afde8b7bbbbb4d0d8be0f5abae359d (diff)
downloadswig-2b4c49d017f526f6622cd54547ab9fab31941176.tar.gz
Add default __eq implementation
* Renamed SWIG_Lua_equal to SWIG_Lua_class_equal * If class has no __eq implemented, then default __eq is provided. Default __eq compares actual pointers stored inside Lua userdata
Diffstat (limited to 'Examples/test-suite/lua')
-rw-r--r--Examples/test-suite/lua/cpp_basic_runme.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/Examples/test-suite/lua/cpp_basic_runme.lua b/Examples/test-suite/lua/cpp_basic_runme.lua
index c7e0325c5..5a0e1c699 100644
--- a/Examples/test-suite/lua/cpp_basic_runme.lua
+++ b/Examples/test-suite/lua/cpp_basic_runme.lua
@@ -86,3 +86,14 @@ f4_name = tostring(f4)
assert( f2_name == "Foo" )
assert( f3_name == "Foo" )
assert( f4_name == "FooSubSub" )
+
+-- Test __eq implementation supplied by default
+
+-- eq_f1 and eq_f2 must be different userdata with same Foo* pointer. If eq_f1 and eq_f2 are the same userdata (e.g.)
+-- > eq_f1 = smth
+-- > eq_f2 = eq_f1
+-- then default Lua equality comparison kicks in and considers them equal. Access to global_fptr is actually a
+-- function call (internally) and it returns new userdata each time.
+eq_f1 = cb.Bar.global_fptr
+eq_f2 = cb.Bar.global_fptr
+assert( eq_f1 == eq_f2 )