Added basic property tests for matchersUtil.equals
* See #1764 from @dubzzz * Property tests are only run in Node, not browser. * The Travis build sets JASMINE_LONG_PROPERTY_TESTS to enable much more thorough (but slow) testing.
This commit is contained in:
@@ -50,3 +50,4 @@ matrix:
|
|||||||
if: type != pull_request
|
if: type != pull_request
|
||||||
addons:
|
addons:
|
||||||
sauce_connect: true
|
sauce_connect: true
|
||||||
|
- env: JASMINE_LONG_PROPERTY_TESTS=y
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"ejs": "^2.5.5",
|
"ejs": "^2.5.5",
|
||||||
"eslint": "^5.16.0",
|
"eslint": "^5.16.0",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
|
"fast-check": "^1.21.0",
|
||||||
"fast-glob": "^2.2.6",
|
"fast-glob": "^2.2.6",
|
||||||
"grunt": "^1.0.4",
|
"grunt": "^1.0.4",
|
||||||
"grunt-cli": "^1.3.2",
|
"grunt-cli": "^1.3.2",
|
||||||
|
|||||||
69
spec/property/matchersUtilSpec.js
Normal file
69
spec/property/matchersUtilSpec.js
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
describe('matchersUtil -- property tests', function() {
|
||||||
|
'use strict';
|
||||||
|
var fc = require('fast-check');
|
||||||
|
|
||||||
|
function basicAnythingSettings() {
|
||||||
|
return {
|
||||||
|
key: fc.oneof(fc.string(), fc.constantFrom('k1', 'k2', 'k3')),
|
||||||
|
// Limiting depth & number of keys allows fast-check to try
|
||||||
|
// a lot more scalar values.
|
||||||
|
maxDepth: 2,
|
||||||
|
maxKeys: 5,
|
||||||
|
withBoxedValues: true,
|
||||||
|
withMap: true,
|
||||||
|
withSet: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function numRuns() {
|
||||||
|
var many = 5000000;
|
||||||
|
|
||||||
|
// Be thorough but very slow when specified (usually on CI).
|
||||||
|
if (process.env.JASMINE_LONG_PROPERTY_TESTS) {
|
||||||
|
console.log(
|
||||||
|
'Using',
|
||||||
|
many,
|
||||||
|
'runs of fc.assert because JASMINE_LONG_PROPERTY_TESTS was set. This may take several minutes.'
|
||||||
|
);
|
||||||
|
return many;
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('equals', function() {
|
||||||
|
it('is symmetric', function() {
|
||||||
|
fc.assert(
|
||||||
|
fc.property(
|
||||||
|
fc.anything(basicAnythingSettings()),
|
||||||
|
fc.anything(basicAnythingSettings()),
|
||||||
|
function(a, b) {
|
||||||
|
return (
|
||||||
|
jasmineUnderTest.matchersUtil.equals(a, b) ===
|
||||||
|
jasmineUnderTest.matchersUtil.equals(b, a)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
{
|
||||||
|
numRuns: numRuns(),
|
||||||
|
examples: [[0, 5e-324]]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is reflexive', function() {
|
||||||
|
var anythingSettings = basicAnythingSettings();
|
||||||
|
anythingSettings.withMap = false;
|
||||||
|
fc.assert(
|
||||||
|
fc.property(fc.dedup(fc.anything(anythingSettings), 2), function(
|
||||||
|
values
|
||||||
|
) {
|
||||||
|
return jasmineUnderTest.matchersUtil.equals(values[0], values[1]);
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
numRuns: numRuns()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -15,7 +15,7 @@ module.exports = {
|
|||||||
'**/*.js'
|
'**/*.js'
|
||||||
],
|
],
|
||||||
specDir: 'spec',
|
specDir: 'spec',
|
||||||
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*'],
|
specFiles: ['**/*[Ss]pec.js', '!npmPackage/**/*', '!property/**/*'],
|
||||||
helpers: [
|
helpers: [
|
||||||
'helpers/asyncAwait.js',
|
'helpers/asyncAwait.js',
|
||||||
'helpers/BrowserFlags.js',
|
'helpers/BrowserFlags.js',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"spec_dir": "spec",
|
"spec_dir": "spec",
|
||||||
"spec_files": [
|
"spec_files": [
|
||||||
"core/**/*[Ss]pec.js",
|
"core/**/*[Ss]pec.js",
|
||||||
|
"property/**/*[Ss]pec.js",
|
||||||
"npmPackage/**/*[Ss]pec.js"
|
"npmPackage/**/*[Ss]pec.js"
|
||||||
],
|
],
|
||||||
"helpers": [
|
"helpers": [
|
||||||
|
|||||||
Reference in New Issue
Block a user