Use valueOf Number to convert to Boolean

issue6746
review37671002
This commit is contained in:
Cédric Krier
2017-09-07 21:03:12 +02:00
parent 4297d72ff9
commit 88643f1491
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -218,6 +218,8 @@
value.v.second() || value.v.millisecond());
} else if (moment.isDuration(value.v)) {
return Boolean(value.v.valueOf());
} else if (value.v instanceof Number) {
return Boolean(value.v.valueOf());
} else if (value.v instanceof Object) {
return !jQuery.isEmptyObject(value.v);
} else {
+4
View File
@@ -173,6 +173,10 @@
.decode(eval_), false, "decode(Bool(Sao.TimeDelta()))");
QUnit.strictEqual(new Sao.PYSON.Decoder({value: Sao.TimeDelta(1)})
.decode(eval_), true, "decode(Bool(Sao.TimeDelta(1)))");
QUnit.strictEqual(new Sao.PYSON.Decoder({value: new Sao.Decimal(0)})
.decode(eval_), false, "decode(Bool(Sao.Decimal(0)))");
QUnit.strictEqual(new Sao.PYSON.Decoder({value: new Sao.Decimal(1)})
.decode(eval_), true, "decode(Bool(Sao.Decimal(1)))");
QUnit.strictEqual(new Sao.PYSON.Bool('test').toString(),
"Bool(\"test\")");