Merge branch 'master' into 3.0-features
This commit is contained in:
3
.github/CONTRIBUTING.md
vendored
3
.github/CONTRIBUTING.md
vendored
@@ -16,7 +16,8 @@ Please submit pull requests via feature branches using the semi-standard workflo
|
|||||||
git clone git@github.com:yourUserName/jasmine.git # Clone your fork
|
git clone git@github.com:yourUserName/jasmine.git # Clone your fork
|
||||||
cd jasmine # Change directory
|
cd jasmine # Change directory
|
||||||
git remote add upstream https://github.com/jasmine/jasmine.git # Assign original repository to a remote named 'upstream'
|
git remote add upstream https://github.com/jasmine/jasmine.git # Assign original repository to a remote named 'upstream'
|
||||||
git fetch upstream # Pull in changes not present in your local repository
|
git fetch upstream # Fetch changes not present in your local repository
|
||||||
|
git merge upstream/master # Sync local master with upstream repository
|
||||||
git checkout -b my-new-feature # Create your feature branch
|
git checkout -b my-new-feature # Create your feature branch
|
||||||
git commit -am 'Add some feature' # Commit your changes
|
git commit -am 'Add some feature' # Commit your changes
|
||||||
git push origin my-new-feature # Push to the branch
|
git push origin my-new-feature # Push to the branch
|
||||||
|
|||||||
20
.travis.yml
20
.travis.yml
@@ -24,16 +24,16 @@ matrix:
|
|||||||
include:
|
include:
|
||||||
- env:
|
- env:
|
||||||
- USE_SAUCE=false
|
- USE_SAUCE=false
|
||||||
- NODE_VERSION="4.8.6"
|
- TEST_COMMAND="bash travis-node-script.sh v0.12.18"
|
||||||
- TEST_COMMAND="bash travis-node-script.sh"
|
|
||||||
- env:
|
- env:
|
||||||
- USE_SAUCE=false
|
- USE_SAUCE=false
|
||||||
- NODE_VERSION="8.9.1"
|
- TEST_COMMAND="bash travis-node-script.sh v4"
|
||||||
- TEST_COMMAND="bash travis-node-script.sh"
|
|
||||||
- env:
|
- env:
|
||||||
- USE_SAUCE=false
|
- USE_SAUCE=false
|
||||||
- NODE_VERSION="9.1.0"
|
- TEST_COMMAND="bash travis-node-script.sh v8"
|
||||||
- TEST_COMMAND="bash travis-node-script.sh"
|
- env:
|
||||||
|
- USE_SAUCE=false
|
||||||
|
- TEST_COMMAND="bash travis-node-script.sh v9"
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="safari"
|
- JASMINE_BROWSER="safari"
|
||||||
- SAUCE_OS="OS X 10.11"
|
- SAUCE_OS="OS X 10.11"
|
||||||
@@ -58,6 +58,14 @@ matrix:
|
|||||||
- JASMINE_BROWSER="internet explorer"
|
- JASMINE_BROWSER="internet explorer"
|
||||||
- SAUCE_OS="Windows 8"
|
- SAUCE_OS="Windows 8"
|
||||||
- SAUCE_BROWSER_VERSION=10
|
- SAUCE_BROWSER_VERSION=10
|
||||||
|
- env:
|
||||||
|
- JASMINE_BROWSER="internet explorer"
|
||||||
|
- SAUCE_OS="Windows 7"
|
||||||
|
- SAUCE_BROWSER_VERSION=9
|
||||||
|
- env:
|
||||||
|
- JASMINE_BROWSER="internet explorer"
|
||||||
|
- SAUCE_OS="Windows 7"
|
||||||
|
- SAUCE_BROWSER_VERSION=8
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="chrome"
|
- JASMINE_BROWSER="chrome"
|
||||||
- SAUCE_OS="Linux"
|
- SAUCE_OS="Linux"
|
||||||
|
|||||||
@@ -217,6 +217,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
return obj.nodeType > 0;
|
return obj.nodeType > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
j$.isPromise = function(obj) {
|
||||||
|
return typeof jasmineGlobal.Promise !== 'undefined' && obj.constructor === jasmineGlobal.Promise;
|
||||||
|
};
|
||||||
|
|
||||||
j$.fnNameFor = function(func) {
|
j$.fnNameFor = function(func) {
|
||||||
if (func.name) {
|
if (func.name) {
|
||||||
return func.name;
|
return func.name;
|
||||||
@@ -2661,6 +2665,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var aIsPromise = j$.isPromise(a);
|
||||||
|
var bIsPromise = j$.isPromise(b);
|
||||||
|
if (aIsPromise && bIsPromise) {
|
||||||
|
return a === b;
|
||||||
|
}
|
||||||
|
|
||||||
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
||||||
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
||||||
var length = aStack.length;
|
var length = aStack.length;
|
||||||
@@ -2743,24 +2753,36 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|||||||
|
|
||||||
// For both sets, check they are all contained in the other set
|
// For both sets, check they are all contained in the other set
|
||||||
var setPairs = [[a, b], [b, a]];
|
var setPairs = [[a, b], [b, a]];
|
||||||
var baseIter, baseValueIt, baseValue;
|
var stackPairs = [[aStack, bStack], [bStack, aStack]];
|
||||||
var otherSet, otherIter, otherValueIt, otherValue, found;
|
var baseIter, baseValueIt, baseValue, baseStack;
|
||||||
|
var otherSet, otherIter, otherValueIt, otherValue, otherStack;
|
||||||
|
var found;
|
||||||
|
var prevStackSize;
|
||||||
for (i = 0; result && i < setPairs.length; i++) {
|
for (i = 0; result && i < setPairs.length; i++) {
|
||||||
baseIter = setPairs[i][0].values();
|
baseIter = setPairs[i][0].values();
|
||||||
otherSet = setPairs[i][1];
|
otherSet = setPairs[i][1];
|
||||||
|
baseStack = stackPairs[i][0];
|
||||||
|
otherStack = stackPairs[i][1];
|
||||||
// For each value in the base set...
|
// For each value in the base set...
|
||||||
baseValueIt = baseIter.next();
|
baseValueIt = baseIter.next();
|
||||||
while (result && !baseValueIt.done) {
|
while (result && !baseValueIt.done) {
|
||||||
baseValue = baseValueIt.value;
|
baseValue = baseValueIt.value;
|
||||||
// ... test that it is present in the other set
|
// ... test that it is present in the other set
|
||||||
otherIter = otherSet.values();
|
|
||||||
otherValueIt = otherIter.next();
|
|
||||||
// Optimisation: start looking for value by object identity
|
// Optimisation: start looking for value by object identity
|
||||||
found = otherSet.has(baseValue);
|
found = otherSet.has(baseValue);
|
||||||
|
if (!found) {
|
||||||
|
otherIter = otherSet.values();
|
||||||
|
otherValueIt = otherIter.next();
|
||||||
|
}
|
||||||
// If not found, compare by value equality
|
// If not found, compare by value equality
|
||||||
while (!found && !otherValueIt.done) {
|
while (!found && !otherValueIt.done) {
|
||||||
otherValue = otherValueIt.value;
|
otherValue = otherValueIt.value;
|
||||||
found = eq(baseValue, otherValue, aStack, bStack, customTesters, j$.NullDiffBuilder());
|
prevStackSize = baseStack.length;
|
||||||
|
found = eq(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
|
||||||
|
if (!found && prevStackSize !== baseStack.length) {
|
||||||
|
baseStack.splice(prevStackSize);
|
||||||
|
otherStack.splice(prevStackSize);
|
||||||
|
}
|
||||||
otherValueIt = otherIter.next();
|
otherValueIt = otherIter.next();
|
||||||
}
|
}
|
||||||
result = result && found;
|
result = result && found;
|
||||||
@@ -4990,7 +5012,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|||||||
* @param {Function} fn The function to invoke with the passed parameters.
|
* @param {Function} fn The function to invoke with the passed parameters.
|
||||||
*/
|
*/
|
||||||
this.callFake = function(fn) {
|
this.callFake = function(fn) {
|
||||||
if(!j$.isFunction_(fn)) {
|
if(!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
|
||||||
throw new Error('Argument passed to callFake should be a function, got ' + fn);
|
throw new Error('Argument passed to callFake should be a function, got ' + fn);
|
||||||
}
|
}
|
||||||
plan = fn;
|
plan = fn;
|
||||||
|
|||||||
@@ -92,12 +92,35 @@ describe("SpyStrategy", function() {
|
|||||||
expect(returnValue).toEqual(67);
|
expect(returnValue).toEqual(67);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows a fake async function to be called instead", function(done) {
|
||||||
|
jasmine.getEnv().requireAsyncAwait();
|
||||||
|
var originalFn = jasmine.createSpy("original"),
|
||||||
|
fakeFn = jasmine.createSpy("fake").and.callFake(eval("async () => { return 67; }")),
|
||||||
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
|
returnValue;
|
||||||
|
|
||||||
|
spyStrategy.callFake(fakeFn);
|
||||||
|
spyStrategy.exec().then(function (returnValue) {
|
||||||
|
expect(originalFn).not.toHaveBeenCalled();
|
||||||
|
expect(fakeFn).toHaveBeenCalled();
|
||||||
|
expect(returnValue).toEqual(67);
|
||||||
|
done();
|
||||||
|
}).catch(function (err) {
|
||||||
|
done.fail(err);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
it('throws an error when a non-function is passed to callFake strategy', function() {
|
it('throws an error when a non-function is passed to callFake strategy', function() {
|
||||||
var originalFn = jasmine.createSpy('original'),
|
var originalFn = jasmine.createSpy('original'),
|
||||||
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
spyStrategy = new jasmineUnderTest.SpyStrategy({fn: originalFn}),
|
||||||
invalidFakes = [5, 'foo', {}, true, false, null, void 0, new Date(), /.*/];
|
invalidFakes = [5, 'foo', {}, true, false, null, void 0, new Date(), /.*/];
|
||||||
|
|
||||||
spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false);
|
spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false);
|
||||||
|
spyOn(jasmineUnderTest, 'isAsyncFunction_').and.returnValue(false);
|
||||||
|
|
||||||
|
expect(function () {
|
||||||
|
spyStrategy.callFake(function() {});
|
||||||
|
}).toThrowError(/^Argument passed to callFake should be a function, got/);
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
spyStrategy.callFake(function() {});
|
spyStrategy.callFake(function() {});
|
||||||
|
|||||||
@@ -165,6 +165,16 @@ describe("matchersUtil", function() {
|
|||||||
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("passes for equivalent Promises (GitHub issue #1314)", function() {
|
||||||
|
if (typeof Promise === 'undefined') { return; }
|
||||||
|
|
||||||
|
var p1 = new Promise(function () {}),
|
||||||
|
p2 = new Promise(function () {});
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(p1, p1)).toBe(true);
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(p1, p2)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
describe("when running in a browser", function() {
|
describe("when running in a browser", function() {
|
||||||
function isNotRunningInBrowser() {
|
function isNotRunningInBrowser() {
|
||||||
return typeof document === 'undefined'
|
return typeof document === 'undefined'
|
||||||
@@ -383,13 +393,27 @@ describe("matchersUtil", function() {
|
|||||||
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes when comparing identical sets with different insertion order", function() {
|
it("passes when comparing identical sets with different insertion order and simple elements", function() {
|
||||||
jasmine.getEnv().requireFunctioningSets();
|
jasmine.getEnv().requireFunctioningSets();
|
||||||
var setA = new Set([3, 6]);
|
var setA = new Set([3, 6]);
|
||||||
var setB = new Set([6, 3]);
|
var setB = new Set([6, 3]);
|
||||||
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("passes when comparing identical sets with different insertion order and complex elements 1", function() {
|
||||||
|
jasmine.getEnv().requireFunctioningMaps();
|
||||||
|
var setA = new Set([new Set([['a', 3], [6, 1]]), new Set([['y', 3], [6, 1]])]);
|
||||||
|
var setB = new Set([new Set([[6, 1], ['a', 3]]), new Set([[6, 1], ['y', 3]])]);
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes when comparing identical sets with different insertion order and complex elements 2", function() {
|
||||||
|
jasmine.getEnv().requireFunctioningMaps();
|
||||||
|
var setA = new Set([[[1,2], [3,4]], [[5,6], [7,8]]]);
|
||||||
|
var setB = new Set([[[5,6], [7,8]], [[1,2], [3,4]]]);
|
||||||
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("fails for sets with different elements", function() {
|
it("fails for sets with different elements", function() {
|
||||||
jasmine.getEnv().requireFunctioningSets();
|
jasmine.getEnv().requireFunctioningSets();
|
||||||
var setA = new Set([6, 3, 5]);
|
var setA = new Set([6, 3, 5]);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|||||||
* @param {Function} fn The function to invoke with the passed parameters.
|
* @param {Function} fn The function to invoke with the passed parameters.
|
||||||
*/
|
*/
|
||||||
this.callFake = function(fn) {
|
this.callFake = function(fn) {
|
||||||
if(!j$.isFunction_(fn)) {
|
if(!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
|
||||||
throw new Error('Argument passed to callFake should be a function, got ' + fn);
|
throw new Error('Argument passed to callFake should be a function, got ' + fn);
|
||||||
}
|
}
|
||||||
plan = fn;
|
plan = fn;
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
return obj.nodeType > 0;
|
return obj.nodeType > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
j$.isPromise = function(obj) {
|
||||||
|
return typeof jasmineGlobal.Promise !== 'undefined' && obj.constructor === jasmineGlobal.Promise;
|
||||||
|
};
|
||||||
|
|
||||||
j$.fnNameFor = function(func) {
|
j$.fnNameFor = function(func) {
|
||||||
if (func.name) {
|
if (func.name) {
|
||||||
return func.name;
|
return func.name;
|
||||||
|
|||||||
@@ -193,6 +193,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var aIsPromise = j$.isPromise(a);
|
||||||
|
var bIsPromise = j$.isPromise(b);
|
||||||
|
if (aIsPromise && bIsPromise) {
|
||||||
|
return a === b;
|
||||||
|
}
|
||||||
|
|
||||||
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
||||||
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
||||||
var length = aStack.length;
|
var length = aStack.length;
|
||||||
@@ -275,24 +281,36 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|||||||
|
|
||||||
// For both sets, check they are all contained in the other set
|
// For both sets, check they are all contained in the other set
|
||||||
var setPairs = [[a, b], [b, a]];
|
var setPairs = [[a, b], [b, a]];
|
||||||
var baseIter, baseValueIt, baseValue;
|
var stackPairs = [[aStack, bStack], [bStack, aStack]];
|
||||||
var otherSet, otherIter, otherValueIt, otherValue, found;
|
var baseIter, baseValueIt, baseValue, baseStack;
|
||||||
|
var otherSet, otherIter, otherValueIt, otherValue, otherStack;
|
||||||
|
var found;
|
||||||
|
var prevStackSize;
|
||||||
for (i = 0; result && i < setPairs.length; i++) {
|
for (i = 0; result && i < setPairs.length; i++) {
|
||||||
baseIter = setPairs[i][0].values();
|
baseIter = setPairs[i][0].values();
|
||||||
otherSet = setPairs[i][1];
|
otherSet = setPairs[i][1];
|
||||||
|
baseStack = stackPairs[i][0];
|
||||||
|
otherStack = stackPairs[i][1];
|
||||||
// For each value in the base set...
|
// For each value in the base set...
|
||||||
baseValueIt = baseIter.next();
|
baseValueIt = baseIter.next();
|
||||||
while (result && !baseValueIt.done) {
|
while (result && !baseValueIt.done) {
|
||||||
baseValue = baseValueIt.value;
|
baseValue = baseValueIt.value;
|
||||||
// ... test that it is present in the other set
|
// ... test that it is present in the other set
|
||||||
otherIter = otherSet.values();
|
|
||||||
otherValueIt = otherIter.next();
|
|
||||||
// Optimisation: start looking for value by object identity
|
// Optimisation: start looking for value by object identity
|
||||||
found = otherSet.has(baseValue);
|
found = otherSet.has(baseValue);
|
||||||
|
if (!found) {
|
||||||
|
otherIter = otherSet.values();
|
||||||
|
otherValueIt = otherIter.next();
|
||||||
|
}
|
||||||
// If not found, compare by value equality
|
// If not found, compare by value equality
|
||||||
while (!found && !otherValueIt.done) {
|
while (!found && !otherValueIt.done) {
|
||||||
otherValue = otherValueIt.value;
|
otherValue = otherValueIt.value;
|
||||||
found = eq(baseValue, otherValue, aStack, bStack, customTesters, j$.NullDiffBuilder());
|
prevStackSize = baseStack.length;
|
||||||
|
found = eq(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
|
||||||
|
if (!found && prevStackSize !== baseStack.length) {
|
||||||
|
baseStack.splice(prevStackSize);
|
||||||
|
otherStack.splice(prevStackSize);
|
||||||
|
}
|
||||||
otherValueIt = otherIter.next();
|
otherValueIt = otherIter.next();
|
||||||
}
|
}
|
||||||
result = result && found;
|
result = result && found;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ rm -rf ~/.nvm
|
|||||||
git clone https://github.com/creationix/nvm.git ~/.nvm
|
git clone https://github.com/creationix/nvm.git ~/.nvm
|
||||||
(cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`)
|
(cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`)
|
||||||
source ~/.nvm/nvm.sh
|
source ~/.nvm/nvm.sh
|
||||||
nvm install $NODE_VERSION
|
nvm install ${1:-"v0.12.18"}
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
npm test
|
npm test
|
||||||
|
|||||||
Reference in New Issue
Block a user