File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1279,7 +1279,7 @@ def test_non_unique_escaper(self):
1279
1279
escapers = [html_escaper , html_escaper ],
1280
1280
)
1281
1281
1282
- def test_variable_reuse (self ):
1282
+ def test_variable_reuse_for_arg_lookup (self ):
1283
1283
code , errs = self .compile_messages (
1284
1284
"""
1285
1285
example = My name is { $name ->
@@ -1293,3 +1293,26 @@ def test_variable_reuse(self):
1293
1293
"""
1294
1294
)
1295
1295
assert not errs
1296
+ # $name should only be looked up once
1297
+ self .assertCodeEqual (
1298
+ code ,
1299
+ """
1300
+ def example(message_args, errors):
1301
+ try:
1302
+ _arg = message_args['name']
1303
+ except (LookupError, TypeError):
1304
+ errors.append(FluentReferenceError('<string>:2:24: Unknown external: name'))
1305
+ _arg = FluentNone('name')
1306
+ _plural_form = plural_form_for_number(_arg)
1307
+ if _arg == 'Peter':
1308
+ _ret = 'Peter11'
1309
+ else:
1310
+ _ret = 'Jane11'
1311
+ _plural_form2 = plural_form_for_number(_arg)
1312
+ if _arg == 'Peter':
1313
+ _ret2 = 'Male'
1314
+ else:
1315
+ _ret2 = 'Female'
1316
+ return f'My name is {_ret}\\ nMy gender is {_ret2}'
1317
+ """ ,
1318
+ )
You can’t perform that action at this time.
0 commit comments