diff options
Diffstat (limited to 'tests/objects.lua')
-rw-r--r-- | tests/objects.lua | 34 |
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 | ||
10 | local linda= lanes.linda() | 10 | local linda= lanes.linda() |
11 | 11 | ||
12 | local start_lane= lanes.gen( "io", | 12 | local 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 | ||
39 | local WR= function(str) | 39 | local WR= function(str) |
40 | io.stderr:write( tostring(str).."\n") | 40 | io.stderr:write(tostring(str).."\n") |
41 | end | 41 | end |
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 | -- |
49 | local o_mt= { | 49 | local 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 | ||
57 | local function obj_gen(v) | 57 | local 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 |
61 | end | 61 | end |
62 | 62 | ||
63 | local a= obj_gen("aaa") | 63 | local a= obj_gen("aaa") |
64 | local b= obj_gen("bbb") | 64 | local b= obj_gen("bbb") |
65 | 65 | ||
66 | assert( a and b ) | 66 | assert(a and b ) |
67 | 67 | ||
68 | local mt_a= getmetatable(a) | 68 | local mt_a= getmetatable(a) |
69 | local mt_b= getmetatable(b) | 69 | local mt_b= getmetatable(b) |
70 | assert( mt_a and mt_a==mt_b ) | 70 | assert(mt_a and mt_a==mt_b ) |
71 | 71 | ||
72 | local h= start_lane(a) -- 1st object as parameter | 72 | local h= start_lane(a) -- 1st object as parameter |
73 | 73 | ||
74 | linda:send( "", b ) -- 2nd object via Linda | 74 | linda:send("", b ) -- 2nd object via Linda |
75 | 75 | ||
76 | assert( h[1]==true ) -- wait for return | 76 | assert(h[1]==true ) -- wait for return |
77 | 77 | ||