Use first the dotted name variable in the PYSON context
issue11109 review383991002
This commit is contained in:
+1
-1
@@ -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,
|
||||
|
||||
@@ -1244,6 +1244,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')");
|
||||
|
||||
Reference in New Issue
Block a user