Return new instances of PYSON object from PYSON shortcut methods

Closes #12985
This commit is contained in:
Cédric Krier
2024-02-03 19:29:59 +01:00
parent 276c2e6338
commit 45ab83cba5
2 changed files with 6 additions and 3 deletions
+3 -3
View File
@@ -33,13 +33,13 @@
throw 'NotImplementedError';
},
get: function(k, d='') {
return Sao.PYSON.Get(this, k, d);
return new Sao.PYSON.Get(this, k, d);
},
in_: function(obj) {
return Sao.PYSON.In(this, obj);
return new Sao.PYSON.In(this, obj);
},
contains: function(k) {
return Sao.PYSON.In(k, this);
return new Sao.PYSON.In(k, this);
},
toString: function() {
var klass = this.pyson().__class__;
+3
View File
@@ -1294,6 +1294,9 @@
QUnit.strictEqual(
eval_pyson('Or(True, False).toString()'),
"Or(true, false)", "eval_pyson('Or(True, False)').toString()");
QUnit.strictEqual(
eval_pyson('Eval("foo", {}).get("bar").toString()'),
'Get(Eval("foo", {}), "bar", "")');
});
var humanize_tests = [