From 45ab83cba567c227286ea6c5d68e1366ea3e6784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 3 Feb 2024 19:29:59 +0100 Subject: [PATCH] Return new instances of PYSON object from PYSON shortcut methods Closes #12985 --- sao/src/pyson.js | 6 +++--- sao/tests/sao.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sao/src/pyson.js b/sao/src/pyson.js index e22ed5a16c..c7269147b2 100644 --- a/sao/src/pyson.js +++ b/sao/src/pyson.js @@ -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__; diff --git a/sao/tests/sao.js b/sao/tests/sao.js index 74b36efd2a..25f85b4fca 100644 --- a/sao/tests/sao.js +++ b/sao/tests/sao.js @@ -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 = [