Run tests in UTC and use millisecond precision for moment comparison

Backout of changeset d5742068fd8d

issue10846
review389071002
This commit is contained in:
Cédric Krier committed 2021-10-19 00:20:37 +02:00
1 parent 227c084bd9
commit f150cf50fe
4 files changed
+26 -26

No files matched your search

+3
View File
@@ -140,6 +140,9 @@ module.exports = function(grunt) {
args: [
'--no-sandbox',
],
env: {
TZ: 'UTC',
},
},
},
all: ['tests/*.html']
+3 -3
View File
@@ -453,7 +453,7 @@
var values = [value.s1, value.s2];
for (var i=0; i < 2; i++) {
if (values[i] instanceof moment) {
values[i] = values[i].unix();
values[i] = values[i].valueOf();
}
else {
values[i] = Number(values[i]);
@@ -760,10 +760,10 @@
Sao.PYSON.Date.eval_ = function(value, context) {
var date = value.start;
if (date && date.isDateTime) {
date = Sao.Date(date.year(), date.month(), date.date(), true);
date = Sao.Date(date.year(), date.month(), date.date());
}
if (!date || !date.isDate) {
date = Sao.Date(undefined, undefined, undefined, true);
date = Sao.Date();
}
if (value.y) date.year(value.y);
if (value.M) date.month(value.M - 1);
+1 -4
View File
@@ -198,7 +198,7 @@ var Sao = {};
}
};
Sao.Date = function(year, month, day, utc) {
Sao.Date = function(year, month, day) {
var date;
if (month === undefined) {
date = moment(year);
@@ -207,9 +207,6 @@ var Sao = {};
else {
date = moment();
}
if (utc) {
date.utc();
}
date.year(year);
date.month(month);
date.date(day);
+19 -19
View File
@@ -468,18 +468,18 @@
'Date(2020, 0, 2)))');
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
Sao.Date(2020, 0, 1, true)));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
'decode(Greater(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0), ' +
'Date(2020, 0, 1, true)))');
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000),
Sao.Date(2020, 0, 1)));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
'decode(Greater(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000), ' +
'Date(2020, 0, 1)))');
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
Sao.Date(2020, 0, 1, true), true));
Sao.Date(2020, 0, 1), true));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
'decode(Greater(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0), ' +
'Date(2020, 0, 1, true), true))');
'Date(2020, 0, 1), true))');
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
@@ -490,7 +490,7 @@
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
new Sao.PYSON.Date(2020, 1, 1),
Sao.Date(2020, 0, 1, true)));
Sao.Date(2020, 0, 1)));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
'decode(Greater(PYSON.Date(2020, 1, 1), Date(2020, 0, 1)))');
@@ -587,10 +587,10 @@
"Less(0, 1, false)");
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000),
Sao.Date(2020, 0, 1)));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
'decode(Less(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0), ' +
'decode(Less(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000), ' +
'Date(2020, 0, 1)))');
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
@@ -615,10 +615,10 @@
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
new Sao.PYSON.Date(2020, 1, 1),
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 1, 0)));
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000)));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
'decode(Less(PYSON.Date(2020, 1, 1), ' +
'PYSON.DateTime(2020, 1, 1, 0, 0, 1, 0)))');
'PYSON.DateTime(2020, 1, 1, 0, 0, 1000)))');
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
@@ -827,27 +827,27 @@
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Date(2010, 1, 12));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
Sao.Date(2010, 0, 12, true).valueOf());
new Date(2010, 0, 12).valueOf());
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Date(2010, 1, 12, -1));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
Sao.Date(2009, 0, 12, true).valueOf());
new Date(2009, 0, 12).valueOf());
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Date(2010, 1, 12, 0, 12));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
Sao.Date(2011, 0, 12, true).valueOf());
new Date(2011, 0, 12).valueOf());
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Date(2010, 1, 12, 0, 0, -7));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
Sao.Date(2010, 0, 5, true).valueOf());
new Date(2010, 0, 5).valueOf());
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Date(2010, 2, 22));
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
Sao.Date(2010, 1, 22, true).valueOf());
new Date(2010, 1, 22).valueOf());
QUnit.strictEqual(
new Sao.PYSON.Date(2010, 1, 12, -1, 12, -7).toString(),
@@ -876,7 +876,7 @@
QUnit.strictEqual(new Sao.PYSON.Decoder(
{'datetime': datetime}).decode(eval_).valueOf(),
Sao.Date(2000, 1, 1, true).valueOf());
Sao.Date(2000, 1, 1).valueOf());
eval_ = new Sao.PYSON.Encoder().encode(
new Sao.PYSON.Date(
@@ -886,7 +886,7 @@
QUnit.strictEqual(new Sao.PYSON.Decoder(
{'foo': 'bar'}).decode(eval_).valueOf(),
Sao.Date(undefined, undefined, undefined, true).valueOf());
Sao.Date().valueOf());
});
QUnit.test('PYSON DateTime', function() {