Use first the dotted name variable in the PYSON context

issue11109
review383991002
(grafted from b0df47b1f914e4e79a2081ac43eca08aeea7244b)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2022-01-11 23:03:06 +01:00
1 parent bc51a97184
commit 25b201225b
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -173,7 +173,7 @@
Sao.PYSON.Eval.eval_ = function(value, context) {
var idx = value.v.indexOf('.');
if (idx >= 0) {
if ((idx >= 0) && !(value.v in context)) {
return Sao.PYSON.Eval.eval_({
'v': value.v.substring(idx + 1),
'd': value.d,
+14
View File
@@ -1234,6 +1234,20 @@
});
});
QUnit.test('PYSON.EVal dot notation in context', function() {
var eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Eval('foo.bar', 0));
var ctx = {
'foo.bar': 1,
'foo': {
'bar': 0,
},
};
QUnit.strictEqual(
new Sao.PYSON.Decoder(ctx).decode(eval_), 1,
"decode(" + JSON.stringify(ctx) + ")");
});
QUnit.test('PYSON eval', function() {
QUnit.strictEqual(eval_pyson('True'), true, "eval_pyson('True')");
QUnit.strictEqual(eval_pyson('False'), false, "eval_pyson('False')");