@@ -96,15 +96,16 @@ foo =
9696 end )
9797
9898 describe (' messages' , function ()
99- local bundle
99+ local bundle , en
100100
101101 before_each (function ()
102102 bundle = FluentBundle (" en" )
103+ en = bundle :get_resource ()
103104 bundle :add_messages (" hi = Hello { $name }!\n foo = bar\n bar = baz\n .bax = qux" )
104105 end )
105106
106107 after_each (function ()
107- bundle = nil
108+ bundle , en = nil , nil
108109 end )
109110
110111 it (' can be accessed with getter' , function ()
@@ -116,10 +117,13 @@ foo =
116117
117118 it (' can be accessed as properties' , function ()
118119 assert .same (" bar" , bundle .foo :format ())
120+ assert .same (" bar" , en .foo :format ())
119121 assert .same (" bar" , bundle [" foo" ]:format ())
120122 assert .same (" baz" , bundle .bar :format ())
123+ assert .same (" baz" , en .bar :format ())
121124 assert .same (" baz" , bundle [" bar" ]:format ())
122125 assert .error (function () return bundle .apple :format () end )
126+ assert .error (function () return en .apple :format () end )
123127 assert .error (function () return bundle [" apple" ]:format () end )
124128 end )
125129
@@ -151,6 +155,7 @@ foo =
151155
152156 it (' preserves attributes when messages are added' , function ()
153157 assert .same (" baz" , bundle .bar ())
158+ assert .same (" baz" , en .bar ())
154159 assert .same (" baz" , bundle :format (" bar" ))
155160 assert .same (" qux" , bundle :get_message (" bar" ):get_attribute (" bax" )())
156161 -- assert.same("qux", bundle["bar.bax"]())
@@ -159,35 +164,52 @@ foo =
159164 -- assert.same("qux", bundle["bar.bax"]())
160165 -- assert.same("qux", bundle.bar:get_attribute("bax")())
161166 assert .same (" baz" , bundle .bar ())
167+ -- TODO fix property accessor on resource
168+ -- assert.same("baz", en.bar())
162169 assert .same (" baz" , bundle :format (" bar" ))
163170 assert .same (" qux" , bundle :get_message (" bar" ):get_attribute (" bax" )())
164171 bundle :add_messages (" bar = rebar" )
165172 assert .same (" rebar" , bundle .bar ())
173+ -- TODO fix property accessor on resource
174+ -- assert.same("rebar", en.bar())
166175 assert .same (" rebar" , bundle :format (" bar" ))
167176 assert .error (function () return bundle :get_message (" bar" ):get_attribute (" bax" )() end )
168177 -- assert.same("qux", bundle.bar.bax())
169178 end )
170179
171- pending (' can be called' , function ()
180+ it (' can be called' , function ()
172181 assert .same (" bar" , bundle .foo ())
182+ assert .same (" bar" , en .foo ())
173183 assert .same (" bar" , bundle [" foo" ]())
184+ assert .same (" bar" , en [" foo" ]())
174185 assert .same (" baz" , bundle .bar ())
186+ assert .same (" baz" , en .bar ())
175187 assert .same (" baz" , bundle [" bar" ]())
188+ assert .same (" baz" , en [" bar" ]())
176189 end )
177190
178- pending (' can be called with parameters' , function ()
191+ it (' can be called with parameters' , function ()
179192 assert .same (" Hello World!" , bundle .hi ({name = " World" }))
193+ assert .same (" Hello World!" , en .hi ({name = " World" }))
180194 assert .same (" Hello World!" , bundle [" hi" ]({name = " World" }))
195+ assert .same (" Hello World!" , en [" hi" ]({name = " World" }))
181196 assert .same (" Hello World!" , bundle [" hi" ]:format ({name = " World" }))
197+ assert .same (" Hello World!" , en [" hi" ]:format ({name = " World" }))
182198 end )
183199
184- pending (' can be cast to strings' , function ()
200+ it (' can be cast to strings' , function ()
185201 assert .same (" baz" , tostring (bundle .bar ))
202+ assert .same (" baz" , tostring (en .bar ))
186203 assert .same (" bar" , tostring (bundle [" foo" ]))
204+ assert .same (" bar" , tostring (en [" foo" ]))
187205 assert .same (" xbar" , " x" .. bundle .foo )
206+ assert .same (" xbar" , " x" .. en .foo )
188207 assert .same (" xbaz" , " x" .. bundle [" bar" ])
208+ assert .same (" xbaz" , " x" .. en [" bar" ])
189209 assert .same (" barx" , bundle .foo .. " x" )
210+ assert .same (" barx" , en .foo .. " x" )
190211 assert .same (" bazx" , bundle [" bar" ] .. " x" )
212+ assert .same (" bazx" , en [" bar" ] .. " x" )
191213 end )
192214
193215 end )
0 commit comments