Fix PYSON.Equal with Array

In javascript, Array comparison doesn't work with '=='. It should use the
Sao.common.compare.

issue5474
review18001002
This commit is contained in:
Cédric Krier
2016-04-15 14:09:35 +07:00
parent 0afceea9a7
commit f3aa2a82ea
2 changed files with 16 additions and 2 deletions
+5 -1
View File
@@ -249,7 +249,11 @@
});
Sao.PYSON.Equal.eval_ = function(value, context) {
return value.s1 == value.s2;
if (value.s1 instanceof Array && value.s2 instanceof Array) {
return Sao.common.compare(value.s1, value.s2);
} else {
return value.s1 == value.s2;
}
};
Sao.PYSON.Greater = Sao.class_(Sao.PYSON.PYSON, {
+11 -1
View File
@@ -312,7 +312,17 @@
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Equal('foo', 'bar'));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
"decode(Equal('test', 'test'))");
"decode(Equal('foo', 'bar'))");
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Equal(['test'], ['test']));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
"decode(Equal(['test'], ['test']))");
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Equal(['foo'], ['bar']));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
"decode(Equal(['foo'], ['bar']))");
});
QUnit.test('PYSON Greater', function() {