2021-02-04 11:26:15 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
// Test cases for version comparison
|
|
|
|
|
|
|
|
const JsUnit = imports.jsUnit;
|
|
|
|
|
2023-08-10 15:50:08 +00:00
|
|
|
import 'resource:///org/gnome/shell/ui/environment.js';
|
2021-02-04 11:26:15 +00:00
|
|
|
|
2023-08-10 15:50:08 +00:00
|
|
|
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
|
2021-02-04 11:26:15 +00:00
|
|
|
|
|
|
|
const tests = [
|
2023-07-10 05:59:46 +00:00
|
|
|
{
|
|
|
|
v1: '40',
|
|
|
|
v2: '40',
|
|
|
|
res: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40',
|
|
|
|
v2: '42',
|
|
|
|
res: -1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '42',
|
|
|
|
v2: '40',
|
|
|
|
res: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '3.38.0',
|
|
|
|
v2: '40',
|
|
|
|
res: -1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40',
|
|
|
|
v2: '3.38.0',
|
|
|
|
res: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40',
|
|
|
|
v2: '3.38.0',
|
|
|
|
res: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40.alpha.1.1',
|
|
|
|
v2: '40',
|
|
|
|
res: -1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40',
|
|
|
|
v2: '40.alpha.1.1',
|
|
|
|
res: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40.beta',
|
|
|
|
v2: '40',
|
|
|
|
res: -1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '40.1',
|
|
|
|
v2: '40',
|
|
|
|
res: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
v1: '',
|
|
|
|
v2: '40.alpha',
|
|
|
|
res: -1,
|
|
|
|
},
|
2021-02-04 11:26:15 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
for (let i = 0; i < tests.length; i++) {
|
2023-07-10 05:59:46 +00:00
|
|
|
const name = `Test #${i} v1: ${tests[i].v1}, v2: ${tests[i].v2}`;
|
2021-02-04 11:26:15 +00:00
|
|
|
print(name);
|
2023-07-10 05:59:46 +00:00
|
|
|
JsUnit.assertEquals(name, Util.GNOMEversionCompare(tests[i].v1, tests[i].v2), tests[i].res);
|
2021-02-04 11:26:15 +00:00
|
|
|
}
|