jasmine-core 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af3fdbce40dc44c9c0129b5ddd5137720bcf9319
4
- data.tar.gz: d22c15e0965fc94de0bb67e9efbc4fbe2bd403b6
3
+ metadata.gz: 52b633d51b123d4eb0ad4d72b0930a4731a51785
4
+ data.tar.gz: c88fb95def076fca0154fe95fb3ad4228387b045
5
5
  SHA512:
6
- metadata.gz: a8b6b5234a6935dbeeab646a474153c81954e677d43f95a34dba63f6d2e8e2e7a8a163abbd7c5b3d563180eba1bd15a199187f2342575bb31993eb84d574ad67
7
- data.tar.gz: 32b6e96b74c6e630f849dd68ca813b4bf8edef110251079b55cfe2c4ef031613c70a496f03cb7b3e2dcec678f10baf7d0a9e297e5310a96353357882958b4492
6
+ metadata.gz: 1db908358f4e995855d55c4c58f53829e8eaf7404b00210df81df8fecf8633e7249bbdd9a2a95da87b29b530ef32a828cbcc347f8aaedb9f055b9b85ce2a98d5
7
+ data.tar.gz: 65c2fe06a9921ce67d5eb03f27f48992868fa375e480e5c6a96f8570f3f34c867986f71bab477f5e0e52dbbddd453aba11ad7506af066c99131ca3baaf271fc0
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2017 Pivotal Labs
2
+ Copyright (c) 2008-2018 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2017 Pivotal Labs
2
+ Copyright (c) 2008-2018 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2017 Pivotal Labs
2
+ Copyright (c) 2008-2018 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -34,6 +34,46 @@ jasmineRequire.HtmlReporter = function(j$) {
34
34
  elapsed: function() { return 0; }
35
35
  };
36
36
 
37
+ function ResultsStateBuilder() {
38
+ this.topResults = new j$.ResultsNode({}, '', null);
39
+ this.currentParent = this.topResults;
40
+ this.specsExecuted = 0;
41
+ this.failureCount = 0;
42
+ this.pendingSpecCount = 0;
43
+ }
44
+
45
+ ResultsStateBuilder.prototype.suiteStarted = function(result) {
46
+ this.currentParent.addChild(result, 'suite');
47
+ this.currentParent = this.currentParent.last();
48
+ };
49
+
50
+ ResultsStateBuilder.prototype.suiteDone = function(result) {
51
+ if (this.currentParent !== this.topResults) {
52
+ this.currentParent = this.currentParent.parent;
53
+ }
54
+ };
55
+
56
+ ResultsStateBuilder.prototype.specStarted = function(result) {
57
+ };
58
+
59
+ ResultsStateBuilder.prototype.specDone = function(result) {
60
+ this.currentParent.addChild(result, 'spec');
61
+
62
+ if (result.status !== 'disabled') {
63
+ this.specsExecuted++;
64
+ }
65
+
66
+ if (result.status === 'failed') {
67
+ this.failureCount++;
68
+ }
69
+
70
+ if (result.status == 'pending') {
71
+ this.pendingSpecCount++;
72
+ }
73
+ };
74
+
75
+
76
+
37
77
  function HtmlReporter(options) {
38
78
  var env = options.env || {},
39
79
  getContainer = options.getContainer,
@@ -46,9 +86,6 @@ jasmineRequire.HtmlReporter = function(j$) {
46
86
  filterSpecs = options.filterSpecs,
47
87
  timer = options.timer || noopTimer,
48
88
  results = [],
49
- specsExecuted = 0,
50
- failureCount = 0,
51
- pendingSpecCount = 0,
52
89
  htmlReporterMain,
53
90
  symbols,
54
91
  failedSuites = [];
@@ -77,12 +114,10 @@ jasmineRequire.HtmlReporter = function(j$) {
77
114
 
78
115
  var summary = createDom('div', {className: 'jasmine-summary'});
79
116
 
80
- var topResults = new j$.ResultsNode({}, '', null),
81
- currentParent = topResults;
117
+ var stateBuilder = new ResultsStateBuilder();
82
118
 
83
119
  this.suiteStarted = function(result) {
84
- currentParent.addChild(result, 'suite');
85
- currentParent = currentParent.last();
120
+ stateBuilder.suiteStarted(result);
86
121
  };
87
122
 
88
123
  this.suiteDone = function(result) {
@@ -90,27 +125,21 @@ jasmineRequire.HtmlReporter = function(j$) {
90
125
  failedSuites.push(result);
91
126
  }
92
127
 
93
- if (currentParent == topResults) {
94
- return;
95
- }
96
-
97
- currentParent = currentParent.parent;
128
+ stateBuilder.suiteDone(result);
98
129
  };
99
130
 
100
131
  this.specStarted = function(result) {
101
- currentParent.addChild(result, 'spec');
132
+ stateBuilder.specStarted(result);
102
133
  };
103
134
 
104
135
  var failures = [];
105
136
  this.specDone = function(result) {
137
+ stateBuilder.specDone(result);
138
+
106
139
  if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
107
140
  console.error('Spec \'' + result.fullName + '\' has no expectations.');
108
141
  }
109
142
 
110
- if (result.status != 'disabled') {
111
- specsExecuted++;
112
- }
113
-
114
143
  if (!symbols){
115
144
  symbols = find('.jasmine-symbol-summary');
116
145
  }
@@ -123,8 +152,6 @@ jasmineRequire.HtmlReporter = function(j$) {
123
152
  ));
124
153
 
125
154
  if (result.status == 'failed') {
126
- failureCount++;
127
-
128
155
  var failure =
129
156
  createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
130
157
  createDom('div', {className: 'jasmine-description'},
@@ -142,10 +169,6 @@ jasmineRequire.HtmlReporter = function(j$) {
142
169
 
143
170
  failures.push(failure);
144
171
  }
145
-
146
- if (result.status == 'pending') {
147
- pendingSpecCount++;
148
- }
149
172
  };
150
173
 
151
174
  this.jasmineDone = function(doneResult) {
@@ -208,8 +231,8 @@ jasmineRequire.HtmlReporter = function(j$) {
208
231
  }
209
232
  };
210
233
 
211
- if (specsExecuted < totalSpecsDefined) {
212
- var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
234
+ if (stateBuilder.specsExecuted < totalSpecsDefined) {
235
+ var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
213
236
  var skippedLink = addToExistingQueryString('spec', '');
214
237
  alert.appendChild(
215
238
  createDom('span', {className: 'jasmine-bar jasmine-skipped'},
@@ -221,9 +244,9 @@ jasmineRequire.HtmlReporter = function(j$) {
221
244
  var statusBarClassName = 'jasmine-bar ';
222
245
 
223
246
  if (totalSpecsDefined > 0) {
224
- statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
225
- if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
226
- statusBarClassName += (failureCount > 0) ? 'jasmine-failed' : 'jasmine-passed';
247
+ statusBarMessage += pluralize('spec', stateBuilder.specsExecuted) + ', ' + pluralize('failure', stateBuilder.failureCount);
248
+ if (stateBuilder.pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', stateBuilder.pendingSpecCount); }
249
+ statusBarClassName += (stateBuilder.failureCount > 0) ? 'jasmine-failed' : 'jasmine-passed';
227
250
  } else {
228
251
  statusBarClassName += 'jasmine-skipped';
229
252
  statusBarMessage += 'No specs found';
@@ -258,7 +281,7 @@ jasmineRequire.HtmlReporter = function(j$) {
258
281
  var results = find('.jasmine-results');
259
282
  results.appendChild(summary);
260
283
 
261
- summaryList(topResults, summary);
284
+ summaryList(stateBuilder.topResults, summary);
262
285
 
263
286
  function summaryList(resultsTree, domParent) {
264
287
  var specListNode;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2017 Pivotal Labs
2
+ Copyright (c) 2008-2018 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -34,7 +34,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
34
34
  if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') {
35
35
  jasmineGlobal = window;
36
36
  }
37
- jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
37
+ jasmineRequire = jasmineGlobal.jasmineRequire = {};
38
38
  }
39
39
 
40
40
  function getJasmineRequire() {
@@ -45,7 +45,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
45
45
  var j$ = {};
46
46
 
47
47
  jRequire.base(j$, jasmineGlobal);
48
- j$.util = jRequire.util();
48
+ j$.util = jRequire.util(j$);
49
49
  j$.errors = jRequire.errors();
50
50
  j$.formatErrorMsg = jRequire.formatErrorMsg();
51
51
  j$.Any = jRequire.Any(j$);
@@ -54,7 +54,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
54
54
  j$.MockDate = jRequire.MockDate();
55
55
  j$.getClearStack = jRequire.clearStack(j$);
56
56
  j$.Clock = jRequire.Clock();
57
- j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler();
57
+ j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$);
58
58
  j$.Env = jRequire.Env(j$);
59
59
  j$.ExceptionFormatter = jRequire.ExceptionFormatter();
60
60
  j$.Expectation = jRequire.Expectation();
@@ -66,7 +66,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
66
66
  j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$);
67
67
  j$.pp = jRequire.pp(j$);
68
68
  j$.QueueRunner = jRequire.QueueRunner(j$);
69
- j$.ReportDispatcher = jRequire.ReportDispatcher();
69
+ j$.ReportDispatcher = jRequire.ReportDispatcher(j$);
70
70
  j$.Spec = jRequire.Spec(j$);
71
71
  j$.Spy = jRequire.Spy(j$);
72
72
  j$.SpyRegistry = jRequire.SpyRegistry(j$);
@@ -138,14 +138,20 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
138
138
  * Set this to a lower value to speed up pretty printing if you have large objects.
139
139
  * @name jasmine.MAX_PRETTY_PRINT_DEPTH
140
140
  */
141
- j$.MAX_PRETTY_PRINT_DEPTH = 40;
141
+ j$.MAX_PRETTY_PRINT_DEPTH = 8;
142
142
  /**
143
143
  * Maximum number of array elements to display when pretty printing objects.
144
144
  * This will also limit the number of keys and values displayed for an object.
145
145
  * Elements past this number will be ellipised.
146
146
  * @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
147
147
  */
148
- j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100;
148
+ j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 50;
149
+ /**
150
+ * Maximum number of charasters to display when pretty printing objects.
151
+ * Characters past this number will be ellipised.
152
+ * @name jasmine.MAX_PRETTY_PRINT_CHARS
153
+ */
154
+ j$.MAX_PRETTY_PRINT_CHARS = 1000;
149
155
  /**
150
156
  * Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
151
157
  * @name jasmine.DEFAULT_TIMEOUT_INTERVAL
@@ -217,6 +223,18 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
217
223
  return obj.nodeType > 0;
218
224
  };
219
225
 
226
+ j$.isMap = function(obj) {
227
+ return typeof jasmineGlobal.Map !== 'undefined' && obj.constructor === jasmineGlobal.Map;
228
+ };
229
+
230
+ j$.isSet = function(obj) {
231
+ return typeof jasmineGlobal.Set !== 'undefined' && obj.constructor === jasmineGlobal.Set;
232
+ };
233
+
234
+ j$.isPromise = function(obj) {
235
+ return typeof jasmineGlobal.Promise !== 'undefined' && obj.constructor === jasmineGlobal.Promise;
236
+ };
237
+
220
238
  j$.fnNameFor = function(func) {
221
239
  if (func.name) {
222
240
  return func.name;
@@ -355,7 +373,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
355
373
  };
356
374
  };
357
375
 
358
- getJasmineRequireObj().util = function() {
376
+ getJasmineRequireObj().util = function(j$) {
359
377
 
360
378
  var util = {};
361
379
 
@@ -412,6 +430,23 @@ getJasmineRequireObj().util = function() {
412
430
  return cloned;
413
431
  };
414
432
 
433
+ util.cloneArgs = function(args) {
434
+ var clonedArgs = [];
435
+ var argsAsArray = j$.util.argsToArray(args);
436
+ for(var i = 0; i < argsAsArray.length; i++) {
437
+ var str = Object.prototype.toString.apply(argsAsArray[i]),
438
+ primitives = /^\[object (Boolean|String|RegExp|Number)/;
439
+
440
+ // All falsey values are either primitives, `null`, or `undefined.
441
+ if (!argsAsArray[i] || str.match(primitives)) {
442
+ clonedArgs.push(argsAsArray[i]);
443
+ } else {
444
+ clonedArgs.push(j$.util.clone(argsAsArray[i]));
445
+ }
446
+ }
447
+ return clonedArgs;
448
+ };
449
+
415
450
  util.getPropertyDescriptor = function(obj, methodName) {
416
451
  var descriptor,
417
452
  proto = obj;
@@ -1048,6 +1083,13 @@ getJasmineRequireObj().Env = function(j$) {
1048
1083
  }
1049
1084
  };
1050
1085
 
1086
+ function ensureIsNotNested(method) {
1087
+ var runnable = currentRunnable();
1088
+ if (runnable !== null && runnable !== undefined) {
1089
+ throw new Error('\'' + method + '\' should only be used in \'describe\' function');
1090
+ }
1091
+ }
1092
+
1051
1093
  var suiteFactory = function(description) {
1052
1094
  var suite = new j$.Suite({
1053
1095
  env: self,
@@ -1063,6 +1105,7 @@ getJasmineRequireObj().Env = function(j$) {
1063
1105
  };
1064
1106
 
1065
1107
  this.describe = function(description, specDefinitions) {
1108
+ ensureIsNotNested('describe');
1066
1109
  ensureIsFunction(specDefinitions, 'describe');
1067
1110
  var suite = suiteFactory(description);
1068
1111
  if (specDefinitions.length > 0) {
@@ -1076,6 +1119,7 @@ getJasmineRequireObj().Env = function(j$) {
1076
1119
  };
1077
1120
 
1078
1121
  this.xdescribe = function(description, specDefinitions) {
1122
+ ensureIsNotNested('xdescribe');
1079
1123
  ensureIsFunction(specDefinitions, 'xdescribe');
1080
1124
  var suite = suiteFactory(description);
1081
1125
  suite.pend();
@@ -1086,6 +1130,7 @@ getJasmineRequireObj().Env = function(j$) {
1086
1130
  var focusedRunnables = [];
1087
1131
 
1088
1132
  this.fdescribe = function(description, specDefinitions) {
1133
+ ensureIsNotNested('fdescribe');
1089
1134
  ensureIsFunction(specDefinitions, 'fdescribe');
1090
1135
  var suite = suiteFactory(description);
1091
1136
  suite.isFocused = true;
@@ -1183,6 +1228,7 @@ getJasmineRequireObj().Env = function(j$) {
1183
1228
  };
1184
1229
 
1185
1230
  this.it = function(description, fn, timeout) {
1231
+ ensureIsNotNested('it');
1186
1232
  // it() sometimes doesn't have a fn argument, so only check the type if
1187
1233
  // it's given.
1188
1234
  if (arguments.length > 1 && typeof fn !== 'undefined') {
@@ -1197,6 +1243,7 @@ getJasmineRequireObj().Env = function(j$) {
1197
1243
  };
1198
1244
 
1199
1245
  this.xit = function(description, fn, timeout) {
1246
+ ensureIsNotNested('xit');
1200
1247
  // xit(), like it(), doesn't always have a fn argument, so only check the
1201
1248
  // type when needed.
1202
1249
  if (arguments.length > 1 && typeof fn !== 'undefined') {
@@ -1208,6 +1255,7 @@ getJasmineRequireObj().Env = function(j$) {
1208
1255
  };
1209
1256
 
1210
1257
  this.fit = function(description, fn, timeout){
1258
+ ensureIsNotNested('fit');
1211
1259
  ensureIsFunctionOrAsync(fn, 'fit');
1212
1260
  var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
1213
1261
  currentDeclarationSuite.addChild(spec);
@@ -1225,6 +1273,7 @@ getJasmineRequireObj().Env = function(j$) {
1225
1273
  };
1226
1274
 
1227
1275
  this.beforeEach = function(beforeEachFunction, timeout) {
1276
+ ensureIsNotNested('beforeEach');
1228
1277
  ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
1229
1278
  currentDeclarationSuite.beforeEach({
1230
1279
  fn: beforeEachFunction,
@@ -1233,6 +1282,7 @@ getJasmineRequireObj().Env = function(j$) {
1233
1282
  };
1234
1283
 
1235
1284
  this.beforeAll = function(beforeAllFunction, timeout) {
1285
+ ensureIsNotNested('beforeAll');
1236
1286
  ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
1237
1287
  currentDeclarationSuite.beforeAll({
1238
1288
  fn: beforeAllFunction,
@@ -1241,6 +1291,7 @@ getJasmineRequireObj().Env = function(j$) {
1241
1291
  };
1242
1292
 
1243
1293
  this.afterEach = function(afterEachFunction, timeout) {
1294
+ ensureIsNotNested('afterEach');
1244
1295
  ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
1245
1296
  afterEachFunction.isCleanup = true;
1246
1297
  currentDeclarationSuite.afterEach({
@@ -1250,6 +1301,7 @@ getJasmineRequireObj().Env = function(j$) {
1250
1301
  };
1251
1302
 
1252
1303
  this.afterAll = function(afterAllFunction, timeout) {
1304
+ ensureIsNotNested('afterAll');
1253
1305
  ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
1254
1306
  currentDeclarationSuite.afterAll({
1255
1307
  fn: afterAllFunction,
@@ -1465,6 +1517,12 @@ getJasmineRequireObj().Any = function(j$) {
1465
1517
  return typeof other == 'boolean';
1466
1518
  }
1467
1519
 
1520
+ /* jshint -W122 */
1521
+ if (typeof Symbol != 'undefined' && this.expectedObject == Symbol) {
1522
+ return typeof other == 'symbol';
1523
+ }
1524
+ /* jshint +W122 */
1525
+
1468
1526
  return other instanceof this.expectedObject;
1469
1527
  };
1470
1528
 
@@ -1629,25 +1687,9 @@ getJasmineRequireObj().CallTracker = function(j$) {
1629
1687
  var calls = [];
1630
1688
  var opts = {};
1631
1689
 
1632
- function argCloner(context) {
1633
- var clonedArgs = [];
1634
- var argsAsArray = j$.util.argsToArray(context.args);
1635
- for(var i = 0; i < argsAsArray.length; i++) {
1636
- var str = Object.prototype.toString.apply(argsAsArray[i]),
1637
- primitives = /^\[object (Boolean|String|RegExp|Number)/;
1638
-
1639
- if (argsAsArray[i] == null || str.match(primitives)) {
1640
- clonedArgs.push(argsAsArray[i]);
1641
- } else {
1642
- clonedArgs.push(j$.util.clone(argsAsArray[i]));
1643
- }
1644
- }
1645
- context.args = clonedArgs;
1646
- }
1647
-
1648
1690
  this.track = function(context) {
1649
1691
  if(opts.cloneArgs) {
1650
- argCloner(context);
1692
+ context.args = j$.util.cloneArgs(context.args);
1651
1693
  }
1652
1694
  calls.push(context);
1653
1695
  };
@@ -1823,6 +1865,9 @@ getJasmineRequireObj().clearStack = function(j$) {
1823
1865
  };
1824
1866
 
1825
1867
  getJasmineRequireObj().Clock = function() {
1868
+
1869
+ var NODE_JS = typeof process !== 'undefined' && process.versions && typeof process.versions.node === 'string';
1870
+
1826
1871
  /**
1827
1872
  * _Note:_ Do not construct this directly, Jasmine will make one during booting. You can get the current clock with {@link jasmine.clock}.
1828
1873
  * @class Clock
@@ -1846,6 +1891,7 @@ getJasmineRequireObj().Clock = function() {
1846
1891
  delayedFunctionScheduler,
1847
1892
  timer;
1848
1893
 
1894
+ self.FakeTimeout = FakeTimeout;
1849
1895
 
1850
1896
  /**
1851
1897
  * Install the mock clock over the built-in methods.
@@ -1969,7 +2015,15 @@ getJasmineRequireObj().Clock = function() {
1969
2015
  }
1970
2016
 
1971
2017
  function setTimeout(fn, delay) {
1972
- return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
2018
+ if (!NODE_JS) {
2019
+ return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
2020
+ }
2021
+
2022
+ var timeout = new FakeTimeout();
2023
+
2024
+ delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2), false, timeout);
2025
+
2026
+ return timeout;
1973
2027
  }
1974
2028
 
1975
2029
  function clearTimeout(id) {
@@ -1977,7 +2031,15 @@ getJasmineRequireObj().Clock = function() {
1977
2031
  }
1978
2032
 
1979
2033
  function setInterval(fn, interval) {
1980
- return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
2034
+ if (!NODE_JS) {
2035
+ return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
2036
+ }
2037
+
2038
+ var timeout = new FakeTimeout();
2039
+
2040
+ delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true, timeout);
2041
+
2042
+ return timeout;
1981
2043
  }
1982
2044
 
1983
2045
  function clearInterval(id) {
@@ -1989,16 +2051,30 @@ getJasmineRequireObj().Clock = function() {
1989
2051
  }
1990
2052
  }
1991
2053
 
2054
+ /**
2055
+ * Mocks Node.js Timeout class
2056
+ */
2057
+ function FakeTimeout() {}
2058
+
2059
+ FakeTimeout.prototype.ref = function () {
2060
+ return this;
2061
+ };
2062
+
2063
+ FakeTimeout.prototype.unref = function () {
2064
+ return this;
2065
+ };
2066
+
1992
2067
  return Clock;
1993
2068
  };
1994
2069
 
1995
- getJasmineRequireObj().DelayedFunctionScheduler = function() {
2070
+ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
1996
2071
  function DelayedFunctionScheduler() {
1997
2072
  var self = this;
1998
2073
  var scheduledLookup = [];
1999
2074
  var scheduledFunctions = {};
2000
2075
  var currentTime = 0;
2001
2076
  var delayedFnCount = 0;
2077
+ var deletedKeys = [];
2002
2078
 
2003
2079
  self.tick = function(millis, tickDate) {
2004
2080
  millis = millis || 0;
@@ -2045,6 +2121,8 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
2045
2121
  };
2046
2122
 
2047
2123
  self.removeFunctionWithId = function(timeoutKey) {
2124
+ deletedKeys.push(timeoutKey);
2125
+
2048
2126
  for (var runAtMillis in scheduledFunctions) {
2049
2127
  var funcs = scheduledFunctions[runAtMillis];
2050
2128
  var i = indexOfFirstToPass(funcs, function (func) {
@@ -2121,6 +2199,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
2121
2199
  currentTime = newCurrentTime;
2122
2200
 
2123
2201
  var funcsToRun = scheduledFunctions[currentTime];
2202
+
2124
2203
  delete scheduledFunctions[currentTime];
2125
2204
 
2126
2205
  forEachFunction(funcsToRun, function(funcToRun) {
@@ -2130,8 +2209,13 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
2130
2209
  });
2131
2210
 
2132
2211
  forEachFunction(funcsToRun, function(funcToRun) {
2212
+ if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) {
2213
+ // skip a timeoutKey deleted whilst we were running
2214
+ return;
2215
+ }
2133
2216
  funcToRun.funcToCall.apply(null, funcToRun.params || []);
2134
2217
  });
2218
+ deletedKeys = [];
2135
2219
  } while (scheduledLookup.length > 0 &&
2136
2220
  // checking first if we're out of time prevents setTimeout(0)
2137
2221
  // scheduled in a funcToRun from forcing an extra iteration
@@ -2660,6 +2744,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
2660
2744
  return false;
2661
2745
  }
2662
2746
 
2747
+ var aIsPromise = j$.isPromise(a);
2748
+ var bIsPromise = j$.isPromise(b);
2749
+ if (aIsPromise && bIsPromise) {
2750
+ return a === b;
2751
+ }
2752
+
2663
2753
  // Assume equality for cyclic structures. The algorithm for detecting cyclic
2664
2754
  // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
2665
2755
  var length = aStack.length;
@@ -2693,22 +2783,46 @@ getJasmineRequireObj().matchersUtil = function(j$) {
2693
2783
  if (!result) {
2694
2784
  return false;
2695
2785
  }
2696
- } else if (className == '[object Map]') {
2786
+ } else if (j$.isMap(a) && j$.isMap(b)) {
2697
2787
  if (a.size != b.size) {
2698
2788
  diffBuilder.record(a, b);
2699
2789
  return false;
2700
2790
  }
2701
2791
 
2702
- // For both sets of keys, check they map to equal values in both maps
2703
- var mapKeys = [a.keys(), b.keys()];
2704
- var mapIter, mapKeyIt, mapKey;
2792
+ var keysA = [];
2793
+ var keysB = [];
2794
+ a.forEach( function( valueA, keyA ) {
2795
+ keysA.push( keyA );
2796
+ });
2797
+ b.forEach( function( valueB, keyB ) {
2798
+ keysB.push( keyB );
2799
+ });
2800
+
2801
+ // For both sets of keys, check they map to equal values in both maps.
2802
+ // Keep track of corresponding keys (in insertion order) in order to handle asymmetric obj keys.
2803
+ var mapKeys = [keysA, keysB];
2804
+ var cmpKeys = [keysB, keysA];
2805
+ var mapIter, mapKey, mapValueA, mapValueB;
2806
+ var cmpIter, cmpKey;
2705
2807
  for (i = 0; result && i < mapKeys.length; i++) {
2706
2808
  mapIter = mapKeys[i];
2707
- mapKeyIt = mapIter.next();
2708
- while (result && !mapKeyIt.done) {
2709
- mapKey = mapKeyIt.value;
2710
- result = eq(a.get(mapKey), b.get(mapKey), aStack, bStack, customTesters, j$.NullDiffBuilder());
2711
- mapKeyIt = mapIter.next();
2809
+ cmpIter = cmpKeys[i];
2810
+
2811
+ for (var j = 0; result && j < mapIter.length; j++) {
2812
+ mapKey = mapIter[j];
2813
+ cmpKey = cmpIter[j];
2814
+ mapValueA = a.get(mapKey);
2815
+
2816
+ // Only use the cmpKey when one of the keys is asymmetric and the corresponding key matches,
2817
+ // otherwise explicitly look up the mapKey in the other Map since we want keys with unique
2818
+ // obj identity (that are otherwise equal) to not match.
2819
+ if (isAsymmetric(mapKey) || isAsymmetric(cmpKey) &&
2820
+ eq(mapKey, cmpKey, aStack, bStack, customTesters, j$.NullDiffBuilder())) {
2821
+ mapValueB = b.get(cmpKey);
2822
+ } else {
2823
+ mapValueB = b.get(mapKey);
2824
+ }
2825
+ result = eq(mapValueA, mapValueB, aStack, bStack, customTesters, j$.NullDiffBuilder());
2712
2826
  }
2713
2827
  }
2714
2828
 
@@ -2716,36 +2830,49 @@ getJasmineRequireObj().matchersUtil = function(j$) {
2716
2830
  diffBuilder.record(a, b);
2717
2831
  return false;
2718
2832
  }
2719
- } else if (className == '[object Set]') {
2833
+ } else if (j$.isSet(a) && j$.isSet(b)) {
2720
2834
  if (a.size != b.size) {
2721
2835
  diffBuilder.record(a, b);
2722
2836
  return false;
2723
2837
  }
2724
2838
 
2839
+ var valuesA = [];
2840
+ a.forEach( function( valueA ) {
2841
+ valuesA.push( valueA );
2842
+ });
2843
+ var valuesB = [];
2844
+ b.forEach( function( valueB ) {
2845
+ valuesB.push( valueB );
2846
+ });
2847
+
2725
2848
  // For both sets, check they are all contained in the other set
2726
- var setPairs = [[a, b], [b, a]];
2727
- var baseIter, baseValueIt, baseValue;
2728
- var otherSet, otherIter, otherValueIt, otherValue, found;
2849
+ var setPairs = [[valuesA, valuesB], [valuesB, valuesA]];
2850
+ var stackPairs = [[aStack, bStack], [bStack, aStack]];
2851
+ var baseValues, baseValue, baseStack;
2852
+ var otherValues, otherValue, otherStack;
2853
+ var found;
2854
+ var prevStackSize;
2729
2855
  for (i = 0; result && i < setPairs.length; i++) {
2730
- baseIter = setPairs[i][0].values();
2731
- otherSet = setPairs[i][1];
2856
+ baseValues = setPairs[i][0];
2857
+ otherValues = setPairs[i][1];
2858
+ baseStack = stackPairs[i][0];
2859
+ otherStack = stackPairs[i][1];
2732
2860
  // For each value in the base set...
2733
- baseValueIt = baseIter.next();
2734
- while (result && !baseValueIt.done) {
2735
- baseValue = baseValueIt.value;
2861
+ for (var k = 0; result && k < baseValues.length; k++) {
2862
+ baseValue = baseValues[k];
2863
+ found = false;
2736
2864
  // ... test that it is present in the other set
2737
- otherIter = otherSet.values();
2738
- otherValueIt = otherIter.next();
2739
- // Optimisation: start looking for value by object identity
2740
- found = otherSet.has(baseValue);
2741
- // If not found, compare by value equality
2742
- while (!found && !otherValueIt.done) {
2743
- otherValue = otherValueIt.value;
2744
- found = eq(baseValue, otherValue, aStack, bStack, customTesters, j$.NullDiffBuilder());
2745
- otherValueIt = otherIter.next();
2865
+ for (var l = 0; !found && l < otherValues.length; l++) {
2866
+ otherValue = otherValues[l];
2867
+ prevStackSize = baseStack.length;
2868
+ // compare by value equality
2869
+ found = eq(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
2870
+ if (!found && prevStackSize !== baseStack.length) {
2871
+ baseStack.splice(prevStackSize);
2872
+ otherStack.splice(prevStackSize);
2873
+ }
2746
2874
  }
2747
2875
  result = result && found;
2748
- baseValueIt = baseIter.next();
2749
2876
  }
2750
2877
  }
2751
2878
 
@@ -3891,6 +4018,8 @@ getJasmineRequireObj().pp = function(j$) {
3891
4018
  function PrettyPrinter() {
3892
4019
  this.ppNestLevel_ = 0;
3893
4020
  this.seen = [];
4021
+ this.length = 0;
4022
+ this.stringParts = [];
3894
4023
  }
3895
4024
 
3896
4025
  function hasCustomToString(value) {
@@ -3924,9 +4053,9 @@ getJasmineRequireObj().pp = function(j$) {
3924
4053
  this.emitScalar('HTMLNode');
3925
4054
  } else if (value instanceof Date) {
3926
4055
  this.emitScalar('Date(' + value + ')');
3927
- } else if (j$.getType_(value) == '[object Set]') {
4056
+ } else if (j$.isSet(value)) {
3928
4057
  this.emitSet(value);
3929
- } else if (j$.getType_(value) == '[object Map]') {
4058
+ } else if (j$.isMap(value)) {
3930
4059
  this.emitMap(value);
3931
4060
  } else if (j$.isTypedArray_(value)) {
3932
4061
  this.emitTypedArray(value);
@@ -3945,6 +4074,10 @@ getJasmineRequireObj().pp = function(j$) {
3945
4074
  } else {
3946
4075
  this.emitScalar(value.toString());
3947
4076
  }
4077
+ } catch (e) {
4078
+ if (this.ppNestLevel_ > 1 || !(e instanceof MaxCharsReachedError)) {
4079
+ throw e;
4080
+ }
3948
4081
  } finally {
3949
4082
  this.ppNestLevel_--;
3950
4083
  }
@@ -3970,30 +4103,15 @@ getJasmineRequireObj().pp = function(j$) {
3970
4103
  return objKeys.length > length;
3971
4104
  };
3972
4105
 
3973
- PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
3974
- PrettyPrinter.prototype.emitSet = j$.unimplementedMethod_;
3975
- PrettyPrinter.prototype.emitMap = j$.unimplementedMethod_;
3976
- PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
3977
- PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
3978
- PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
3979
-
3980
- function StringPrettyPrinter() {
3981
- PrettyPrinter.call(this);
3982
-
3983
- this.stringParts = [];
3984
- }
3985
-
3986
- j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
3987
-
3988
- StringPrettyPrinter.prototype.emitScalar = function(value) {
4106
+ PrettyPrinter.prototype.emitScalar = function(value) {
3989
4107
  this.append(value);
3990
4108
  };
3991
4109
 
3992
- StringPrettyPrinter.prototype.emitString = function(value) {
4110
+ PrettyPrinter.prototype.emitString = function(value) {
3993
4111
  this.append('\'' + value + '\'');
3994
4112
  };
3995
4113
 
3996
- StringPrettyPrinter.prototype.emitArray = function(array) {
4114
+ PrettyPrinter.prototype.emitArray = function(array) {
3997
4115
  if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
3998
4116
  this.append('Array');
3999
4117
  return;
@@ -4027,47 +4145,57 @@ getJasmineRequireObj().pp = function(j$) {
4027
4145
  this.append(' ]');
4028
4146
  };
4029
4147
 
4030
- StringPrettyPrinter.prototype.emitSet = function(set) {
4148
+ PrettyPrinter.prototype.emitSet = function(set) {
4031
4149
  if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
4032
4150
  this.append('Set');
4033
4151
  return;
4034
4152
  }
4035
4153
  this.append('Set( ');
4036
4154
  var size = Math.min(set.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
4037
- var iter = set.values();
4038
- for (var i = 0; i < size; i++) {
4155
+ var i = 0;
4156
+ set.forEach( function( value, key ) {
4157
+ if (i >= size) {
4158
+ return;
4159
+ }
4039
4160
  if (i > 0) {
4040
4161
  this.append(', ');
4041
4162
  }
4042
- this.format(iter.next().value);
4043
- }
4163
+ this.format(value);
4164
+
4165
+ i++;
4166
+ }, this );
4044
4167
  if (set.size > size){
4045
4168
  this.append(', ...');
4046
4169
  }
4047
4170
  this.append(' )');
4048
4171
  };
4049
4172
 
4050
- StringPrettyPrinter.prototype.emitMap = function(map) {
4173
+ PrettyPrinter.prototype.emitMap = function(map) {
4051
4174
  if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
4052
4175
  this.append('Map');
4053
4176
  return;
4054
4177
  }
4055
4178
  this.append('Map( ');
4056
4179
  var size = Math.min(map.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
4057
- var iter = map.entries();
4058
- for (var i = 0; i < size; i++) {
4180
+ var i = 0;
4181
+ map.forEach( function( value, key ) {
4182
+ if (i >= size) {
4183
+ return;
4184
+ }
4059
4185
  if (i > 0) {
4060
4186
  this.append(', ');
4061
4187
  }
4062
- this.format(iter.next().value);
4063
- }
4188
+ this.format([key,value]);
4189
+
4190
+ i++;
4191
+ }, this );
4064
4192
  if (map.size > size){
4065
4193
  this.append(', ...');
4066
4194
  }
4067
4195
  this.append(' )');
4068
4196
  };
4069
4197
 
4070
- StringPrettyPrinter.prototype.emitObject = function(obj) {
4198
+ PrettyPrinter.prototype.emitObject = function(obj) {
4071
4199
  var ctor = obj.constructor,
4072
4200
  constructorName;
4073
4201
 
@@ -4100,7 +4228,7 @@ getJasmineRequireObj().pp = function(j$) {
4100
4228
  this.append(' })');
4101
4229
  };
4102
4230
 
4103
- StringPrettyPrinter.prototype.emitTypedArray = function(arr) {
4231
+ PrettyPrinter.prototype.emitTypedArray = function(arr) {
4104
4232
  var constructorName = j$.fnNameFor(arr.constructor),
4105
4233
  limitedArray = Array.prototype.slice.call(arr, 0, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH),
4106
4234
  itemsString = Array.prototype.join.call(limitedArray, ', ');
@@ -4112,7 +4240,7 @@ getJasmineRequireObj().pp = function(j$) {
4112
4240
  this.append(constructorName + ' [ ' + itemsString + ' ]');
4113
4241
  };
4114
4242
 
4115
- StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
4243
+ PrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
4116
4244
  this.append(property);
4117
4245
  this.append(': ');
4118
4246
  if (isGetter) {
@@ -4122,10 +4250,33 @@ getJasmineRequireObj().pp = function(j$) {
4122
4250
  }
4123
4251
  };
4124
4252
 
4125
- StringPrettyPrinter.prototype.append = function(value) {
4126
- this.stringParts.push(value);
4253
+ PrettyPrinter.prototype.append = function(value) {
4254
+ var result = truncate(value, j$.MAX_PRETTY_PRINT_CHARS - this.length);
4255
+ this.length += result.value.length;
4256
+ this.stringParts.push(result.value);
4257
+
4258
+ if (result.truncated) {
4259
+ throw new MaxCharsReachedError();
4260
+ }
4127
4261
  };
4128
4262
 
4263
+
4264
+ function truncate(s, maxlen) {
4265
+ if (s.length <= maxlen) {
4266
+ return { value: s, truncated: false };
4267
+ }
4268
+
4269
+ s = s.substring(0, maxlen - 4) + ' ...';
4270
+ return { value: s, truncated: true };
4271
+ }
4272
+
4273
+ function MaxCharsReachedError() {
4274
+ this.message = 'Exceeded ' + j$.MAX_PRETTY_PRINT_CHARS +
4275
+ ' characters while pretty-printing a value';
4276
+ }
4277
+
4278
+ MaxCharsReachedError.prototype = new Error();
4279
+
4129
4280
  function keys(obj, isArray) {
4130
4281
  var allKeys = Object.keys ? Object.keys(obj) :
4131
4282
  (function(o) {
@@ -4156,9 +4307,9 @@ getJasmineRequireObj().pp = function(j$) {
4156
4307
  return extraKeys;
4157
4308
  }
4158
4309
  return function(value) {
4159
- var stringPrettyPrinter = new StringPrettyPrinter();
4160
- stringPrettyPrinter.format(value);
4161
- return stringPrettyPrinter.stringParts.join('');
4310
+ var prettyPrinter = new PrettyPrinter();
4311
+ prettyPrinter.format(value);
4312
+ return prettyPrinter.stringParts.join('');
4162
4313
  };
4163
4314
  };
4164
4315
 
@@ -4289,7 +4440,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
4289
4440
  var maybeThenable = queueableFn.fn.call(self.userContext);
4290
4441
 
4291
4442
  if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
4292
- maybeThenable.then(next, next.fail);
4443
+ maybeThenable.then(next, onPromiseRejection);
4293
4444
  completedSynchronously = false;
4294
4445
  return { completedSynchronously: false };
4295
4446
  }
@@ -4311,6 +4462,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
4311
4462
  errored = true;
4312
4463
  }
4313
4464
 
4465
+ function onPromiseRejection(e) {
4466
+ onException(e);
4467
+ next();
4468
+ }
4469
+
4314
4470
  function handleException(e, queueableFn) {
4315
4471
  onException(e);
4316
4472
  if (!self.catchException(e)) {
@@ -4325,7 +4481,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
4325
4481
  return QueueRunner;
4326
4482
  };
4327
4483
 
4328
- getJasmineRequireObj().ReportDispatcher = function() {
4484
+ getJasmineRequireObj().ReportDispatcher = function(j$) {
4329
4485
  function ReportDispatcher(methods) {
4330
4486
 
4331
4487
  var dispatchedMethods = methods || [];
@@ -4363,7 +4519,7 @@ getJasmineRequireObj().ReportDispatcher = function() {
4363
4519
  for (var i = 0; i < reporters.length; i++) {
4364
4520
  var reporter = reporters[i];
4365
4521
  if (reporter[method]) {
4366
- reporter[method].apply(reporter, args);
4522
+ reporter[method].apply(reporter, j$.util.cloneArgs(args));
4367
4523
  }
4368
4524
  }
4369
4525
  }
@@ -4572,7 +4728,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4572
4728
  },
4573
4729
 
4574
4730
  /**
4575
- * Install a spy on a property onto an existing object.
4731
+ * Install a spy on a property installed with `Object.defineProperty` onto an existing object.
4576
4732
  * @name spyOnProperty
4577
4733
  * @function
4578
4734
  * @global
@@ -4720,6 +4876,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
4720
4876
 
4721
4877
  function SpyRegistry(options) {
4722
4878
  options = options || {};
4879
+ var global = options.global || j$.getGlobal();
4723
4880
  var currentSpies = options.currentSpies || function() { return []; };
4724
4881
 
4725
4882
  this.allowRespy = function(allow){
@@ -4763,7 +4920,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
4763
4920
  spiedMethod = j$.createSpy(methodName, originalMethod),
4764
4921
  restoreStrategy;
4765
4922
 
4766
- if (Object.prototype.hasOwnProperty.call(obj, methodName)) {
4923
+ if (Object.prototype.hasOwnProperty.call(obj, methodName) || (obj === global && methodName === 'onerror')) {
4767
4924
  restoreStrategy = function() {
4768
4925
  obj[methodName] = originalMethod;
4769
4926
  };
@@ -4946,7 +5103,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
4946
5103
  * @param {Function} fn The function to invoke with the passed parameters.
4947
5104
  */
4948
5105
  this.callFake = function(fn) {
4949
- if(!j$.isFunction_(fn)) {
5106
+ if(!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
4950
5107
  throw new Error('Argument passed to callFake should be a function, got ' + fn);
4951
5108
  }
4952
5109
  plan = fn;
@@ -5381,5 +5538,5 @@ getJasmineRequireObj().UserContext = function(j$) {
5381
5538
  };
5382
5539
 
5383
5540
  getJasmineRequireObj().version = function() {
5384
- return '2.8.0';
5541
+ return '2.9.0';
5385
5542
  };