aboutsummaryrefslogtreecommitdiff
path: root/tests/objects.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/objects.lua')
-rw-r--r--tests/objects.lua34
1 files changed, 17 insertions, 17 deletions
diff --git a/tests/objects.lua b/tests/objects.lua
index eed02bf..7668e45 100644
--- a/tests/objects.lua
+++ b/tests/objects.lua
@@ -9,27 +9,27 @@ lanes.configure()
9 9
10local linda= lanes.linda() 10local linda= lanes.linda()
11 11
12local start_lane= lanes.gen( "io", 12local start_lane= lanes.gen("io",
13 function( obj1 ) 13 function(obj1 )
14 14
15 assert( obj1.v ) 15 assert(obj1.v )
16 assert( obj1.print ) 16 assert(obj1.print )
17 17
18 assert( obj1 ) 18 assert(obj1 )
19 local mt1= getmetatable(obj1) 19 local mt1= getmetatable(obj1)
20 assert(mt1) 20 assert(mt1)
21 21
22 local k, obj2= linda:receive("") 22 local k, obj2= linda:receive("")
23 assert( obj2 ) 23 assert(k == "" and obj2 )
24 local mt2= getmetatable(obj2) 24 local mt2= getmetatable(obj2)
25 assert(mt2) 25 assert(mt2)
26 assert( mt1==mt2 ) 26 assert(mt1==mt2 )
27 27
28 local v= obj1:print() 28 local v= obj1:print()
29 assert( v=="aaa" ) 29 assert(v=="aaa" )
30 30
31 v= obj2:print() 31 v = obj2:print()
32 assert( v=="bbb" ) 32 assert(v=="bbb" )
33 33
34 return true 34 return true
35 end 35 end
@@ -37,7 +37,7 @@ local start_lane= lanes.gen( "io",
37 37
38 38
39local WR= function(str) 39local WR= function(str)
40 io.stderr:write( tostring(str).."\n") 40 io.stderr:write(tostring(str).."\n")
41end 41end
42 42
43 43
@@ -47,7 +47,7 @@ end
47-- having the methods 'fixed' in the object tables themselves. 47-- having the methods 'fixed' in the object tables themselves.
48-- 48--
49local o_mt= { 49local o_mt= {
50 __index= function( me, key ) 50 __index= function(me, key )
51 if key=="print" then 51 if key=="print" then
52 return function() WR(me.v); return me.v end 52 return function() WR(me.v); return me.v end
53 end 53 end
@@ -56,22 +56,22 @@ local o_mt= {
56 56
57local function obj_gen(v) 57local function obj_gen(v)
58 local o= { v=v } 58 local o= { v=v }
59 setmetatable( o, o_mt ) 59 setmetatable(o, o_mt )
60 return o 60 return o
61end 61end
62 62
63local a= obj_gen("aaa") 63local a= obj_gen("aaa")
64local b= obj_gen("bbb") 64local b= obj_gen("bbb")
65 65
66assert( a and b ) 66assert(a and b )
67 67
68local mt_a= getmetatable(a) 68local mt_a= getmetatable(a)
69local mt_b= getmetatable(b) 69local mt_b= getmetatable(b)
70assert( mt_a and mt_a==mt_b ) 70assert(mt_a and mt_a==mt_b )
71 71
72local h= start_lane(a) -- 1st object as parameter 72local h= start_lane(a) -- 1st object as parameter
73 73
74linda:send( "", b ) -- 2nd object via Linda 74linda:send("", b ) -- 2nd object via Linda
75 75
76assert( h[1]==true ) -- wait for return 76assert(h[1]==true ) -- wait for return
77 77