-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqunit-2.23.0.js
7318 lines (6973 loc) · 267 KB
/
qunit-2.23.0.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* QUnit 2.23.0
* https://qunitjs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*/
(function () {
'use strict';
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return _arrayLikeToArray(r);
}
function _classCallCheck(a, n) {
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
}
}
function _createClass(e, r, t) {
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
writable: !1
}), e;
}
function _createForOfIteratorHelper(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (!t) {
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var n = 0,
F = function () {};
return {
s: F,
n: function () {
return n >= r.length ? {
done: !0
} : {
done: !1,
value: r[n++]
};
},
e: function (r) {
throw r;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var o,
a = !0,
u = !1;
return {
s: function () {
t = t.call(r);
},
n: function () {
var r = t.next();
return a = r.done, r;
},
e: function (r) {
u = !0, o = r;
},
f: function () {
try {
a || null == t.return || t.return();
} finally {
if (u) throw o;
}
}
};
}
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _toConsumableArray(r) {
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
// We don't use global-this-polyfill [1], because it modifies
// the globals scope by default. QUnit must not affect the host context
// as developers may test their project may be such a polyfill, and/or
// they may intentionally test their project with and without certain
// polyfills and we must not affect that. It also uses an obscure
// mechanism that seems to sometimes causes a runtime error in older
// browsers (specifically Safari and IE versions that support
// Object.defineProperty but then report _T_ as undefined).
// [1] https://github.com/ungap/global-this/blob/v0.4.4/esm/index.js
//
// Another way is `Function('return this')()`, but doing so relies
// on eval which will cause a CSP error on some servers.
//
// Instead, simply check the four options that already exist
// in all supported environments.
function getGlobalThis() {
if (typeof globalThis !== 'undefined') {
// For SpiderMonkey, modern browsers, and recent Node.js
// eslint-disable-next-line no-undef
return globalThis;
}
if (typeof self !== 'undefined') {
// For web workers
// eslint-disable-next-line no-undef
return self;
}
if (typeof window$1 !== 'undefined') {
// For document context in browsers
return window$1;
}
if (typeof global !== 'undefined') {
// For Node.js
// eslint-disable-next-line no-undef
return global;
}
throw new Error('Unable to locate global object');
}
// This avoids a simple `export const` assignment as that would lead Rollup
// to change getGlobalThis and use the same (generated) variable name there.
var g = getGlobalThis();
// These optional globals are undefined in one or more environments:
// modern browser, old browser, Node.js, SpiderMonkey.
// Calling code must check these for truthy-ness before use.
var console$1 = g.console;
var setTimeout$1 = g.setTimeout;
var clearTimeout = g.clearTimeout;
var process$1 = g.process;
var window$1 = g.window;
var document = window$1 && window$1.document;
var navigator = window$1 && window$1.navigator;
var localSessionStorage = function () {
var x = 'qunit-test-string';
try {
g.sessionStorage.setItem(x, x);
g.sessionStorage.removeItem(x);
return g.sessionStorage;
} catch (e) {
return undefined;
}
}();
// Basic fallback for ES6 Map
// Support: IE 9-10, Safari 7, PhantomJS; Map is undefined
// Support: iOS 8; `new Map(iterable)` is not supported
//
// Fallback for ES7 Map#keys
// Support: IE 11; Map#keys is undefined
var StringMap = typeof g.Map === 'function' && typeof g.Map.prototype.keys === 'function' && typeof g.Symbol === 'function' && _typeof(g.Symbol.iterator) === 'symbol' ? g.Map : function StringMap(input) {
var _this = this;
var store = Object.create(null);
var hasOwn = Object.prototype.hasOwnProperty;
this.has = function (strKey) {
return hasOwn.call(store, strKey);
};
this.get = function (strKey) {
return store[strKey];
};
this.set = function (strKey, val) {
if (!hasOwn.call(store, strKey)) {
this.size++;
}
store[strKey] = val;
return this;
};
this.delete = function (strKey) {
if (hasOwn.call(store, strKey)) {
delete store[strKey];
this.size--;
}
};
this.forEach = function (callback) {
for (var strKey in store) {
callback(store[strKey], strKey);
}
};
this.keys = function () {
return Object.keys(store);
};
this.clear = function () {
store = Object.create(null);
this.size = 0;
};
this.size = 0;
if (input) {
input.forEach(function (val, strKey) {
_this.set(strKey, val);
});
}
};
// Basic fallback for ES6 Set
// Support: IE 11, `new Set(iterable)` parameter not yet implemented
// Test for Set#values() which came after Set(iterable).
var StringSet = typeof g.Set === 'function' && typeof g.Set.prototype.values === 'function' ? g.Set : function (input) {
var set = Object.create(null);
if (Array.isArray(input)) {
input.forEach(function (item) {
set[item] = true;
});
}
return {
add: function add(value) {
set[value] = true;
},
has: function has(value) {
return value in set;
},
get size() {
return Object.keys(set).length;
}
};
};
var toString = Object.prototype.toString;
var hasOwn$2 = Object.prototype.hasOwnProperty;
var performance = {
// eslint-disable-next-line compat/compat -- Checked
now: window$1 && window$1.performance && window$1.performance.now ? window$1.performance.now.bind(window$1.performance) : Date.now
};
// Returns a new Array with the elements that are in a but not in b
function diff$1(a, b) {
return a.filter(function (a) {
return b.indexOf(a) === -1;
});
}
/**
* Determines whether an element exists in a given array or not.
*
* @method inArray
* @param {any} elem
* @param {Array} array
* @return {boolean}
*/
var inArray = Array.prototype.includes ? function (elem, array) {
return array.includes(elem);
} : function (elem, array) {
return array.indexOf(elem) !== -1;
};
/**
* Recursively clone an object into a plain array or object, taking only the
* own enumerable properties.
*
* @param {any} obj
* @param {bool} [allowArray=true]
* @return {Object|Array}
*/
function objectValues(obj) {
var allowArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var vals = allowArray && is('array', obj) ? [] : {};
for (var key in obj) {
if (hasOwn$2.call(obj, key)) {
var val = obj[key];
vals[key] = val === Object(val) ? objectValues(val, allowArray) : val;
}
}
return vals;
}
/**
* Recursively clone an object into a plain object, taking only the
* subset of own enumerable properties that exist a given model.
*
* @param {any} obj
* @param {any} model
* @return {Object}
*/
function objectValuesSubset(obj, model) {
// Return primitive values unchanged to avoid false positives or confusing
// results from assert.propContains().
// E.g. an actual null or false wrongly equaling an empty object,
// or an actual string being reported as object not matching a partial object.
if (obj !== Object(obj)) {
return obj;
}
// Unlike objectValues(), subset arrays to a plain objects as well.
// This enables subsetting [20, 30] with {1: 30}.
var subset = {};
for (var key in model) {
if (hasOwn$2.call(model, key) && hasOwn$2.call(obj, key)) {
subset[key] = objectValuesSubset(obj[key], model[key]);
}
}
return subset;
}
function extend(a, b, undefOnly) {
for (var prop in b) {
if (hasOwn$2.call(b, prop)) {
if (b[prop] === undefined) {
delete a[prop];
} else if (!(undefOnly && typeof a[prop] !== 'undefined')) {
a[prop] = b[prop];
}
}
}
return a;
}
function objectType(obj) {
if (typeof obj === 'undefined') {
return 'undefined';
}
// Consider: typeof null === object
if (obj === null) {
return 'null';
}
var match = toString.call(obj).match(/^\[object\s(.*)\]$/);
var type = match && match[1];
switch (type) {
case 'Number':
if (isNaN(obj)) {
return 'nan';
}
return 'number';
case 'String':
case 'Boolean':
case 'Array':
case 'Set':
case 'Map':
case 'Date':
case 'RegExp':
case 'Function':
case 'Symbol':
return type.toLowerCase();
default:
return _typeof(obj);
}
}
// Safe object type checking
function is(type, obj) {
return objectType(obj) === type;
}
// Based on Java's String.hashCode, a simple but not
// rigorously collision resistant hashing function
function generateHash(module, testName) {
var str = module + '\x1C' + testName;
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = (hash << 5) - hash + str.charCodeAt(i);
hash |= 0;
}
// Convert the possibly negative integer hash code into an 8 character hex string, which isn't
// strictly necessary but increases user understanding that the id is a SHA-like hash
var hex = (0x100000000 + hash).toString(16);
if (hex.length < 8) {
hex = '0000000' + hex;
}
return hex.slice(-8);
}
/**
* Converts an error into a simple string for comparisons.
*
* @param {Error|any} error
* @return {string}
*/
function errorString(error) {
// Use String() instead of toString() to handle non-object values like undefined or null.
var resultErrorString = String(error);
// If the error wasn't a subclass of Error but something like
// an object literal with name and message properties...
if (resultErrorString.slice(0, 7) === '[object') {
// Based on https://es5.github.io/#x15.11.4.4
return (error.name || 'Error') + (error.message ? ": ".concat(error.message) : '');
} else {
return resultErrorString;
}
}
function escapeText(str) {
if (!str) {
return '';
}
// Both single quotes and double quotes (for attributes)
return ('' + str).replace(/['"<>&]/g, function (s) {
switch (s) {
case "'":
return ''';
case '"':
return '"';
case '<':
return '<';
case '>':
return '>';
case '&':
return '&';
}
});
}
var BOXABLE_TYPES = new StringSet(['boolean', 'number', 'string']);
// Memory for previously seen containers (object, array, map, set).
// Used for recursion detection, and to avoid repeated comparison.
//
// Elements are { a: val, b: val }.
var memory = [];
function useStrictEquality(a, b) {
return a === b;
}
function useObjectValueEquality(a, b) {
return a === b || a.valueOf() === b.valueOf();
}
function compareConstructors(a, b) {
// Comparing constructors is more strict than using `instanceof`
return getConstructor(a) === getConstructor(b);
}
function getConstructor(obj) {
var proto = Object.getPrototypeOf(obj);
// If the obj prototype descends from a null constructor, treat it
// as a null prototype.
// Ref https://github.com/qunitjs/qunit/issues/851
//
// Allow objects with no prototype, from Object.create(null), to be equivalent to
// plain objects that have Object as their constructor.
return !proto || proto.constructor === null ? Object : obj.constructor;
}
function getRegExpFlags(regexp) {
return 'flags' in regexp ? regexp.flags : regexp.toString().match(/[gimuy]*$/)[0];
}
// Specialised comparisons after entryTypeCallbacks.object, based on `objectType()`
var objTypeCallbacks = {
undefined: useStrictEquality,
null: useStrictEquality,
// Handle boxed boolean
boolean: useObjectValueEquality,
number: function number(a, b) {
// Handle NaN and boxed number
return a === b || a.valueOf() === b.valueOf() || isNaN(a.valueOf()) && isNaN(b.valueOf());
},
// Handle boxed string
string: useObjectValueEquality,
symbol: useStrictEquality,
date: useObjectValueEquality,
nan: function nan() {
return true;
},
regexp: function regexp(a, b) {
return a.source === b.source &&
// Include flags in the comparison
getRegExpFlags(a) === getRegExpFlags(b);
},
// identical reference only
function: useStrictEquality,
array: function array(a, b) {
if (a.length !== b.length) {
// Safe and faster
return false;
}
for (var i = 0; i < a.length; i++) {
if (!typeEquiv(a[i], b[i])) {
return false;
}
}
return true;
},
// Define sets a and b to be equivalent if for each element aVal in a, there
// is some element bVal in b such that aVal and bVal are equivalent. Element
// repetitions are not counted, so these are equivalent:
// a = new Set( [ X={}, Y=[], Y ] );
// b = new Set( [ Y, X, X ] );
set: function set(a, b) {
if (a.size !== b.size) {
// This optimization has certain quirks because of the lack of
// repetition counting. For instance, adding the same
// (reference-identical) element to two equivalent sets can
// make them non-equivalent.
return false;
}
var outerEq = true;
a.forEach(function (aVal) {
// Short-circuit if the result is already known. (Using for...of
// with a break clause would be cleaner here, but it would cause
// a syntax error on older JavaScript implementations even if
// Set is unused)
if (!outerEq) {
return;
}
var innerEq = false;
b.forEach(function (bVal) {
// Likewise, short-circuit if the result is already known
if (innerEq) {
return;
}
// Swap out the global memory, as nested typeEquiv() would clobber it
var originalMemory = memory;
memory = [];
if (typeEquiv(bVal, aVal)) {
innerEq = true;
}
// Restore
memory = originalMemory;
});
if (!innerEq) {
outerEq = false;
}
});
return outerEq;
},
// Define maps a and b to be equivalent if for each key-value pair (aKey, aVal)
// in a, there is some key-value pair (bKey, bVal) in b such that
// [ aKey, aVal ] and [ bKey, bVal ] are equivalent. Key repetitions are not
// counted, so these are equivalent:
// a = new Map( [ [ {}, 1 ], [ {}, 1 ], [ [], 1 ] ] );
// b = new Map( [ [ {}, 1 ], [ [], 1 ], [ [], 1 ] ] );
map: function map(a, b) {
if (a.size !== b.size) {
// This optimization has certain quirks because of the lack of
// repetition counting. For instance, adding the same
// (reference-identical) key-value pair to two equivalent maps
// can make them non-equivalent.
return false;
}
var outerEq = true;
a.forEach(function (aVal, aKey) {
// Short-circuit if the result is already known. (Using for...of
// with a break clause would be cleaner here, but it would cause
// a syntax error on older JavaScript implementations even if
// Map is unused)
if (!outerEq) {
return;
}
var innerEq = false;
b.forEach(function (bVal, bKey) {
// Likewise, short-circuit if the result is already known
if (innerEq) {
return;
}
// Swap out the global memory, as nested typeEquiv() would clobber it
var originalMemory = memory;
memory = [];
if (objTypeCallbacks.array([bVal, bKey], [aVal, aKey])) {
innerEq = true;
}
// Restore
memory = originalMemory;
});
if (!innerEq) {
outerEq = false;
}
});
return outerEq;
}
};
// Entry points from typeEquiv, based on `typeof`
var entryTypeCallbacks = {
undefined: useStrictEquality,
null: useStrictEquality,
boolean: useStrictEquality,
number: function number(a, b) {
// Handle NaN
return a === b || isNaN(a) && isNaN(b);
},
string: useStrictEquality,
symbol: useStrictEquality,
function: useStrictEquality,
object: function object(a, b) {
// Handle memory (skip recursion)
if (memory.some(function (pair) {
return pair.a === a && pair.b === b;
})) {
return true;
}
memory.push({
a: a,
b: b
});
var aObjType = objectType(a);
var bObjType = objectType(b);
if (aObjType !== 'object' || bObjType !== 'object') {
// Handle literal `null`
// Handle: Array, Map/Set, Date, Regxp/Function, boxed primitives
return aObjType === bObjType && objTypeCallbacks[aObjType](a, b);
}
// NOTE: Literal null must not make it here as it would throw
if (compareConstructors(a, b) === false) {
return false;
}
var aProperties = [];
var bProperties = [];
// Be strict and go deep, no filtering with hasOwnProperty.
for (var i in a) {
// Collect a's properties
aProperties.push(i);
// Skip OOP methods that look the same
if (a.constructor !== Object && typeof a.constructor !== 'undefined' && typeof a[i] === 'function' && typeof b[i] === 'function' && a[i].toString() === b[i].toString()) {
continue;
}
if (!typeEquiv(a[i], b[i])) {
return false;
}
}
for (var _i in b) {
// Collect b's properties
bProperties.push(_i);
}
return objTypeCallbacks.array(aProperties.sort(), bProperties.sort());
}
};
function typeEquiv(a, b) {
// Optimization: Only perform type-specific comparison when pairs are not strictly equal.
if (a === b) {
return true;
}
var aType = _typeof(a);
var bType = _typeof(b);
if (aType !== bType) {
// Support comparing primitive to boxed primitives
// Try again after possibly unwrapping one
return (aType === 'object' && BOXABLE_TYPES.has(objectType(a)) ? a.valueOf() : a) === (bType === 'object' && BOXABLE_TYPES.has(objectType(b)) ? b.valueOf() : b);
}
return entryTypeCallbacks[aType](a, b);
}
function innerEquiv(a, b) {
var res = typeEquiv(a, b);
// Release any retained objects and reset recursion detection for next call
memory = [];
return res;
}
/**
* Test any two types of JavaScript values for equality.
*
* @author Philippe Rathé <[email protected]>
* @author David Chan <[email protected]>
*/
function equiv(a, b) {
if (arguments.length === 2) {
return a === b || innerEquiv(a, b);
}
// Given 0 or 1 arguments, just return true (nothing to compare).
// Given (A,B,C,D) compare C,D then B,C then A,B.
var i = arguments.length - 1;
while (i > 0) {
if (!innerEquiv(arguments[i - 1], arguments[i])) {
return false;
}
i--;
}
return true;
}
/**
* Config object: Maintain internal state
* Later exposed as QUnit.config
* `config` initialized at top of scope
*/
var config = {
// HTML Reporter: Modify document.title when suite is done
altertitle: true,
// TODO: Move here from /src/core.js in QUnit 3.
// autostart: true,
// HTML Reporter: collapse every test except the first failing test
// If false, all failing tests will be expanded
collapse: true,
countStepsAsOne: false,
// TODO: Make explicit in QUnit 3.
// current: undefined,
// whether or not to fail when there are zero tests
// defaults to `true`
failOnZeroTests: true,
// Select by pattern or case-insensitive substring match against "moduleName: testName"
filter: undefined,
// TODO: Make explicit in QUnit 3.
// fixture: undefined,
// Depth up-to which object will be dumped
maxDepth: 5,
// Select case-insensitive match of the module name
module: undefined,
// HTML Reporter: Select module/test by array of internal IDs
moduleId: undefined,
// By default, run previously failed tests first
// very useful in combination with "Hide passed tests" checked
reorder: true,
// When enabled, all tests must call expect()
requireExpects: false,
// By default, scroll to top of the page when suite is done
scrolltop: true,
// TODO: Make explicit in QUnit 3.
// seed: undefined,
// The storage module to use for reordering tests
storage: localSessionStorage,
testId: undefined,
// The updateRate controls how often QUnit will yield the main thread
// between tests. This is mainly for the benefit of the HTML Reporter,
// so that the browser can visually paint DOM changes with test results.
// This also helps avoid causing browsers to prompt a warning about
// long-running scripts.
// TODO: Move here from /src/core.js in QUnit 3.
// updateRate: 1000,
// HTML Reporter: List of URL parameters that are given visual controls
urlConfig: [],
// Internal: The first unnamed module
//
// By being defined as the intial value for currentModule, it is the
// receptacle and implied parent for any global tests. It is as if we
// called `QUnit.module( "" );` before any other tests were defined.
//
// If we reach begin() and no tests were put in it, we dequeue it as if it
// never existed, and in that case never expose it to the events and
// callbacks API.
//
// When global tests are defined, then this unnamed module will execute
// as any other module, including moduleStart/moduleDone events etc.
//
// Since this module isn't explicitly created by the user, they have no
// access to add hooks for it. The hooks object is defined to comply
// with internal expectations of test.js, but they will be empty.
// To apply hooks, place tests explicitly in a QUnit.module(), and use
// its hooks accordingly.
//
// For global hooks that apply to all tests and all modules, use QUnit.hooks.
//
// NOTE: This is *not* a "global module". It is not an ancestor of all modules
// and tests. It is merely the parent for any tests defined globally,
// before the first QUnit.module(). As such, the events for this unnamed
// module will fire as normal, right after its last test, and *not* at
// the end of the test run.
//
// NOTE: This also should probably also not become a global module, unless
// we keep it out of the public API. For example, it would likely not
// improve the user interface and plugin behaviour if all modules became
// wrapped between the start and end events of this module, and thus
// needlessly add indentation, indirection, or other visible noise.
// Unit tests for the callbacks API would detect that as a regression.
currentModule: {
name: '',
tests: [],
childModules: [],
testsRun: 0,
testsIgnored: 0,
hooks: {
before: [],
beforeEach: [],
afterEach: [],
after: []
}
},
// Internal: Exposed to make resets easier
// Ref https://github.com/qunitjs/qunit/pull/1598
globalHooks: {},
// Internal: ProcessingQueue singleton, created in /src/core.js
pq: null,
// Internal: Created in /src/core.js
// TODO: Move definitions here in QUnit 3.0.
// started: 0,
// Internal state
_deprecated_timeout_shown: false,
_deprecated_countEachStep_shown: false,
blocking: true,
callbacks: {},
modules: [],
queue: [],
stats: {
all: 0,
bad: 0,
testCount: 0
}
};
function readFlatPreconfigBoolean(val, dest) {
if (typeof val === 'boolean' || typeof val === 'string' && val !== '') {
config[dest] = val === true || val === 'true';
}
}
function readFlatPreconfigNumber(val, dest) {
if (typeof val === 'number' || typeof val === 'string' && /^[0-9]+$/.test(val)) {
config[dest] = +val;
}
}
function readFlatPreconfigString(val, dest) {
if (typeof val === 'string' && val !== '') {
config[dest] = val;
}
}
function readFlatPreconfigStringArray(val, dest) {
if (typeof val === 'string' && val !== '') {
config[dest] = [val];
}
}
function readFlatPreconfig(obj) {
readFlatPreconfigBoolean(obj.qunit_config_altertitle, 'altertitle');
readFlatPreconfigBoolean(obj.qunit_config_autostart, 'autostart');
readFlatPreconfigBoolean(obj.qunit_config_collapse, 'collapse');
readFlatPreconfigBoolean(obj.qunit_config_failonzerotests, 'failOnZeroTests');
readFlatPreconfigString(obj.qunit_config_filter, 'filter');
readFlatPreconfigString(obj.qunit_config_fixture, 'fixture');
readFlatPreconfigBoolean(obj.qunit_config_hidepassed, 'hidepassed');
readFlatPreconfigNumber(obj.qunit_config_maxdepth, 'maxDepth');
readFlatPreconfigString(obj.qunit_config_module, 'module');
readFlatPreconfigStringArray(obj.qunit_config_moduleid, 'moduleId');
readFlatPreconfigBoolean(obj.qunit_config_noglobals, 'noglobals');
readFlatPreconfigBoolean(obj.qunit_config_notrycatch, 'notrycatch');
readFlatPreconfigBoolean(obj.qunit_config_reorder, 'reorder');
readFlatPreconfigBoolean(obj.qunit_config_requireexpects, 'requireExpects');
readFlatPreconfigBoolean(obj.qunit_config_scrolltop, 'scrolltop');
readFlatPreconfigString(obj.qunit_config_seed, 'seed');
readFlatPreconfigStringArray(obj.qunit_config_testid, 'testId');
readFlatPreconfigNumber(obj.qunit_config_testtimeout, 'testTimeout');
}
if (process$1 && 'env' in process$1) {
readFlatPreconfig(process$1.env);
}
readFlatPreconfig(g);
// Apply a predefined QUnit.config object
//
// Ignore QUnit.config if it is a QUnit distribution instead of preconfig.
// That means QUnit was loaded twice! (Use the same approach as export.js)
var preConfig = g && g.QUnit && !g.QUnit.version && g.QUnit.config;
if (preConfig) {
extend(config, preConfig);
}
// Push a loose unnamed module to the modules collection
config.modules.push(config.currentModule);
var dump = (function () {
function quote(str) {
return '"' + str.toString().replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
}
function literal(o) {
return o + '';
}
function join(pre, arr, post) {
var s = dump.separator();
var inner = dump.indent(1);
if (arr.join) {
arr = arr.join(',' + s + inner);
}
if (!arr) {
return pre + post;
}
var base = dump.indent();
return [pre, inner + arr, base + post].join(s);
}
function array(arr, stack) {
if (dump.maxDepth && dump.depth > dump.maxDepth) {
return '[object Array]';
}
this.up();
var i = arr.length;
var ret = new Array(i);
while (i--) {
ret[i] = this.parse(arr[i], undefined, stack);
}
this.down();
return join('[', ret, ']');
}
function isArray(obj) {
return (
// Native Arrays
toString.call(obj) === '[object Array]' ||
// NodeList objects
typeof obj.length === 'number' && obj.item !== undefined && (obj.length ? obj.item(0) === obj[0] : obj.item(0) === null && obj[0] === undefined)
);
}
var reName = /^function (\w+)/;
var dump = {
// The objType is used mostly internally, you can fix a (custom) type in advance
parse: function parse(obj, objType, stack) {
stack = stack || [];
var objIndex = stack.indexOf(obj);
if (objIndex !== -1) {
return "recursion(".concat(objIndex - stack.length, ")");
}
objType = objType || this.typeOf(obj);
var parser = this.parsers[objType];
var parserType = _typeof(parser);
if (parserType === 'function') {
stack.push(obj);
var res = parser.call(this, obj, stack);
stack.pop();
return res;
}
if (parserType === 'string') {
return parser;
}
return '[ERROR: Missing QUnit.dump formatter for type ' + objType + ']';
},
typeOf: function typeOf(obj) {
var type;
if (obj === null) {
type = 'null';
} else if (typeof obj === 'undefined') {
type = 'undefined';
} else if (is('regexp', obj)) {
type = 'regexp';
} else if (is('date', obj)) {
type = 'date';
} else if (is('function', obj)) {
type = 'function';
} else if (obj.setInterval !== undefined && obj.document !== undefined && obj.nodeType === undefined) {
type = 'window';
} else if (obj.nodeType === 9) {
type = 'document';
} else if (obj.nodeType) {
type = 'node';
} else if (isArray(obj)) {
type = 'array';