@everyonesoftware/common 6.0.0 → 8.0.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.
- package/outputs/{characterWriteStream-DUlG_bx_.d.cts → characterWriteStream-ogvZec-U.d.cts} +25 -22
- package/outputs/{characterWriteStream-DUlG_bx_.d.ts → characterWriteStream-ogvZec-U.d.ts} +25 -22
- package/outputs/chunk-FEQPKLDH.js +1204 -0
- package/outputs/chunk-FEQPKLDH.js.map +1 -0
- package/outputs/{chunk-5Z677JON.js → chunk-OYMWB5SX.js} +7786 -3814
- package/outputs/chunk-OYMWB5SX.js.map +1 -0
- package/outputs/sourceIndex.cjs +984 -525
- package/outputs/sourceIndex.cjs.map +1 -1
- package/outputs/sourceIndex.d.cts +165 -33
- package/outputs/sourceIndex.d.ts +165 -33
- package/outputs/sourceIndex.js +55 -1094
- package/outputs/sourceIndex.js.map +1 -1
- package/outputs/testIndex.cjs +2097 -1178
- package/outputs/testIndex.cjs.map +1 -1
- package/outputs/testIndex.d.cts +163 -67
- package/outputs/testIndex.d.ts +163 -67
- package/outputs/testIndex.js +2 -2
- package/outputs/tests.cjs +14608 -12930
- package/outputs/tests.cjs.map +1 -1
- package/outputs/tests.js +3169 -2325
- package/outputs/tests.js.map +1 -1
- package/package.json +1 -1
- package/outputs/chunk-5Z677JON.js.map +0 -1
- package/outputs/chunk-6V7JRJ7P.js +0 -2469
- package/outputs/chunk-6V7JRJ7P.js.map +0 -1
- package/outputs/chunk-CHBOMCYM.js +0 -845
- package/outputs/chunk-CHBOMCYM.js.map +0 -1
package/outputs/testIndex.cjs
CHANGED
|
@@ -425,7 +425,26 @@ var PromiseAsyncResult = class _PromiseAsyncResult {
|
|
|
425
425
|
}
|
|
426
426
|
static create(actionOrPromise) {
|
|
427
427
|
PreCondition.assertNotUndefinedAndNotNull(actionOrPromise, "action or promise");
|
|
428
|
-
|
|
428
|
+
let promise;
|
|
429
|
+
if (isPromise(actionOrPromise)) {
|
|
430
|
+
promise = actionOrPromise;
|
|
431
|
+
} else {
|
|
432
|
+
let actionExecutor2 = function(resolve, reject) {
|
|
433
|
+
try {
|
|
434
|
+
resolve(action());
|
|
435
|
+
} catch (error) {
|
|
436
|
+
reject(error);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
var actionExecutor = actionExecutor2;
|
|
440
|
+
const action = actionOrPromise;
|
|
441
|
+
;
|
|
442
|
+
promise = new Promise(actionExecutor2);
|
|
443
|
+
}
|
|
444
|
+
return new _PromiseAsyncResult(promise);
|
|
445
|
+
}
|
|
446
|
+
static empty() {
|
|
447
|
+
return _PromiseAsyncResult.create(Promise.resolve());
|
|
429
448
|
}
|
|
430
449
|
static value(value) {
|
|
431
450
|
return _PromiseAsyncResult.create(Promise.resolve(value));
|
|
@@ -1685,6 +1704,118 @@ var Iterator = class _Iterator {
|
|
|
1685
1704
|
}
|
|
1686
1705
|
};
|
|
1687
1706
|
|
|
1707
|
+
// sources/Indexable.ts
|
|
1708
|
+
var Indexable = class _Indexable {
|
|
1709
|
+
static create(values) {
|
|
1710
|
+
return List.create(values);
|
|
1711
|
+
}
|
|
1712
|
+
toArray() {
|
|
1713
|
+
return _Indexable.toArray(this);
|
|
1714
|
+
}
|
|
1715
|
+
static toArray(indexable) {
|
|
1716
|
+
return Iterable.toArray(indexable);
|
|
1717
|
+
}
|
|
1718
|
+
any() {
|
|
1719
|
+
return _Indexable.any(this);
|
|
1720
|
+
}
|
|
1721
|
+
static any(indexable) {
|
|
1722
|
+
return Iterable.any(indexable);
|
|
1723
|
+
}
|
|
1724
|
+
getCount() {
|
|
1725
|
+
return _Indexable.getCount(this);
|
|
1726
|
+
}
|
|
1727
|
+
static getCount(indexable) {
|
|
1728
|
+
return Iterable.getCount(indexable);
|
|
1729
|
+
}
|
|
1730
|
+
equals(right, equalFunctions) {
|
|
1731
|
+
return _Indexable.equals(this, right, equalFunctions);
|
|
1732
|
+
}
|
|
1733
|
+
static equals(left, right, equalFunctions) {
|
|
1734
|
+
return Iterable.equals(left, right, equalFunctions);
|
|
1735
|
+
}
|
|
1736
|
+
toString(toStringFunctions) {
|
|
1737
|
+
return _Indexable.toString(this, toStringFunctions);
|
|
1738
|
+
}
|
|
1739
|
+
static toString(indexable, toStringFunctions) {
|
|
1740
|
+
return Iterable.toString(indexable, toStringFunctions);
|
|
1741
|
+
}
|
|
1742
|
+
concatenate(...toConcatenate) {
|
|
1743
|
+
return _Indexable.concatenate(this, ...toConcatenate);
|
|
1744
|
+
}
|
|
1745
|
+
static concatenate(indexable, ...toConcatenate) {
|
|
1746
|
+
return Iterable.concatenate(indexable, ...toConcatenate);
|
|
1747
|
+
}
|
|
1748
|
+
map(mapping) {
|
|
1749
|
+
return _Indexable.map(this, mapping);
|
|
1750
|
+
}
|
|
1751
|
+
static map(indexable, mapping) {
|
|
1752
|
+
return Iterable.map(indexable, mapping);
|
|
1753
|
+
}
|
|
1754
|
+
flatMap(mapping) {
|
|
1755
|
+
return _Indexable.flatMap(this, mapping);
|
|
1756
|
+
}
|
|
1757
|
+
static flatMap(indexable, mapping) {
|
|
1758
|
+
return Iterable.flatMap(indexable, mapping);
|
|
1759
|
+
}
|
|
1760
|
+
where(condition) {
|
|
1761
|
+
return _Indexable.where(this, condition);
|
|
1762
|
+
}
|
|
1763
|
+
static where(indexable, condition) {
|
|
1764
|
+
return Iterable.where(indexable, condition);
|
|
1765
|
+
}
|
|
1766
|
+
instanceOf(typeOrTypeCheck) {
|
|
1767
|
+
return _Indexable.instanceOf(this, typeOrTypeCheck);
|
|
1768
|
+
}
|
|
1769
|
+
static instanceOf(indexable, typeOrTypeCheck) {
|
|
1770
|
+
return Iterable.instanceOf(indexable, typeOrTypeCheck);
|
|
1771
|
+
}
|
|
1772
|
+
first(condition) {
|
|
1773
|
+
return _Indexable.first(this, condition);
|
|
1774
|
+
}
|
|
1775
|
+
static first(indexable, condition) {
|
|
1776
|
+
let result;
|
|
1777
|
+
if (condition) {
|
|
1778
|
+
result = Iterable.first(indexable, condition);
|
|
1779
|
+
} else {
|
|
1780
|
+
if (indexable.any().await()) {
|
|
1781
|
+
result = indexable.get(0);
|
|
1782
|
+
} else {
|
|
1783
|
+
result = SyncResult.error(new EmptyError());
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
return result;
|
|
1787
|
+
}
|
|
1788
|
+
last(condition) {
|
|
1789
|
+
return _Indexable.last(this, condition);
|
|
1790
|
+
}
|
|
1791
|
+
static last(indexable, condition) {
|
|
1792
|
+
let result;
|
|
1793
|
+
if (condition) {
|
|
1794
|
+
result = Iterable.last(indexable, condition);
|
|
1795
|
+
} else {
|
|
1796
|
+
const count = indexable.getCount().await();
|
|
1797
|
+
if (count > 0) {
|
|
1798
|
+
result = indexable.get(count - 1);
|
|
1799
|
+
} else {
|
|
1800
|
+
result = SyncResult.error(new EmptyError());
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
return result;
|
|
1804
|
+
}
|
|
1805
|
+
[Symbol.iterator]() {
|
|
1806
|
+
return _Indexable[Symbol.iterator](this);
|
|
1807
|
+
}
|
|
1808
|
+
static [Symbol.iterator](indexable) {
|
|
1809
|
+
return Iterable[Symbol.iterator](indexable);
|
|
1810
|
+
}
|
|
1811
|
+
contains(value, equalFunctions) {
|
|
1812
|
+
return _Indexable.contains(this, value, equalFunctions);
|
|
1813
|
+
}
|
|
1814
|
+
static contains(indexable, value, equalFunctions) {
|
|
1815
|
+
return Iterable.contains(indexable, value, equalFunctions);
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
|
|
1688
1819
|
// sources/javascriptArrayList.ts
|
|
1689
1820
|
var JavascriptArrayList = class _JavascriptArrayList {
|
|
1690
1821
|
array;
|
|
@@ -1786,6 +1917,97 @@ var JavascriptArrayList = class _JavascriptArrayList {
|
|
|
1786
1917
|
}
|
|
1787
1918
|
};
|
|
1788
1919
|
|
|
1920
|
+
// sources/MutableIndexable.ts
|
|
1921
|
+
var MutableIndexable = class _MutableIndexable {
|
|
1922
|
+
static create(values) {
|
|
1923
|
+
return List.create(values);
|
|
1924
|
+
}
|
|
1925
|
+
toArray() {
|
|
1926
|
+
return _MutableIndexable.toArray(this);
|
|
1927
|
+
}
|
|
1928
|
+
static toArray(indexable) {
|
|
1929
|
+
return Indexable.toArray(indexable);
|
|
1930
|
+
}
|
|
1931
|
+
any() {
|
|
1932
|
+
return _MutableIndexable.any(this);
|
|
1933
|
+
}
|
|
1934
|
+
static any(indexable) {
|
|
1935
|
+
return Indexable.any(indexable);
|
|
1936
|
+
}
|
|
1937
|
+
getCount() {
|
|
1938
|
+
return _MutableIndexable.getCount(this);
|
|
1939
|
+
}
|
|
1940
|
+
static getCount(indexable) {
|
|
1941
|
+
return Indexable.getCount(indexable);
|
|
1942
|
+
}
|
|
1943
|
+
equals(right, equalFunctions) {
|
|
1944
|
+
return _MutableIndexable.equals(this, right, equalFunctions);
|
|
1945
|
+
}
|
|
1946
|
+
static equals(left, right, equalFunctions) {
|
|
1947
|
+
return Indexable.equals(left, right, equalFunctions);
|
|
1948
|
+
}
|
|
1949
|
+
toString(toStringFunctions) {
|
|
1950
|
+
return _MutableIndexable.toString(this, toStringFunctions);
|
|
1951
|
+
}
|
|
1952
|
+
static toString(indexable, toStringFunctions) {
|
|
1953
|
+
return Indexable.toString(indexable, toStringFunctions);
|
|
1954
|
+
}
|
|
1955
|
+
concatenate(...toConcatenate) {
|
|
1956
|
+
return _MutableIndexable.concatenate(this, ...toConcatenate);
|
|
1957
|
+
}
|
|
1958
|
+
static concatenate(indexable, ...toConcatenate) {
|
|
1959
|
+
return Indexable.concatenate(indexable, ...toConcatenate);
|
|
1960
|
+
}
|
|
1961
|
+
map(mapping) {
|
|
1962
|
+
return _MutableIndexable.map(this, mapping);
|
|
1963
|
+
}
|
|
1964
|
+
static map(indexable, mapping) {
|
|
1965
|
+
return Indexable.map(indexable, mapping);
|
|
1966
|
+
}
|
|
1967
|
+
flatMap(mapping) {
|
|
1968
|
+
return _MutableIndexable.flatMap(this, mapping);
|
|
1969
|
+
}
|
|
1970
|
+
static flatMap(indexable, mapping) {
|
|
1971
|
+
return Indexable.flatMap(indexable, mapping);
|
|
1972
|
+
}
|
|
1973
|
+
where(condition) {
|
|
1974
|
+
return _MutableIndexable.where(this, condition);
|
|
1975
|
+
}
|
|
1976
|
+
static where(indexable, condition) {
|
|
1977
|
+
return Indexable.where(indexable, condition);
|
|
1978
|
+
}
|
|
1979
|
+
instanceOf(typeOrTypeCheck) {
|
|
1980
|
+
return _MutableIndexable.instanceOf(this, typeOrTypeCheck);
|
|
1981
|
+
}
|
|
1982
|
+
static instanceOf(indexable, typeOrTypeCheck) {
|
|
1983
|
+
return Indexable.instanceOf(indexable, typeOrTypeCheck);
|
|
1984
|
+
}
|
|
1985
|
+
first(condition) {
|
|
1986
|
+
return _MutableIndexable.first(this, condition);
|
|
1987
|
+
}
|
|
1988
|
+
static first(indexable, condition) {
|
|
1989
|
+
return Indexable.first(indexable, condition);
|
|
1990
|
+
}
|
|
1991
|
+
last(condition) {
|
|
1992
|
+
return _MutableIndexable.last(this, condition);
|
|
1993
|
+
}
|
|
1994
|
+
static last(indexable, condition) {
|
|
1995
|
+
return Indexable.last(indexable, condition);
|
|
1996
|
+
}
|
|
1997
|
+
[Symbol.iterator]() {
|
|
1998
|
+
return Indexable[Symbol.iterator](this);
|
|
1999
|
+
}
|
|
2000
|
+
static [Symbol.iterator](indexable) {
|
|
2001
|
+
return Iterable[Symbol.iterator](indexable);
|
|
2002
|
+
}
|
|
2003
|
+
contains(value, equalFunctions) {
|
|
2004
|
+
return _MutableIndexable.contains(this, value, equalFunctions);
|
|
2005
|
+
}
|
|
2006
|
+
static contains(indexable, value, equalFunctions) {
|
|
2007
|
+
return Indexable.contains(indexable, value, equalFunctions);
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
|
|
1789
2011
|
// sources/javascript.ts
|
|
1790
2012
|
var JavascriptMap = Map;
|
|
1791
2013
|
var JavascriptSet = Set;
|
|
@@ -2633,85 +2855,85 @@ var List = class _List {
|
|
|
2633
2855
|
return _List.toArray(this);
|
|
2634
2856
|
}
|
|
2635
2857
|
static toArray(list2) {
|
|
2636
|
-
return
|
|
2858
|
+
return MutableIndexable.toArray(list2);
|
|
2637
2859
|
}
|
|
2638
2860
|
any() {
|
|
2639
2861
|
return _List.any(this);
|
|
2640
2862
|
}
|
|
2641
2863
|
static any(list2) {
|
|
2642
|
-
return
|
|
2864
|
+
return MutableIndexable.any(list2);
|
|
2643
2865
|
}
|
|
2644
2866
|
getCount() {
|
|
2645
2867
|
return _List.getCount(this);
|
|
2646
2868
|
}
|
|
2647
2869
|
static getCount(list2) {
|
|
2648
|
-
return
|
|
2870
|
+
return MutableIndexable.getCount(list2);
|
|
2649
2871
|
}
|
|
2650
2872
|
equals(right, equalFunctions) {
|
|
2651
2873
|
return _List.equals(this, right, equalFunctions);
|
|
2652
2874
|
}
|
|
2653
2875
|
static equals(left, right, equalFunctions) {
|
|
2654
|
-
return
|
|
2876
|
+
return MutableIndexable.equals(left, right, equalFunctions);
|
|
2655
2877
|
}
|
|
2656
2878
|
toString(toStringFunctions) {
|
|
2657
2879
|
return _List.toString(this, toStringFunctions);
|
|
2658
2880
|
}
|
|
2659
2881
|
static toString(list2, toStringFunctions) {
|
|
2660
|
-
return
|
|
2882
|
+
return MutableIndexable.toString(list2, toStringFunctions);
|
|
2661
2883
|
}
|
|
2662
2884
|
concatenate(...toConcatenate) {
|
|
2663
2885
|
return _List.concatenate(this, ...toConcatenate);
|
|
2664
2886
|
}
|
|
2665
2887
|
static concatenate(list2, ...toConcatenate) {
|
|
2666
|
-
return
|
|
2888
|
+
return MutableIndexable.concatenate(list2, ...toConcatenate);
|
|
2667
2889
|
}
|
|
2668
2890
|
map(mapping) {
|
|
2669
2891
|
return _List.map(this, mapping);
|
|
2670
2892
|
}
|
|
2671
2893
|
static map(list2, mapping) {
|
|
2672
|
-
return
|
|
2894
|
+
return MutableIndexable.map(list2, mapping);
|
|
2673
2895
|
}
|
|
2674
2896
|
flatMap(mapping) {
|
|
2675
2897
|
return _List.flatMap(this, mapping);
|
|
2676
2898
|
}
|
|
2677
2899
|
static flatMap(list2, mapping) {
|
|
2678
|
-
return
|
|
2900
|
+
return MutableIndexable.flatMap(list2, mapping);
|
|
2679
2901
|
}
|
|
2680
2902
|
where(condition) {
|
|
2681
2903
|
return _List.where(this, condition);
|
|
2682
2904
|
}
|
|
2683
2905
|
static where(list2, condition) {
|
|
2684
|
-
return
|
|
2906
|
+
return MutableIndexable.where(list2, condition);
|
|
2685
2907
|
}
|
|
2686
2908
|
instanceOf(typeOrTypeCheck) {
|
|
2687
2909
|
return _List.instanceOf(this, typeOrTypeCheck);
|
|
2688
2910
|
}
|
|
2689
2911
|
static instanceOf(list2, typeOrTypeCheck) {
|
|
2690
|
-
return
|
|
2912
|
+
return MutableIndexable.instanceOf(list2, typeOrTypeCheck);
|
|
2691
2913
|
}
|
|
2692
2914
|
first(condition) {
|
|
2693
2915
|
return _List.first(this, condition);
|
|
2694
2916
|
}
|
|
2695
2917
|
static first(list2, condition) {
|
|
2696
|
-
return
|
|
2918
|
+
return MutableIndexable.first(list2, condition);
|
|
2697
2919
|
}
|
|
2698
2920
|
last(condition) {
|
|
2699
2921
|
return _List.last(this, condition);
|
|
2700
2922
|
}
|
|
2701
2923
|
static last(list2, condition) {
|
|
2702
|
-
return
|
|
2924
|
+
return MutableIndexable.last(list2, condition);
|
|
2703
2925
|
}
|
|
2704
2926
|
[Symbol.iterator]() {
|
|
2705
2927
|
return _List[Symbol.iterator](this);
|
|
2706
2928
|
}
|
|
2707
2929
|
static [Symbol.iterator](list2) {
|
|
2708
|
-
return
|
|
2930
|
+
return Indexable[Symbol.iterator](list2);
|
|
2709
2931
|
}
|
|
2710
2932
|
contains(value, equalFunctions) {
|
|
2711
2933
|
return _List.contains(this, value, equalFunctions);
|
|
2712
2934
|
}
|
|
2713
2935
|
static contains(list2, value, equalFunctions) {
|
|
2714
|
-
return
|
|
2936
|
+
return MutableIndexable.contains(list2, value, equalFunctions);
|
|
2715
2937
|
}
|
|
2716
2938
|
};
|
|
2717
2939
|
|
|
@@ -3068,7 +3290,7 @@ var WhereIterable = class _WhereIterable {
|
|
|
3068
3290
|
// sources/iterable.ts
|
|
3069
3291
|
var Iterable = class _Iterable {
|
|
3070
3292
|
static create(values) {
|
|
3071
|
-
return
|
|
3293
|
+
return Indexable.create(values);
|
|
3072
3294
|
}
|
|
3073
3295
|
[Symbol.iterator]() {
|
|
3074
3296
|
return _Iterable[Symbol.iterator](this);
|
|
@@ -3555,7 +3777,7 @@ var MutableCondition = class _MutableCondition {
|
|
|
3555
3777
|
}
|
|
3556
3778
|
assertNotEmpty(value, expression, message) {
|
|
3557
3779
|
this.assertNotUndefinedAndNotNull(value, expression, message);
|
|
3558
|
-
if (isString(value) && value.length === 0 || isJavascriptIterable(value) && !Iterable.create(value).any()) {
|
|
3780
|
+
if (isString(value) && value.length === 0 || isJavascriptIterable(value) && !Iterable.create(value).any().await()) {
|
|
3559
3781
|
throw this.createError({
|
|
3560
3782
|
expected: "not empty",
|
|
3561
3783
|
actual: this.toValueString(value),
|
|
@@ -3921,395 +4143,142 @@ var PreCondition = class _PreCondition {
|
|
|
3921
4143
|
}
|
|
3922
4144
|
};
|
|
3923
4145
|
|
|
3924
|
-
//
|
|
3925
|
-
var
|
|
3926
|
-
|
|
3927
|
-
* Assert that the provided value is undefined;
|
|
3928
|
-
* @param value The value to check.
|
|
3929
|
-
*/
|
|
3930
|
-
assertUndefined(value) {
|
|
3931
|
-
_Test.assertUndefined(this, value);
|
|
4146
|
+
// sources/ANSIStyles.ts
|
|
4147
|
+
var ANSIStyles = class {
|
|
4148
|
+
constructor() {
|
|
3932
4149
|
}
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
* @param test The current {@link Test}.
|
|
3936
|
-
* @param value The value to check.
|
|
3937
|
-
*/
|
|
3938
|
-
static assertUndefined(test2, value) {
|
|
3939
|
-
test2.assertSame(value, void 0);
|
|
4150
|
+
static color(colorCode, text) {
|
|
4151
|
+
return `\x1B[${colorCode}m${text}\x1B[0m`;
|
|
3940
4152
|
}
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
* @param value The value to check.
|
|
3944
|
-
*/
|
|
3945
|
-
assertNotUndefined(value) {
|
|
3946
|
-
_Test.assertNotUndefined(this, value);
|
|
4153
|
+
static black(text) {
|
|
4154
|
+
return this.color(30, text);
|
|
3947
4155
|
}
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
4156
|
+
static red(text) {
|
|
4157
|
+
return this.color(31, text);
|
|
4158
|
+
}
|
|
4159
|
+
static green(text) {
|
|
4160
|
+
return this.color(32, text);
|
|
4161
|
+
}
|
|
4162
|
+
static yellow(text) {
|
|
4163
|
+
return this.color(33, text);
|
|
4164
|
+
}
|
|
4165
|
+
static blue(text) {
|
|
4166
|
+
return this.color(34, text);
|
|
4167
|
+
}
|
|
4168
|
+
};
|
|
4169
|
+
|
|
4170
|
+
// sources/asyncResult.ts
|
|
4171
|
+
var AsyncResult = class {
|
|
4172
|
+
static create(actionOrPromise) {
|
|
4173
|
+
return PromiseAsyncResult.create(actionOrPromise);
|
|
3955
4174
|
}
|
|
3956
4175
|
/**
|
|
3957
|
-
*
|
|
3958
|
-
* @param value The value to check.
|
|
4176
|
+
* Get an {@link AsyncResult} that is already completed and doesn't do anything.
|
|
3959
4177
|
*/
|
|
3960
|
-
|
|
3961
|
-
|
|
4178
|
+
static empty() {
|
|
4179
|
+
return PromiseAsyncResult.empty();
|
|
3962
4180
|
}
|
|
3963
4181
|
/**
|
|
3964
|
-
*
|
|
3965
|
-
* @param value The value to
|
|
4182
|
+
* Create a new {@link AsyncResult} that contains the provided value.
|
|
4183
|
+
* @param value The value to wrap in a {@link AsyncResult}.
|
|
3966
4184
|
*/
|
|
3967
|
-
static
|
|
3968
|
-
|
|
4185
|
+
static value(value) {
|
|
4186
|
+
return PromiseAsyncResult.value(value);
|
|
3969
4187
|
}
|
|
3970
4188
|
/**
|
|
3971
|
-
*
|
|
3972
|
-
* @param
|
|
4189
|
+
* Create a new {@link AsyncResult} that contains the provided error.
|
|
4190
|
+
* @param error The error to wrap in a {@link AsyncResult}.
|
|
3973
4191
|
*/
|
|
3974
|
-
|
|
3975
|
-
|
|
4192
|
+
static error(error) {
|
|
4193
|
+
return PromiseAsyncResult.error(error);
|
|
4194
|
+
}
|
|
4195
|
+
static yield() {
|
|
4196
|
+
return PromiseAsyncResult.yield();
|
|
4197
|
+
}
|
|
4198
|
+
};
|
|
4199
|
+
|
|
4200
|
+
// sources/postConditionError.ts
|
|
4201
|
+
var PostConditionError = class extends Error {
|
|
4202
|
+
constructor(...message) {
|
|
4203
|
+
super(join("\n", message));
|
|
4204
|
+
}
|
|
4205
|
+
};
|
|
4206
|
+
|
|
4207
|
+
// sources/postCondition.ts
|
|
4208
|
+
var PostCondition = class _PostCondition {
|
|
4209
|
+
static condition;
|
|
4210
|
+
static getCondition() {
|
|
4211
|
+
if (_PostCondition.condition === void 0) {
|
|
4212
|
+
_PostCondition.condition = MutableCondition.create().setCreateErrorFunction((message) => {
|
|
4213
|
+
return new PostConditionError(message);
|
|
4214
|
+
});
|
|
4215
|
+
}
|
|
4216
|
+
return _PostCondition.condition;
|
|
3976
4217
|
}
|
|
3977
4218
|
/**
|
|
3978
|
-
* Assert that the provided value is
|
|
4219
|
+
* Assert that the provided value is undefined.
|
|
3979
4220
|
* @param value The value to check.
|
|
4221
|
+
* @param expression The name of the expression that produced the value.
|
|
4222
|
+
* @param message An additional message that will be included with the error.
|
|
3980
4223
|
*/
|
|
3981
|
-
static
|
|
3982
|
-
|
|
4224
|
+
static assertUndefined(value, expression, message) {
|
|
4225
|
+
return _PostCondition.getCondition().assertUndefined(value, expression, message);
|
|
3983
4226
|
}
|
|
3984
4227
|
/**
|
|
3985
4228
|
* Assert that the provided value is not undefined and not null.
|
|
3986
4229
|
* @param value The value to check.
|
|
4230
|
+
* @param expression The name of the expression that produced the value.
|
|
4231
|
+
* @param message An additional message that will be included with the error.
|
|
3987
4232
|
*/
|
|
3988
|
-
|
|
3989
|
-
|
|
4233
|
+
static assertNotUndefined(value, expression, message) {
|
|
4234
|
+
return _PostCondition.getCondition().assertNotUndefined(value, expression, message);
|
|
3990
4235
|
}
|
|
3991
4236
|
/**
|
|
3992
4237
|
* Assert that the provided value is not undefined and not null.
|
|
3993
4238
|
* @param value The value to check.
|
|
4239
|
+
* @param expression The name of the expression that produced the value.
|
|
4240
|
+
* @param message An additional message that will be included with the error.
|
|
3994
4241
|
*/
|
|
3995
|
-
static assertNotUndefinedAndNotNull(
|
|
3996
|
-
|
|
3997
|
-
test2.assertNotSame(value, void 0);
|
|
4242
|
+
static assertNotUndefinedAndNotNull(value, expression, message) {
|
|
4243
|
+
return _PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
|
|
3998
4244
|
}
|
|
3999
4245
|
/**
|
|
4000
|
-
* Assert that the provided value is
|
|
4246
|
+
* Assert that the provided value is true.
|
|
4001
4247
|
* @param value The value to check.
|
|
4248
|
+
* @param expression The name of the expression that produced the value.
|
|
4249
|
+
* @param message An additional message that will be included with the error.
|
|
4002
4250
|
*/
|
|
4003
|
-
|
|
4004
|
-
|
|
4251
|
+
static assertTrue(value, expression, message) {
|
|
4252
|
+
return _PostCondition.getCondition().assertTrue(value, expression, message);
|
|
4005
4253
|
}
|
|
4006
4254
|
/**
|
|
4007
4255
|
* Assert that the provided value is false.
|
|
4008
4256
|
* @param value The value to check.
|
|
4257
|
+
* @param expression The name of the expression that produced the value.
|
|
4258
|
+
* @param message An additional message that will be included with the error.
|
|
4009
4259
|
*/
|
|
4010
|
-
static assertFalse(
|
|
4011
|
-
|
|
4012
|
-
test2.assertSame(value, false);
|
|
4260
|
+
static assertFalse(value, expression, message) {
|
|
4261
|
+
return _PostCondition.getCondition().assertFalse(value, expression, message);
|
|
4013
4262
|
}
|
|
4014
4263
|
/**
|
|
4015
|
-
* Assert that the provided value is
|
|
4016
|
-
* @param
|
|
4264
|
+
* Assert that the provided actual value is the same as the provided expected value.
|
|
4265
|
+
* @param expected The expected value.
|
|
4266
|
+
* @param actual The actual value.
|
|
4267
|
+
* @param expression The expression that produced the actual value.
|
|
4268
|
+
* @param message An optional message that describes the scenario.
|
|
4017
4269
|
*/
|
|
4018
|
-
|
|
4019
|
-
|
|
4270
|
+
static assertSame(expected, actual, expression, message) {
|
|
4271
|
+
return _PostCondition.getCondition().assertSame(expected, actual, expression, message);
|
|
4020
4272
|
}
|
|
4021
4273
|
/**
|
|
4022
|
-
* Assert that the provided value is
|
|
4023
|
-
* @param
|
|
4274
|
+
* Assert that the provided actual value is not the same as the provided expected value.
|
|
4275
|
+
* @param expected The expected value.
|
|
4276
|
+
* @param actual The actual value.
|
|
4277
|
+
* @param expression The expression that produced the actual value.
|
|
4278
|
+
* @param message An optional message that describes the scenario.
|
|
4024
4279
|
*/
|
|
4025
|
-
static
|
|
4026
|
-
|
|
4027
|
-
test2.assertSame(value, true);
|
|
4028
|
-
}
|
|
4029
|
-
/**
|
|
4030
|
-
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
4031
|
-
* @param value The value to check.
|
|
4032
|
-
* @param type The {@link Type} to check.
|
|
4033
|
-
* @param expression The expression that produced the value.
|
|
4034
|
-
* @param message An optional error message.
|
|
4035
|
-
*/
|
|
4036
|
-
assertInstanceOf(value, type, typeCheck) {
|
|
4037
|
-
return _Test.assertInstanceOf(this, value, type, typeCheck);
|
|
4038
|
-
}
|
|
4039
|
-
/**
|
|
4040
|
-
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
4041
|
-
* @param value The value to check.
|
|
4042
|
-
* @param type The {@link Type} to check.
|
|
4043
|
-
* @param expression The expression that produced the value.
|
|
4044
|
-
* @param message An optional error message.
|
|
4045
|
-
*/
|
|
4046
|
-
static assertInstanceOf(test2, value, type, typeCheck) {
|
|
4047
|
-
PreCondition.assertNotUndefinedAndNotNull(type, "type");
|
|
4048
|
-
if (isUndefinedOrNull(typeCheck)) {
|
|
4049
|
-
typeCheck = ((value2) => value2 instanceof type);
|
|
4050
|
-
}
|
|
4051
|
-
if (!typeCheck(value)) {
|
|
4052
|
-
test2.fail(`Expected value to be of type ${type.name} but found ${value} instead.`);
|
|
4053
|
-
}
|
|
4054
|
-
}
|
|
4055
|
-
};
|
|
4056
|
-
|
|
4057
|
-
// tests/assertTest.ts
|
|
4058
|
-
var AssertTest = class _AssertTest {
|
|
4059
|
-
name;
|
|
4060
|
-
constructor(name) {
|
|
4061
|
-
this.name = name;
|
|
4062
|
-
}
|
|
4063
|
-
/**
|
|
4064
|
-
* Create a new {@link AssertTest} object.
|
|
4065
|
-
*/
|
|
4066
|
-
static create(name) {
|
|
4067
|
-
return new _AssertTest(name);
|
|
4068
|
-
}
|
|
4069
|
-
fail(message) {
|
|
4070
|
-
PreCondition.assertNotEmpty(message, "message");
|
|
4071
|
-
assert.fail(message);
|
|
4072
|
-
}
|
|
4073
|
-
assertUndefined(value) {
|
|
4074
|
-
Test.assertUndefined(this, value);
|
|
4075
|
-
}
|
|
4076
|
-
assertNotUndefined(value) {
|
|
4077
|
-
Test.assertNotUndefined(this, value);
|
|
4078
|
-
}
|
|
4079
|
-
assertNull(value) {
|
|
4080
|
-
Test.assertNull(this, value);
|
|
4081
|
-
}
|
|
4082
|
-
assertNotNull(value) {
|
|
4083
|
-
Test.assertNotNull(this, value);
|
|
4084
|
-
}
|
|
4085
|
-
assertNotUndefinedAndNotNull(value) {
|
|
4086
|
-
Test.assertNotUndefinedAndNotNull(this, value);
|
|
4087
|
-
}
|
|
4088
|
-
assertSame(left, right) {
|
|
4089
|
-
assert.strictEqual(left, right);
|
|
4090
|
-
}
|
|
4091
|
-
assertNotSame(left, right) {
|
|
4092
|
-
assert.notStrictEqual(left, right);
|
|
4093
|
-
}
|
|
4094
|
-
assertEqual(left, right, message) {
|
|
4095
|
-
assert.deepStrictEqual(left, right, message);
|
|
4096
|
-
}
|
|
4097
|
-
assertNotEqual(left, right) {
|
|
4098
|
-
assert.notDeepStrictEqual(left, right);
|
|
4099
|
-
}
|
|
4100
|
-
assertFalse(value) {
|
|
4101
|
-
Test.assertFalse(this, value);
|
|
4102
|
-
}
|
|
4103
|
-
assertTrue(value) {
|
|
4104
|
-
Test.assertTrue(this, value);
|
|
4105
|
-
}
|
|
4106
|
-
assertThrows(action, expectedError) {
|
|
4107
|
-
if (!isFunction(action)) {
|
|
4108
|
-
const syncResult = action;
|
|
4109
|
-
action = () => {
|
|
4110
|
-
syncResult.await();
|
|
4111
|
-
};
|
|
4112
|
-
}
|
|
4113
|
-
assert.throws(action, expectedError);
|
|
4114
|
-
}
|
|
4115
|
-
assertThrowsAsync(action, expectedError) {
|
|
4116
|
-
const promiseOrAsyncAction = isFunction(action) ? async () => await action() : action;
|
|
4117
|
-
return PromiseAsyncResult.create(assert.rejects(promiseOrAsyncAction, expectedError));
|
|
4118
|
-
}
|
|
4119
|
-
assertInstanceOf(value, type, typeCheck) {
|
|
4120
|
-
Test.assertInstanceOf(this, value, type, typeCheck);
|
|
4121
|
-
}
|
|
4122
|
-
};
|
|
4123
|
-
|
|
4124
|
-
// tests/assertTestTests.ts
|
|
4125
|
-
var import_assert = require("assert");
|
|
4126
|
-
function test(runner) {
|
|
4127
|
-
runner.testFile("assertTest.ts", () => {
|
|
4128
|
-
runner.testType("AssertTest", () => {
|
|
4129
|
-
runner.testFunction("assertThrows()", () => {
|
|
4130
|
-
runner.test("with throwing action", (test2) => {
|
|
4131
|
-
const at = AssertTest.create("fake-test-name");
|
|
4132
|
-
at.assertThrows(() => {
|
|
4133
|
-
throw new Error("abc");
|
|
4134
|
-
}, new Error("abc"));
|
|
4135
|
-
});
|
|
4136
|
-
runner.test("with non-throwing action", (test2) => {
|
|
4137
|
-
const at = AssertTest.create("fake-test-name");
|
|
4138
|
-
test2.assertThrows(
|
|
4139
|
-
() => at.assertThrows(() => {
|
|
4140
|
-
}, new Error("oops")),
|
|
4141
|
-
new import_assert.AssertionError({
|
|
4142
|
-
message: "Missing expected exception (Error).",
|
|
4143
|
-
operator: "throws",
|
|
4144
|
-
expected: new Error("oops")
|
|
4145
|
-
})
|
|
4146
|
-
);
|
|
4147
|
-
});
|
|
4148
|
-
});
|
|
4149
|
-
runner.testFunction("assertThrowsAsync()", () => {
|
|
4150
|
-
runner.test("with throwing sync action", async (test2) => {
|
|
4151
|
-
const at = AssertTest.create("fake-test-name");
|
|
4152
|
-
await at.assertThrowsAsync(() => {
|
|
4153
|
-
throw new Error("abc");
|
|
4154
|
-
}, new Error("abc"));
|
|
4155
|
-
});
|
|
4156
|
-
runner.test("with throwing async action", async (test2) => {
|
|
4157
|
-
const at = AssertTest.create("fake-test-name");
|
|
4158
|
-
await at.assertThrowsAsync(async () => {
|
|
4159
|
-
throw new Error("abc");
|
|
4160
|
-
}, new Error("abc"));
|
|
4161
|
-
});
|
|
4162
|
-
runner.test("with rejected Promise", async (test2) => {
|
|
4163
|
-
const at = AssertTest.create("fake-test-name");
|
|
4164
|
-
await at.assertThrowsAsync(Promise.reject(new Error("abc")), new Error("abc"));
|
|
4165
|
-
});
|
|
4166
|
-
runner.test("with throwing action that returns a rejected Promise", async (test2) => {
|
|
4167
|
-
const at = AssertTest.create("fake-test-name");
|
|
4168
|
-
await at.assertThrowsAsync(() => Promise.reject(new Error("abc")), new Error("abc"));
|
|
4169
|
-
});
|
|
4170
|
-
runner.test("with non-throwing async action", async (test2) => {
|
|
4171
|
-
const at = AssertTest.create("fake-test-name");
|
|
4172
|
-
await test2.assertThrowsAsync(
|
|
4173
|
-
async () => await at.assertThrowsAsync(async () => {
|
|
4174
|
-
}, new Error("oops")),
|
|
4175
|
-
new import_assert.AssertionError({
|
|
4176
|
-
message: "Missing expected rejection (Error).",
|
|
4177
|
-
operator: "rejects",
|
|
4178
|
-
expected: new Error("oops")
|
|
4179
|
-
})
|
|
4180
|
-
);
|
|
4181
|
-
});
|
|
4182
|
-
});
|
|
4183
|
-
});
|
|
4184
|
-
});
|
|
4185
|
-
}
|
|
4186
|
-
|
|
4187
|
-
// tests/basicTestSkip.ts
|
|
4188
|
-
var BasicTestSkip = class _BasicTestSkip {
|
|
4189
|
-
shouldSkip;
|
|
4190
|
-
message;
|
|
4191
|
-
constructor(shouldSkip, message) {
|
|
4192
|
-
PreCondition.assertNotUndefinedAndNotNull(message, "message");
|
|
4193
|
-
this.shouldSkip = shouldSkip;
|
|
4194
|
-
this.message = message;
|
|
4195
|
-
}
|
|
4196
|
-
/**
|
|
4197
|
-
* Create a new {@link TestSkip} with the provided properties.
|
|
4198
|
-
* @param shouldSkip Whether the tests associated with the new {@link TestSkip}
|
|
4199
|
-
* should be skipped.
|
|
4200
|
-
* @param message The message that explains why the tests associated with this {@link TestSkip}
|
|
4201
|
-
* should be skipped.
|
|
4202
|
-
*/
|
|
4203
|
-
static create(shouldSkip, message) {
|
|
4204
|
-
if (shouldSkip === void 0 || shouldSkip === null) {
|
|
4205
|
-
shouldSkip = true;
|
|
4206
|
-
}
|
|
4207
|
-
if (message === void 0 || message === null) {
|
|
4208
|
-
message = "";
|
|
4209
|
-
}
|
|
4210
|
-
return new _BasicTestSkip(shouldSkip, message);
|
|
4211
|
-
}
|
|
4212
|
-
getShouldSkip() {
|
|
4213
|
-
return this.shouldSkip;
|
|
4214
|
-
}
|
|
4215
|
-
getMessage() {
|
|
4216
|
-
return this.message;
|
|
4217
|
-
}
|
|
4218
|
-
};
|
|
4219
|
-
|
|
4220
|
-
// sources/commandLineParameters.ts
|
|
4221
|
-
var CommandLineParameters = class _CommandLineParameters {
|
|
4222
|
-
args;
|
|
4223
|
-
constructor(argv) {
|
|
4224
|
-
this.args = argv;
|
|
4225
|
-
}
|
|
4226
|
-
static create(args) {
|
|
4227
|
-
return new _CommandLineParameters(args);
|
|
4228
|
-
}
|
|
4229
|
-
};
|
|
4230
|
-
|
|
4231
|
-
// sources/postConditionError.ts
|
|
4232
|
-
var PostConditionError = class extends Error {
|
|
4233
|
-
constructor(...message) {
|
|
4234
|
-
super(join("\n", message));
|
|
4235
|
-
}
|
|
4236
|
-
};
|
|
4237
|
-
|
|
4238
|
-
// sources/postCondition.ts
|
|
4239
|
-
var PostCondition = class _PostCondition {
|
|
4240
|
-
static condition;
|
|
4241
|
-
static getCondition() {
|
|
4242
|
-
if (_PostCondition.condition === void 0) {
|
|
4243
|
-
_PostCondition.condition = MutableCondition.create().setCreateErrorFunction((message) => {
|
|
4244
|
-
return new PostConditionError(message);
|
|
4245
|
-
});
|
|
4246
|
-
}
|
|
4247
|
-
return _PostCondition.condition;
|
|
4248
|
-
}
|
|
4249
|
-
/**
|
|
4250
|
-
* Assert that the provided value is undefined.
|
|
4251
|
-
* @param value The value to check.
|
|
4252
|
-
* @param expression The name of the expression that produced the value.
|
|
4253
|
-
* @param message An additional message that will be included with the error.
|
|
4254
|
-
*/
|
|
4255
|
-
static assertUndefined(value, expression, message) {
|
|
4256
|
-
return _PostCondition.getCondition().assertUndefined(value, expression, message);
|
|
4257
|
-
}
|
|
4258
|
-
/**
|
|
4259
|
-
* Assert that the provided value is not undefined and not null.
|
|
4260
|
-
* @param value The value to check.
|
|
4261
|
-
* @param expression The name of the expression that produced the value.
|
|
4262
|
-
* @param message An additional message that will be included with the error.
|
|
4263
|
-
*/
|
|
4264
|
-
static assertNotUndefined(value, expression, message) {
|
|
4265
|
-
return _PostCondition.getCondition().assertNotUndefined(value, expression, message);
|
|
4266
|
-
}
|
|
4267
|
-
/**
|
|
4268
|
-
* Assert that the provided value is not undefined and not null.
|
|
4269
|
-
* @param value The value to check.
|
|
4270
|
-
* @param expression The name of the expression that produced the value.
|
|
4271
|
-
* @param message An additional message that will be included with the error.
|
|
4272
|
-
*/
|
|
4273
|
-
static assertNotUndefinedAndNotNull(value, expression, message) {
|
|
4274
|
-
return _PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
|
|
4275
|
-
}
|
|
4276
|
-
/**
|
|
4277
|
-
* Assert that the provided value is true.
|
|
4278
|
-
* @param value The value to check.
|
|
4279
|
-
* @param expression The name of the expression that produced the value.
|
|
4280
|
-
* @param message An additional message that will be included with the error.
|
|
4281
|
-
*/
|
|
4282
|
-
static assertTrue(value, expression, message) {
|
|
4283
|
-
return _PostCondition.getCondition().assertTrue(value, expression, message);
|
|
4284
|
-
}
|
|
4285
|
-
/**
|
|
4286
|
-
* Assert that the provided value is false.
|
|
4287
|
-
* @param value The value to check.
|
|
4288
|
-
* @param expression The name of the expression that produced the value.
|
|
4289
|
-
* @param message An additional message that will be included with the error.
|
|
4290
|
-
*/
|
|
4291
|
-
static assertFalse(value, expression, message) {
|
|
4292
|
-
return _PostCondition.getCondition().assertFalse(value, expression, message);
|
|
4293
|
-
}
|
|
4294
|
-
/**
|
|
4295
|
-
* Assert that the provided actual value is the same as the provided expected value.
|
|
4296
|
-
* @param expected The expected value.
|
|
4297
|
-
* @param actual The actual value.
|
|
4298
|
-
* @param expression The expression that produced the actual value.
|
|
4299
|
-
* @param message An optional message that describes the scenario.
|
|
4300
|
-
*/
|
|
4301
|
-
static assertSame(expected, actual, expression, message) {
|
|
4302
|
-
return _PostCondition.getCondition().assertSame(expected, actual, expression, message);
|
|
4303
|
-
}
|
|
4304
|
-
/**
|
|
4305
|
-
* Assert that the provided actual value is not the same as the provided expected value.
|
|
4306
|
-
* @param expected The expected value.
|
|
4307
|
-
* @param actual The actual value.
|
|
4308
|
-
* @param expression The expression that produced the actual value.
|
|
4309
|
-
* @param message An optional message that describes the scenario.
|
|
4310
|
-
*/
|
|
4311
|
-
static assertNotSame(expected, actual, expression, message) {
|
|
4312
|
-
return _PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
|
|
4280
|
+
static assertNotSame(expected, actual, expression, message) {
|
|
4281
|
+
return _PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
|
|
4313
4282
|
}
|
|
4314
4283
|
/**
|
|
4315
4284
|
* Assert that the provided actual value is equal to the provided expected value.
|
|
@@ -4465,17 +4434,280 @@ var CharacterWriteStream = class _CharacterWriteStream {
|
|
|
4465
4434
|
writeLine(text) {
|
|
4466
4435
|
return _CharacterWriteStream.writeLine(this, text);
|
|
4467
4436
|
}
|
|
4468
|
-
static writeLine(writeStream, text) {
|
|
4469
|
-
PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
|
|
4470
|
-
return PromiseAsyncResult.create(async () => {
|
|
4471
|
-
let result = 0;
|
|
4472
|
-
if (text) {
|
|
4473
|
-
result += await writeStream.writeString(text);
|
|
4474
|
-
}
|
|
4475
|
-
result += await writeStream.writeString("\n");
|
|
4476
|
-
PostCondition.assertGreaterThan(result, 0, "result");
|
|
4477
|
-
return result;
|
|
4478
|
-
});
|
|
4437
|
+
static writeLine(writeStream, text) {
|
|
4438
|
+
PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
|
|
4439
|
+
return PromiseAsyncResult.create(async () => {
|
|
4440
|
+
let result = 0;
|
|
4441
|
+
if (text) {
|
|
4442
|
+
result += await writeStream.writeString(text);
|
|
4443
|
+
}
|
|
4444
|
+
result += await writeStream.writeString("\n");
|
|
4445
|
+
PostCondition.assertGreaterThan(result, 0, "result");
|
|
4446
|
+
return result;
|
|
4447
|
+
});
|
|
4448
|
+
}
|
|
4449
|
+
};
|
|
4450
|
+
|
|
4451
|
+
// sources/IndentedCharacterWriteStream.ts
|
|
4452
|
+
var IndentedCharacterWriteStream = class _IndentedCharacterWriteStream extends CharacterWriteStream {
|
|
4453
|
+
innerStream;
|
|
4454
|
+
currentIndentationList;
|
|
4455
|
+
currentIndentation;
|
|
4456
|
+
singleIndent;
|
|
4457
|
+
atLineStart;
|
|
4458
|
+
constructor(innerStream) {
|
|
4459
|
+
PreCondition.assertNotUndefinedAndNotNull(innerStream, "innerStream");
|
|
4460
|
+
super();
|
|
4461
|
+
this.innerStream = innerStream;
|
|
4462
|
+
this.currentIndentationList = List.create();
|
|
4463
|
+
this.currentIndentation = "";
|
|
4464
|
+
this.singleIndent = " ";
|
|
4465
|
+
this.atLineStart = true;
|
|
4466
|
+
}
|
|
4467
|
+
static create(innerStream) {
|
|
4468
|
+
return new _IndentedCharacterWriteStream(innerStream);
|
|
4469
|
+
}
|
|
4470
|
+
getSingleIndent() {
|
|
4471
|
+
return this.singleIndent;
|
|
4472
|
+
}
|
|
4473
|
+
setSingleIndent(singleIndent) {
|
|
4474
|
+
PreCondition.assertNotUndefinedAndNotNull(singleIndent, "singleIndent");
|
|
4475
|
+
this.singleIndent = singleIndent;
|
|
4476
|
+
return this;
|
|
4477
|
+
}
|
|
4478
|
+
getCurrentIndentationCount() {
|
|
4479
|
+
return this.currentIndentationList.getCount().await();
|
|
4480
|
+
}
|
|
4481
|
+
getCurrentIndentation() {
|
|
4482
|
+
return this.currentIndentation;
|
|
4483
|
+
}
|
|
4484
|
+
addIndentation(singleIndent) {
|
|
4485
|
+
if (isUndefinedOrNull(singleIndent)) {
|
|
4486
|
+
singleIndent = this.singleIndent;
|
|
4487
|
+
}
|
|
4488
|
+
this.currentIndentationList.add(singleIndent);
|
|
4489
|
+
if (singleIndent) {
|
|
4490
|
+
this.currentIndentation = this.currentIndentation + singleIndent;
|
|
4491
|
+
}
|
|
4492
|
+
return this;
|
|
4493
|
+
}
|
|
4494
|
+
removeIndentation() {
|
|
4495
|
+
PreCondition.assertGreaterThanOrEqualTo(this.getCurrentIndentationCount(), 1, "this.getCurrentIndentationCount()");
|
|
4496
|
+
const result = this.currentIndentationList.removeLast().await();
|
|
4497
|
+
if (result) {
|
|
4498
|
+
this.currentIndentation = this.currentIndentation.substring(0, this.currentIndentation.length - result.length);
|
|
4499
|
+
}
|
|
4500
|
+
return result;
|
|
4501
|
+
}
|
|
4502
|
+
indent(actionOrSingleIndent, action) {
|
|
4503
|
+
let singleIndent;
|
|
4504
|
+
if (isString(actionOrSingleIndent)) {
|
|
4505
|
+
singleIndent = actionOrSingleIndent;
|
|
4506
|
+
action = action;
|
|
4507
|
+
} else {
|
|
4508
|
+
action = actionOrSingleIndent;
|
|
4509
|
+
}
|
|
4510
|
+
PreCondition.assertNotUndefinedAndNotNull(action, "action");
|
|
4511
|
+
return AsyncResult.create(async () => {
|
|
4512
|
+
let result;
|
|
4513
|
+
this.addIndentation(singleIndent);
|
|
4514
|
+
try {
|
|
4515
|
+
result = await action();
|
|
4516
|
+
if (!isNumber(result)) {
|
|
4517
|
+
result = 0;
|
|
4518
|
+
}
|
|
4519
|
+
} finally {
|
|
4520
|
+
this.removeIndentation();
|
|
4521
|
+
}
|
|
4522
|
+
return result;
|
|
4523
|
+
});
|
|
4524
|
+
}
|
|
4525
|
+
writeString(text) {
|
|
4526
|
+
return AsyncResult.create(async () => {
|
|
4527
|
+
let result = 0;
|
|
4528
|
+
const textLength = text.length;
|
|
4529
|
+
let startIndex = 0;
|
|
4530
|
+
while (startIndex < textLength) {
|
|
4531
|
+
const newLineCharacterIndex = text.indexOf("\n", startIndex);
|
|
4532
|
+
const atLineStartAfterWrite = newLineCharacterIndex !== -1;
|
|
4533
|
+
const nextLineStartIndex = atLineStartAfterWrite ? newLineCharacterIndex + 1 : textLength;
|
|
4534
|
+
if (newLineCharacterIndex === startIndex || newLineCharacterIndex === startIndex + 1 && text[startIndex] === "\r") {
|
|
4535
|
+
result += await this.innerStream.writeString(text.substring(startIndex, nextLineStartIndex));
|
|
4536
|
+
startIndex = nextLineStartIndex;
|
|
4537
|
+
} else {
|
|
4538
|
+
if (this.atLineStart && this.currentIndentation) {
|
|
4539
|
+
result += await this.innerStream.writeString(this.currentIndentation);
|
|
4540
|
+
}
|
|
4541
|
+
result += await this.innerStream.writeString(text.substring(startIndex, nextLineStartIndex));
|
|
4542
|
+
startIndex = nextLineStartIndex;
|
|
4543
|
+
}
|
|
4544
|
+
this.atLineStart = atLineStartAfterWrite;
|
|
4545
|
+
}
|
|
4546
|
+
return result;
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
};
|
|
4550
|
+
|
|
4551
|
+
// sources/english.ts
|
|
4552
|
+
function andList(values) {
|
|
4553
|
+
return list("and", values);
|
|
4554
|
+
}
|
|
4555
|
+
function orList(values) {
|
|
4556
|
+
return list("or", values);
|
|
4557
|
+
}
|
|
4558
|
+
function list(conjunction, values) {
|
|
4559
|
+
PreCondition.assertNotEmpty(conjunction, "conjunction");
|
|
4560
|
+
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
4561
|
+
let result = "";
|
|
4562
|
+
let index = 0;
|
|
4563
|
+
const iterator = Iterator.create(values).start().await();
|
|
4564
|
+
while (iterator.hasCurrent()) {
|
|
4565
|
+
const currentValue = iterator.takeCurrent().await();
|
|
4566
|
+
if (index >= 1) {
|
|
4567
|
+
if (iterator.hasCurrent()) {
|
|
4568
|
+
result += `, `;
|
|
4569
|
+
} else {
|
|
4570
|
+
if (index >= 2) {
|
|
4571
|
+
result += `,`;
|
|
4572
|
+
}
|
|
4573
|
+
result += ` ${conjunction} `;
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
result += currentValue;
|
|
4577
|
+
index++;
|
|
4578
|
+
}
|
|
4579
|
+
return result;
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
// sources/commandLineParameters.ts
|
|
4583
|
+
var CommandLineParameters = class _CommandLineParameters {
|
|
4584
|
+
args;
|
|
4585
|
+
parameters;
|
|
4586
|
+
constructor(argv) {
|
|
4587
|
+
PreCondition.assertNotUndefinedAndNotNull(argv, "argv");
|
|
4588
|
+
this.args = isIterable(argv) ? argv : Iterable.create(argv);
|
|
4589
|
+
this.parameters = List.create();
|
|
4590
|
+
}
|
|
4591
|
+
static create(args) {
|
|
4592
|
+
return new _CommandLineParameters(args);
|
|
4593
|
+
}
|
|
4594
|
+
static getArgumentName(arg) {
|
|
4595
|
+
return arg[0] === "-" ? arg.substring(arg[1] === "-" ? 2 : 1) : void 0;
|
|
4596
|
+
}
|
|
4597
|
+
getArguments() {
|
|
4598
|
+
return this.args;
|
|
4599
|
+
}
|
|
4600
|
+
/**
|
|
4601
|
+
* Get the value of the first argument that matches one of the provided names.
|
|
4602
|
+
* @param names The possible names to look for.
|
|
4603
|
+
*/
|
|
4604
|
+
getNamedArgumentStringValue(nameOrNames) {
|
|
4605
|
+
PreCondition.assertNotEmpty(nameOrNames, "nameOrNames");
|
|
4606
|
+
return SyncResult.create(() => {
|
|
4607
|
+
let foundArgName = false;
|
|
4608
|
+
let result;
|
|
4609
|
+
if (isString(nameOrNames)) {
|
|
4610
|
+
nameOrNames = [nameOrNames];
|
|
4611
|
+
}
|
|
4612
|
+
const searchNames = Iterable.create(nameOrNames);
|
|
4613
|
+
for (const arg of this.args) {
|
|
4614
|
+
if (!foundArgName) {
|
|
4615
|
+
const argName = _CommandLineParameters.getArgumentName(arg);
|
|
4616
|
+
foundArgName = !!(argName && searchNames.contains(argName));
|
|
4617
|
+
} else {
|
|
4618
|
+
result = arg;
|
|
4619
|
+
break;
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
if (result === void 0) {
|
|
4623
|
+
const toStringFunctions = ToStringFunctions.create();
|
|
4624
|
+
throw new NotFoundError(`No argument found that matches ${orList(searchNames.map((n) => toStringFunctions.toString(n)))}.`);
|
|
4625
|
+
}
|
|
4626
|
+
return result;
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
4629
|
+
nameOrAliasExists(nameOrAlias) {
|
|
4630
|
+
PreCondition.assertNotEmpty(nameOrAlias, "nameOrAlias");
|
|
4631
|
+
let result = false;
|
|
4632
|
+
for (const parameter of this.parameters) {
|
|
4633
|
+
if (parameter.getNameAndAliases().contains(nameOrAlias).await()) {
|
|
4634
|
+
result = true;
|
|
4635
|
+
break;
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
return result;
|
|
4639
|
+
}
|
|
4640
|
+
add(name) {
|
|
4641
|
+
const result = CommandLineParameter.create({
|
|
4642
|
+
owner: this,
|
|
4643
|
+
name
|
|
4644
|
+
});
|
|
4645
|
+
this.parameters.add(result);
|
|
4646
|
+
return result;
|
|
4647
|
+
}
|
|
4648
|
+
};
|
|
4649
|
+
|
|
4650
|
+
// sources/commandLineParameter.ts
|
|
4651
|
+
var CommandLineParameter = class _CommandLineParameter {
|
|
4652
|
+
owner;
|
|
4653
|
+
name;
|
|
4654
|
+
aliases;
|
|
4655
|
+
description;
|
|
4656
|
+
constructor(owner, name) {
|
|
4657
|
+
PreCondition.assertNotUndefinedAndNotNull(owner, "owner");
|
|
4658
|
+
PreCondition.assertNotEmpty(name, "name");
|
|
4659
|
+
PreCondition.assertFalse(owner.nameOrAliasExists(name), "owner.nameOrAliasExists(name)");
|
|
4660
|
+
this.owner = owner;
|
|
4661
|
+
this.name = name;
|
|
4662
|
+
}
|
|
4663
|
+
static create(ownerOrProperties, name) {
|
|
4664
|
+
let owner;
|
|
4665
|
+
if (ownerOrProperties instanceof CommandLineParameters) {
|
|
4666
|
+
owner = ownerOrProperties;
|
|
4667
|
+
name = name;
|
|
4668
|
+
} else {
|
|
4669
|
+
owner = ownerOrProperties.owner;
|
|
4670
|
+
name = ownerOrProperties.name;
|
|
4671
|
+
}
|
|
4672
|
+
return new _CommandLineParameter(owner, name);
|
|
4673
|
+
}
|
|
4674
|
+
/**
|
|
4675
|
+
* Get the name of this {@link CommandLineParameter}.
|
|
4676
|
+
*/
|
|
4677
|
+
getName() {
|
|
4678
|
+
return this.name;
|
|
4679
|
+
}
|
|
4680
|
+
getAliases() {
|
|
4681
|
+
return this.aliases ?? Iterable.create();
|
|
4682
|
+
}
|
|
4683
|
+
nameOrAliasExists(nameOrAlias) {
|
|
4684
|
+
return this.owner.nameOrAliasExists(nameOrAlias);
|
|
4685
|
+
}
|
|
4686
|
+
addAlias(alias) {
|
|
4687
|
+
PreCondition.assertNotEmpty(alias, "alias");
|
|
4688
|
+
PreCondition.assertFalse(this.nameOrAliasExists(alias), "this.nameOrAliasExists(alias)");
|
|
4689
|
+
if (this.aliases === void 0) {
|
|
4690
|
+
this.aliases = List.create();
|
|
4691
|
+
}
|
|
4692
|
+
this.aliases.add(alias);
|
|
4693
|
+
return this;
|
|
4694
|
+
}
|
|
4695
|
+
addAliases(aliases) {
|
|
4696
|
+
for (const alias of aliases) {
|
|
4697
|
+
this.addAlias(alias);
|
|
4698
|
+
}
|
|
4699
|
+
return this;
|
|
4700
|
+
}
|
|
4701
|
+
getNameAndAliases() {
|
|
4702
|
+
return List.create().add(this.getName()).addAll(this.getAliases());
|
|
4703
|
+
}
|
|
4704
|
+
getDescription() {
|
|
4705
|
+
return this.description ?? "";
|
|
4706
|
+
}
|
|
4707
|
+
setDescription(description) {
|
|
4708
|
+
PreCondition.assertNotUndefinedAndNotNull(description, "description");
|
|
4709
|
+
this.description = description;
|
|
4710
|
+
return this;
|
|
4479
4711
|
}
|
|
4480
4712
|
};
|
|
4481
4713
|
|
|
@@ -4586,747 +4818,1112 @@ var MutableHttpHeaders = class _MutableHttpHeaders {
|
|
|
4586
4818
|
iterate() {
|
|
4587
4819
|
return this.headers.iterate();
|
|
4588
4820
|
}
|
|
4589
|
-
get(headerName) {
|
|
4821
|
+
get(headerName) {
|
|
4822
|
+
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4823
|
+
return SyncResult.create(() => {
|
|
4824
|
+
let result;
|
|
4825
|
+
const lowerHeaderName = headerName.toLowerCase();
|
|
4826
|
+
for (const header of this.headers) {
|
|
4827
|
+
if (header.getName().toLowerCase() === lowerHeaderName) {
|
|
4828
|
+
result = header;
|
|
4829
|
+
break;
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
if (result === void 0) {
|
|
4833
|
+
throw new NotFoundError(`No HttpHeader found with the name ${escapeAndQuote(headerName)}.`);
|
|
4834
|
+
}
|
|
4835
|
+
return result;
|
|
4836
|
+
});
|
|
4837
|
+
}
|
|
4838
|
+
getValue(headerName) {
|
|
4839
|
+
return this.get(headerName).then((header) => header.getValue());
|
|
4840
|
+
}
|
|
4841
|
+
set(headerOrHeaderName, headerValue) {
|
|
4842
|
+
let headerName;
|
|
4843
|
+
if (isString(headerOrHeaderName)) {
|
|
4844
|
+
headerName = headerOrHeaderName;
|
|
4845
|
+
} else {
|
|
4846
|
+
headerName = headerOrHeaderName.getName();
|
|
4847
|
+
headerValue = headerOrHeaderName.getValue();
|
|
4848
|
+
}
|
|
4849
|
+
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4850
|
+
PreCondition.assertNotUndefinedAndNotNull(headerValue, "headerValue");
|
|
4851
|
+
let insertIndex = 0;
|
|
4852
|
+
for (let insertIndex2 = 0; insertIndex2 < this.headers.getCount().await(); insertIndex2++) {
|
|
4853
|
+
const header = this.headers.get(insertIndex2).await();
|
|
4854
|
+
if (header.getName() === headerName) {
|
|
4855
|
+
this.headers.removeAt(insertIndex2);
|
|
4856
|
+
break;
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
this.headers.insert(insertIndex, HttpHeader.create(headerName, headerValue));
|
|
4860
|
+
return this;
|
|
4861
|
+
}
|
|
4862
|
+
setAll(headers) {
|
|
4863
|
+
PreCondition.assertNotUndefinedAndNotNull(headers, "headers");
|
|
4864
|
+
for (const header of headers) {
|
|
4865
|
+
this.set(header);
|
|
4866
|
+
}
|
|
4867
|
+
return this;
|
|
4868
|
+
}
|
|
4869
|
+
setContentType(contentType) {
|
|
4870
|
+
return this.set(HttpHeaders.contentTypeHeaderName, contentType);
|
|
4871
|
+
}
|
|
4872
|
+
getContentType() {
|
|
4873
|
+
return this.get(HttpHeaders.contentTypeHeaderName);
|
|
4874
|
+
}
|
|
4875
|
+
getContentTypeValue() {
|
|
4876
|
+
return this.getValue(HttpHeaders.contentTypeHeaderName);
|
|
4877
|
+
}
|
|
4878
|
+
getCount() {
|
|
4879
|
+
return this.headers.getCount();
|
|
4880
|
+
}
|
|
4881
|
+
toArray() {
|
|
4882
|
+
return HttpHeaders.toArray(this);
|
|
4883
|
+
}
|
|
4884
|
+
any() {
|
|
4885
|
+
return HttpHeaders.any(this);
|
|
4886
|
+
}
|
|
4887
|
+
equals(right, equalFunctions) {
|
|
4888
|
+
return HttpHeaders.equals(this, right, equalFunctions);
|
|
4889
|
+
}
|
|
4890
|
+
toString(toStringFunctions) {
|
|
4891
|
+
return HttpHeaders.toString(this, toStringFunctions);
|
|
4892
|
+
}
|
|
4893
|
+
concatenate(...toConcatenate) {
|
|
4894
|
+
return HttpHeaders.concatenate(this, ...toConcatenate);
|
|
4895
|
+
}
|
|
4896
|
+
map(mapping) {
|
|
4897
|
+
return HttpHeaders.map(this, mapping);
|
|
4898
|
+
}
|
|
4899
|
+
flatMap(mapping) {
|
|
4900
|
+
return HttpHeaders.flatMap(this, mapping);
|
|
4901
|
+
}
|
|
4902
|
+
where(condition) {
|
|
4903
|
+
return HttpHeaders.where(this, condition);
|
|
4904
|
+
}
|
|
4905
|
+
instanceOf(typeOrTypeCheck) {
|
|
4906
|
+
return HttpHeaders.instanceOf(this, typeOrTypeCheck);
|
|
4907
|
+
}
|
|
4908
|
+
first(condition) {
|
|
4909
|
+
return HttpHeaders.first(this, condition);
|
|
4910
|
+
}
|
|
4911
|
+
last(condition) {
|
|
4912
|
+
return HttpHeaders.last(this, condition);
|
|
4913
|
+
}
|
|
4914
|
+
[Symbol.iterator]() {
|
|
4915
|
+
return HttpHeaders[Symbol.iterator](this);
|
|
4916
|
+
}
|
|
4917
|
+
contains(value, equalFunctions) {
|
|
4918
|
+
return HttpHeaders.contains(this, value, equalFunctions);
|
|
4919
|
+
}
|
|
4920
|
+
};
|
|
4921
|
+
|
|
4922
|
+
// sources/httpHeaders.ts
|
|
4923
|
+
var HttpHeaders = class _HttpHeaders {
|
|
4924
|
+
static contentTypeHeaderName = "Content-Type";
|
|
4925
|
+
static create(headers) {
|
|
4926
|
+
return MutableHttpHeaders.create(headers);
|
|
4927
|
+
}
|
|
4928
|
+
getContentType() {
|
|
4929
|
+
return _HttpHeaders.getContentType(this);
|
|
4930
|
+
}
|
|
4931
|
+
static getContentType(headers) {
|
|
4932
|
+
return headers.get(_HttpHeaders.contentTypeHeaderName);
|
|
4933
|
+
}
|
|
4934
|
+
getContentTypeValue() {
|
|
4935
|
+
return _HttpHeaders.getContentTypeValue(this);
|
|
4936
|
+
}
|
|
4937
|
+
static getContentTypeValue(headers) {
|
|
4938
|
+
return headers.getValue(_HttpHeaders.contentTypeHeaderName);
|
|
4939
|
+
}
|
|
4940
|
+
/**
|
|
4941
|
+
* Get the {@link HttpHeader}s in this {@link HttpHeaders} object as an array.
|
|
4942
|
+
*/
|
|
4943
|
+
toArray() {
|
|
4944
|
+
return _HttpHeaders.toArray(this);
|
|
4945
|
+
}
|
|
4946
|
+
static toArray(headers) {
|
|
4947
|
+
return Iterable.toArray(headers);
|
|
4948
|
+
}
|
|
4949
|
+
any() {
|
|
4950
|
+
return _HttpHeaders.any(this);
|
|
4951
|
+
}
|
|
4952
|
+
static any(headers) {
|
|
4953
|
+
return Iterable.any(headers);
|
|
4954
|
+
}
|
|
4955
|
+
getCount() {
|
|
4956
|
+
return _HttpHeaders.getCount(this);
|
|
4957
|
+
}
|
|
4958
|
+
static getCount(headers) {
|
|
4959
|
+
return Iterable.getCount(headers);
|
|
4960
|
+
}
|
|
4961
|
+
equals(right, equalFunctions) {
|
|
4962
|
+
return _HttpHeaders.equals(this, right, equalFunctions);
|
|
4963
|
+
}
|
|
4964
|
+
static equals(headers, right, equalFunctions) {
|
|
4965
|
+
return Iterable.equals(headers, right, equalFunctions);
|
|
4966
|
+
}
|
|
4967
|
+
toString(toStringFunctions) {
|
|
4968
|
+
return _HttpHeaders.toString(this, toStringFunctions);
|
|
4969
|
+
}
|
|
4970
|
+
static toString(headers, toStringFunctions) {
|
|
4971
|
+
return Iterable.toString(headers, toStringFunctions);
|
|
4972
|
+
}
|
|
4973
|
+
concatenate(...toConcatenate) {
|
|
4974
|
+
return _HttpHeaders.concatenate(this, ...toConcatenate);
|
|
4975
|
+
}
|
|
4976
|
+
static concatenate(headers, ...toConcatenate) {
|
|
4977
|
+
return Iterable.concatenate(headers, ...toConcatenate);
|
|
4978
|
+
}
|
|
4979
|
+
map(mapping) {
|
|
4980
|
+
return _HttpHeaders.map(this, mapping);
|
|
4981
|
+
}
|
|
4982
|
+
static map(headers, mapping) {
|
|
4983
|
+
return Iterable.map(headers, mapping);
|
|
4984
|
+
}
|
|
4985
|
+
flatMap(mapping) {
|
|
4986
|
+
return _HttpHeaders.flatMap(this, mapping);
|
|
4987
|
+
}
|
|
4988
|
+
static flatMap(headers, mapping) {
|
|
4989
|
+
return Iterable.flatMap(headers, mapping);
|
|
4990
|
+
}
|
|
4991
|
+
where(condition) {
|
|
4992
|
+
return _HttpHeaders.where(this, condition);
|
|
4993
|
+
}
|
|
4994
|
+
static where(headers, condition) {
|
|
4995
|
+
return Iterable.where(headers, condition);
|
|
4996
|
+
}
|
|
4997
|
+
instanceOf(typeOrTypeCheck) {
|
|
4998
|
+
return _HttpHeaders.instanceOf(this, typeOrTypeCheck);
|
|
4999
|
+
}
|
|
5000
|
+
static instanceOf(headers, typeOrTypeCheck) {
|
|
5001
|
+
return Iterable.instanceOf(headers, typeOrTypeCheck);
|
|
5002
|
+
}
|
|
5003
|
+
first(condition) {
|
|
5004
|
+
return _HttpHeaders.first(this, condition);
|
|
5005
|
+
}
|
|
5006
|
+
static first(headers, condition) {
|
|
5007
|
+
return Iterable.first(headers, condition);
|
|
5008
|
+
}
|
|
5009
|
+
last(condition) {
|
|
5010
|
+
return _HttpHeaders.last(this, condition);
|
|
5011
|
+
}
|
|
5012
|
+
static last(headers, condition) {
|
|
5013
|
+
return Iterable.last(headers, condition);
|
|
5014
|
+
}
|
|
5015
|
+
[Symbol.iterator]() {
|
|
5016
|
+
return _HttpHeaders[Symbol.iterator](this);
|
|
5017
|
+
}
|
|
5018
|
+
static [Symbol.iterator](headers) {
|
|
5019
|
+
return Iterable[Symbol.iterator](headers);
|
|
5020
|
+
}
|
|
5021
|
+
contains(value, equalFunctions) {
|
|
5022
|
+
return _HttpHeaders.contains(this, value, equalFunctions);
|
|
5023
|
+
}
|
|
5024
|
+
static contains(headers, value, equalFunctions) {
|
|
5025
|
+
return SyncResult.create(() => {
|
|
5026
|
+
if (!equalFunctions) {
|
|
5027
|
+
equalFunctions = EqualFunctions.create();
|
|
5028
|
+
}
|
|
5029
|
+
return headers.getValue(value.getName()).then((headerValue) => equalFunctions.areEqual(headerValue, value.getValue()).await()).catch(NotFoundError, () => false).await();
|
|
5030
|
+
});
|
|
5031
|
+
}
|
|
5032
|
+
};
|
|
5033
|
+
|
|
5034
|
+
// sources/httpIncomingResponse.ts
|
|
5035
|
+
var HttpIncomingResponse = class {
|
|
5036
|
+
};
|
|
5037
|
+
|
|
5038
|
+
// sources/fetchHttpResponse.ts
|
|
5039
|
+
var FetchHttpIncomingResponse = class _FetchHttpIncomingResponse extends HttpIncomingResponse {
|
|
5040
|
+
response;
|
|
5041
|
+
constructor(response) {
|
|
5042
|
+
PreCondition.assertNotUndefinedAndNotNull(response, "response");
|
|
5043
|
+
super();
|
|
5044
|
+
this.response = response;
|
|
5045
|
+
}
|
|
5046
|
+
static create(response) {
|
|
5047
|
+
return new _FetchHttpIncomingResponse(response);
|
|
5048
|
+
}
|
|
5049
|
+
getStatusCode() {
|
|
5050
|
+
return this.response.status;
|
|
5051
|
+
}
|
|
5052
|
+
getHeaders() {
|
|
5053
|
+
return SyncResult.create(() => {
|
|
5054
|
+
const result = HttpHeaders.create();
|
|
5055
|
+
for (const header of this.response.headers) {
|
|
5056
|
+
result.set(header[0], header[1]);
|
|
5057
|
+
}
|
|
5058
|
+
return result;
|
|
5059
|
+
});
|
|
5060
|
+
}
|
|
5061
|
+
getHeader(headerName) {
|
|
4590
5062
|
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4591
5063
|
return SyncResult.create(() => {
|
|
4592
5064
|
let result;
|
|
4593
5065
|
const lowerHeaderName = headerName.toLowerCase();
|
|
4594
|
-
for (const header of this.headers) {
|
|
4595
|
-
if (header.
|
|
4596
|
-
result = header;
|
|
5066
|
+
for (const header of this.response.headers) {
|
|
5067
|
+
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
5068
|
+
result = HttpHeader.create(header[0], header[1]);
|
|
4597
5069
|
break;
|
|
4598
5070
|
}
|
|
4599
5071
|
}
|
|
4600
5072
|
if (result === void 0) {
|
|
4601
|
-
throw new NotFoundError(`
|
|
5073
|
+
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
4602
5074
|
}
|
|
4603
5075
|
return result;
|
|
4604
5076
|
});
|
|
4605
5077
|
}
|
|
4606
|
-
|
|
4607
|
-
return this.get(headerName).then((header) => header.getValue());
|
|
4608
|
-
}
|
|
4609
|
-
set(headerOrHeaderName, headerValue) {
|
|
4610
|
-
let headerName;
|
|
4611
|
-
if (isString(headerOrHeaderName)) {
|
|
4612
|
-
headerName = headerOrHeaderName;
|
|
4613
|
-
} else {
|
|
4614
|
-
headerName = headerOrHeaderName.getName();
|
|
4615
|
-
headerValue = headerOrHeaderName.getValue();
|
|
4616
|
-
}
|
|
5078
|
+
getHeaderValue(headerName) {
|
|
4617
5079
|
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
const header
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
5080
|
+
return SyncResult.create(() => {
|
|
5081
|
+
let result;
|
|
5082
|
+
const lowerHeaderName = headerName.toLowerCase();
|
|
5083
|
+
for (const header of this.response.headers) {
|
|
5084
|
+
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
5085
|
+
result = header[1];
|
|
5086
|
+
break;
|
|
5087
|
+
}
|
|
4625
5088
|
}
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
5089
|
+
if (result === void 0) {
|
|
5090
|
+
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
5091
|
+
}
|
|
5092
|
+
return result;
|
|
5093
|
+
});
|
|
4629
5094
|
}
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
for (const header of headers) {
|
|
4633
|
-
this.set(header);
|
|
4634
|
-
}
|
|
4635
|
-
return this;
|
|
5095
|
+
getBody() {
|
|
5096
|
+
return PromiseAsyncResult.create(this.response.text());
|
|
4636
5097
|
}
|
|
4637
|
-
|
|
4638
|
-
|
|
5098
|
+
};
|
|
5099
|
+
|
|
5100
|
+
// sources/httpOutgoingRequest.ts
|
|
5101
|
+
var HttpOutgoingRequest = class _HttpOutgoingRequest {
|
|
5102
|
+
method;
|
|
5103
|
+
url;
|
|
5104
|
+
headers;
|
|
5105
|
+
body;
|
|
5106
|
+
constructor(method, url) {
|
|
5107
|
+
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
5108
|
+
PreCondition.assertNotEmpty(url, "url");
|
|
5109
|
+
this.method = method;
|
|
5110
|
+
this.url = url;
|
|
5111
|
+
this.headers = HttpHeaders.create();
|
|
5112
|
+
this.body = "";
|
|
4639
5113
|
}
|
|
4640
|
-
|
|
4641
|
-
return
|
|
5114
|
+
static create(method, url) {
|
|
5115
|
+
return new _HttpOutgoingRequest(method, url);
|
|
4642
5116
|
}
|
|
4643
|
-
|
|
4644
|
-
|
|
5117
|
+
/**
|
|
5118
|
+
* Create a new {@link HttpOutgoingRequest} with a GET {@link HttpMethod}.
|
|
5119
|
+
* @param url The target URL for the {@link HttpOutgoingRequest}.
|
|
5120
|
+
*/
|
|
5121
|
+
static get(url) {
|
|
5122
|
+
return _HttpOutgoingRequest.create(0 /* GET */, url);
|
|
4645
5123
|
}
|
|
4646
|
-
|
|
4647
|
-
|
|
5124
|
+
/**
|
|
5125
|
+
* Get the {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
5126
|
+
*/
|
|
5127
|
+
getMethod() {
|
|
5128
|
+
return this.method;
|
|
4648
5129
|
}
|
|
4649
|
-
|
|
4650
|
-
|
|
5130
|
+
/**
|
|
5131
|
+
* Set the {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
5132
|
+
* @param method The {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
5133
|
+
*/
|
|
5134
|
+
setMethod(method) {
|
|
5135
|
+
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
5136
|
+
this.method = method;
|
|
5137
|
+
return this;
|
|
4651
5138
|
}
|
|
4652
|
-
|
|
4653
|
-
|
|
5139
|
+
/**
|
|
5140
|
+
* Get this {@link HttpOutgoingRequest}'s target URL.
|
|
5141
|
+
*/
|
|
5142
|
+
getURL() {
|
|
5143
|
+
return this.url;
|
|
4654
5144
|
}
|
|
4655
|
-
|
|
4656
|
-
|
|
5145
|
+
/**
|
|
5146
|
+
* Set the URL that this request will be sent to.
|
|
5147
|
+
* @param url The URL to send this request to.
|
|
5148
|
+
*/
|
|
5149
|
+
setURL(url) {
|
|
5150
|
+
PreCondition.assertNotEmpty(url, "url");
|
|
5151
|
+
this.url = url;
|
|
5152
|
+
return this;
|
|
4657
5153
|
}
|
|
4658
|
-
|
|
4659
|
-
|
|
5154
|
+
/**
|
|
5155
|
+
* Get the {@link HttpHeaders} that will be sent.
|
|
5156
|
+
*/
|
|
5157
|
+
getHeaders() {
|
|
5158
|
+
return this.headers;
|
|
4660
5159
|
}
|
|
4661
|
-
|
|
4662
|
-
return
|
|
5160
|
+
getHeader(headerName) {
|
|
5161
|
+
return this.headers.get(headerName);
|
|
4663
5162
|
}
|
|
4664
|
-
|
|
4665
|
-
return
|
|
5163
|
+
getHeaderValue(headerName) {
|
|
5164
|
+
return this.headers.getValue(headerName);
|
|
4666
5165
|
}
|
|
4667
|
-
|
|
4668
|
-
|
|
5166
|
+
/**
|
|
5167
|
+
* Get the body that will be sent.
|
|
5168
|
+
*/
|
|
5169
|
+
getBody() {
|
|
5170
|
+
return this.body;
|
|
4669
5171
|
}
|
|
4670
|
-
|
|
4671
|
-
|
|
5172
|
+
setBody(body) {
|
|
5173
|
+
PreCondition.assertNotUndefinedAndNotNull(body, "body");
|
|
5174
|
+
this.body = body;
|
|
5175
|
+
return this;
|
|
4672
5176
|
}
|
|
4673
|
-
|
|
4674
|
-
|
|
5177
|
+
};
|
|
5178
|
+
|
|
5179
|
+
// sources/fetchHttpClient.ts
|
|
5180
|
+
var FetchHttpClient = class _FetchHttpClient {
|
|
5181
|
+
constructor() {
|
|
4675
5182
|
}
|
|
4676
|
-
|
|
4677
|
-
return
|
|
5183
|
+
static create() {
|
|
5184
|
+
return new _FetchHttpClient();
|
|
4678
5185
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
5186
|
+
sendRequest(request) {
|
|
5187
|
+
PreCondition.assertNotUndefinedAndNotNull(request, "request");
|
|
5188
|
+
return PromiseAsyncResult.create(async () => {
|
|
5189
|
+
const requestInit = {
|
|
5190
|
+
method: _FetchHttpClient.convertMethod(request.getMethod()),
|
|
5191
|
+
headers: request.getHeaders().map((header) => [header.getName(), header.getValue()]).toArray().await(),
|
|
5192
|
+
body: request.getBody() || void 0
|
|
5193
|
+
};
|
|
5194
|
+
const fetchResponse = await fetch(request.getURL(), requestInit);
|
|
5195
|
+
return FetchHttpIncomingResponse.create(fetchResponse);
|
|
5196
|
+
});
|
|
4681
5197
|
}
|
|
4682
|
-
|
|
4683
|
-
return
|
|
5198
|
+
sendGetRequest(url) {
|
|
5199
|
+
return this.sendRequest(HttpOutgoingRequest.create(0 /* GET */, url));
|
|
4684
5200
|
}
|
|
4685
|
-
|
|
4686
|
-
|
|
5201
|
+
static convertMethod(method) {
|
|
5202
|
+
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
5203
|
+
let result;
|
|
5204
|
+
switch (method) {
|
|
5205
|
+
case 5 /* CONNECT */:
|
|
5206
|
+
result = "CONNECT";
|
|
5207
|
+
break;
|
|
5208
|
+
case 4 /* DELETE */:
|
|
5209
|
+
result = "DELETE";
|
|
5210
|
+
break;
|
|
5211
|
+
case 0 /* GET */:
|
|
5212
|
+
result = "GET";
|
|
5213
|
+
break;
|
|
5214
|
+
case 1 /* HEAD */:
|
|
5215
|
+
result = "HEAD";
|
|
5216
|
+
break;
|
|
5217
|
+
case 6 /* OPTIONS */:
|
|
5218
|
+
result = "OPTIONS";
|
|
5219
|
+
break;
|
|
5220
|
+
case 8 /* PATCH */:
|
|
5221
|
+
result = "PATCH";
|
|
5222
|
+
break;
|
|
5223
|
+
case 2 /* POST */:
|
|
5224
|
+
result = "POST";
|
|
5225
|
+
break;
|
|
5226
|
+
case 3 /* PUT */:
|
|
5227
|
+
result = "PUT";
|
|
5228
|
+
break;
|
|
5229
|
+
case 7 /* TRACE */:
|
|
5230
|
+
result = "TRACE";
|
|
5231
|
+
break;
|
|
5232
|
+
}
|
|
5233
|
+
PostCondition.assertNotEmpty(result, "result");
|
|
5234
|
+
return result;
|
|
4687
5235
|
}
|
|
4688
5236
|
};
|
|
4689
5237
|
|
|
4690
|
-
// sources/
|
|
4691
|
-
var
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
5238
|
+
// sources/network.ts
|
|
5239
|
+
var Network = class {
|
|
5240
|
+
};
|
|
5241
|
+
|
|
5242
|
+
// sources/nodeJSHttpServer.ts
|
|
5243
|
+
var http = __toESM(require("http"), 1);
|
|
5244
|
+
|
|
5245
|
+
// sources/httpServer.ts
|
|
5246
|
+
var HttpServer = class {
|
|
5247
|
+
};
|
|
5248
|
+
|
|
5249
|
+
// sources/httpOutgoingResponse.ts
|
|
5250
|
+
var HttpOutgoingResponse = class _HttpOutgoingResponse {
|
|
5251
|
+
statusCode;
|
|
5252
|
+
headers;
|
|
5253
|
+
body;
|
|
5254
|
+
constructor() {
|
|
5255
|
+
this.statusCode = 200;
|
|
5256
|
+
this.headers = MutableHttpHeaders.create();
|
|
5257
|
+
this.body = "";
|
|
5258
|
+
}
|
|
5259
|
+
static create() {
|
|
5260
|
+
return new _HttpOutgoingResponse();
|
|
5261
|
+
}
|
|
5262
|
+
/**
|
|
5263
|
+
* Get the status code of this {@link HttpOutgoingResponse}.
|
|
5264
|
+
*/
|
|
5265
|
+
getStatusCode() {
|
|
5266
|
+
return this.statusCode;
|
|
5267
|
+
}
|
|
5268
|
+
/**
|
|
5269
|
+
* Set the status code of this {@link HttpOutgoingResponse}.
|
|
5270
|
+
* @param statusCode The status code of this {@link HttpOutgoingResponse}.
|
|
5271
|
+
*/
|
|
5272
|
+
setStatusCode(statusCode) {
|
|
5273
|
+
PreCondition.assertBetween(100, statusCode, 599, "statusCode");
|
|
5274
|
+
this.statusCode = statusCode;
|
|
5275
|
+
return this;
|
|
4695
5276
|
}
|
|
4696
|
-
|
|
4697
|
-
return
|
|
5277
|
+
getHeaders() {
|
|
5278
|
+
return this.headers;
|
|
4698
5279
|
}
|
|
4699
|
-
|
|
4700
|
-
|
|
5280
|
+
/**
|
|
5281
|
+
* Get the HTTP header with the provided name or return a {@link NotFoundError} if the header
|
|
5282
|
+
* doesn't exist.
|
|
5283
|
+
* @param headerName The name of the header to get.
|
|
5284
|
+
*/
|
|
5285
|
+
getHeader(headerName) {
|
|
5286
|
+
return this.headers.get(headerName);
|
|
4701
5287
|
}
|
|
4702
|
-
|
|
4703
|
-
|
|
5288
|
+
/**
|
|
5289
|
+
* Get the value of the header with the provided name or return a {@link NotFoundError} if the
|
|
5290
|
+
* header doesn't exist.
|
|
5291
|
+
* @param headerName The name of the header value to get.
|
|
5292
|
+
*/
|
|
5293
|
+
getHeaderValue(headerName) {
|
|
5294
|
+
return this.headers.getValue(headerName);
|
|
4704
5295
|
}
|
|
4705
|
-
|
|
4706
|
-
|
|
5296
|
+
/**
|
|
5297
|
+
* Set the HTTP header in this {@link HttpOutgoingResponse}.
|
|
5298
|
+
* @param headerName The name of the HTTP header.
|
|
5299
|
+
* @param headerValue The value of the HTTP header.
|
|
5300
|
+
*/
|
|
5301
|
+
setHeader(headerName, headerValue) {
|
|
5302
|
+
this.headers.set(headerName, headerValue);
|
|
5303
|
+
return this;
|
|
5304
|
+
}
|
|
5305
|
+
setContentTypeHeader(contentType) {
|
|
5306
|
+
this.headers.setContentType(contentType);
|
|
5307
|
+
return this;
|
|
4707
5308
|
}
|
|
4708
5309
|
/**
|
|
4709
|
-
* Get the
|
|
5310
|
+
* Get the body of this {@link HttpOutgoingResponse}.
|
|
4710
5311
|
*/
|
|
4711
|
-
|
|
4712
|
-
return
|
|
5312
|
+
getBody() {
|
|
5313
|
+
return this.body;
|
|
4713
5314
|
}
|
|
4714
|
-
|
|
4715
|
-
|
|
5315
|
+
/**
|
|
5316
|
+
* Set the body of this {@link HttpOutgoingResponse}.
|
|
5317
|
+
* @param body The body for this {@link HttpOutgoingResponse}.
|
|
5318
|
+
*/
|
|
5319
|
+
setBody(body) {
|
|
5320
|
+
PreCondition.assertNotUndefinedAndNotNull(body, "body");
|
|
5321
|
+
this.body = body;
|
|
5322
|
+
return this;
|
|
4716
5323
|
}
|
|
4717
|
-
|
|
4718
|
-
|
|
5324
|
+
};
|
|
5325
|
+
|
|
5326
|
+
// sources/nodeJSHttpServer.ts
|
|
5327
|
+
var NodeJSHttpServer = class _NodeJSHttpServer extends HttpServer {
|
|
5328
|
+
httpServer;
|
|
5329
|
+
disposed;
|
|
5330
|
+
constructor() {
|
|
5331
|
+
super();
|
|
5332
|
+
this.disposed = false;
|
|
4719
5333
|
}
|
|
4720
|
-
static
|
|
4721
|
-
return
|
|
5334
|
+
static create() {
|
|
5335
|
+
return new _NodeJSHttpServer();
|
|
4722
5336
|
}
|
|
4723
|
-
|
|
4724
|
-
return
|
|
5337
|
+
dispose() {
|
|
5338
|
+
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
5339
|
+
if (this.disposed) {
|
|
5340
|
+
resolve(false);
|
|
5341
|
+
} else if (!this.httpServer) {
|
|
5342
|
+
this.disposed = true;
|
|
5343
|
+
resolve(true);
|
|
5344
|
+
} else {
|
|
5345
|
+
this.httpServer.close((error) => {
|
|
5346
|
+
if (error) {
|
|
5347
|
+
reject(error);
|
|
5348
|
+
} else {
|
|
5349
|
+
this.disposed = true;
|
|
5350
|
+
this.httpServer = void 0;
|
|
5351
|
+
resolve(true);
|
|
5352
|
+
}
|
|
5353
|
+
});
|
|
5354
|
+
}
|
|
5355
|
+
}));
|
|
4725
5356
|
}
|
|
4726
|
-
|
|
4727
|
-
return
|
|
5357
|
+
isDisposed() {
|
|
5358
|
+
return this.disposed;
|
|
4728
5359
|
}
|
|
4729
|
-
|
|
4730
|
-
return
|
|
5360
|
+
isStarted() {
|
|
5361
|
+
return !!this.httpServer;
|
|
4731
5362
|
}
|
|
4732
|
-
|
|
4733
|
-
|
|
5363
|
+
addRequestHandler(requestPath, handler) {
|
|
5364
|
+
throw new Error("Method not implemented.");
|
|
4734
5365
|
}
|
|
4735
|
-
|
|
4736
|
-
|
|
5366
|
+
setDefaultRequestHandler(handler) {
|
|
5367
|
+
throw new Error("Method not implemented.");
|
|
4737
5368
|
}
|
|
4738
|
-
|
|
4739
|
-
|
|
5369
|
+
start(portNumber) {
|
|
5370
|
+
PreCondition.assertGreaterThanOrEqualTo(portNumber, 1, "portNumber");
|
|
5371
|
+
PreCondition.assertFalse(this.isDisposed(), "this.isDisposed()");
|
|
5372
|
+
PreCondition.assertUndefined(this.httpServer, "this.httpServer");
|
|
5373
|
+
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
5374
|
+
if (this.httpServer) {
|
|
5375
|
+
reject(new Error("Can't run a HttpServer multiple times."));
|
|
5376
|
+
} else {
|
|
5377
|
+
this.httpServer = http.createServer();
|
|
5378
|
+
this.httpServer.on("request", (request, response) => {
|
|
5379
|
+
const httpResponse = HttpOutgoingResponse.create().setStatusCode(200).setHeader("Content-Type", "text/plain").setBody("Hello world!");
|
|
5380
|
+
const statusCode = httpResponse.getStatusCode();
|
|
5381
|
+
const headers = httpResponse.getHeaders();
|
|
5382
|
+
const responseHeaders = {};
|
|
5383
|
+
for (const header of headers) {
|
|
5384
|
+
responseHeaders[header.getName()] = header.getValue();
|
|
5385
|
+
}
|
|
5386
|
+
response.writeHead(statusCode, responseHeaders);
|
|
5387
|
+
response.end(httpResponse.getBody());
|
|
5388
|
+
});
|
|
5389
|
+
this.httpServer.on("close", () => {
|
|
5390
|
+
resolve();
|
|
5391
|
+
});
|
|
5392
|
+
this.httpServer.on("error", (error) => {
|
|
5393
|
+
reject(error);
|
|
5394
|
+
});
|
|
5395
|
+
this.httpServer.listen(portNumber);
|
|
5396
|
+
}
|
|
5397
|
+
}));
|
|
4740
5398
|
}
|
|
4741
|
-
|
|
4742
|
-
|
|
5399
|
+
};
|
|
5400
|
+
|
|
5401
|
+
// sources/realNetwork.ts
|
|
5402
|
+
var RealNetwork = class _RealNetwork extends Network {
|
|
5403
|
+
constructor() {
|
|
5404
|
+
super();
|
|
4743
5405
|
}
|
|
4744
|
-
static
|
|
4745
|
-
return
|
|
5406
|
+
static create() {
|
|
5407
|
+
return new _RealNetwork();
|
|
4746
5408
|
}
|
|
4747
|
-
|
|
4748
|
-
return
|
|
5409
|
+
createHttpServer() {
|
|
5410
|
+
return NodeJSHttpServer.create();
|
|
4749
5411
|
}
|
|
4750
|
-
|
|
4751
|
-
return
|
|
5412
|
+
createHttpClient() {
|
|
5413
|
+
return FetchHttpClient.create();
|
|
4752
5414
|
}
|
|
4753
|
-
|
|
4754
|
-
|
|
5415
|
+
};
|
|
5416
|
+
|
|
5417
|
+
// sources/currentProcess.ts
|
|
5418
|
+
var CurrentProcess = class _CurrentProcess {
|
|
5419
|
+
args;
|
|
5420
|
+
parameters;
|
|
5421
|
+
outputWriteStream;
|
|
5422
|
+
exitCodeProperty;
|
|
5423
|
+
network;
|
|
5424
|
+
constructor() {
|
|
4755
5425
|
}
|
|
4756
|
-
static
|
|
4757
|
-
return
|
|
5426
|
+
static create() {
|
|
5427
|
+
return new _CurrentProcess();
|
|
4758
5428
|
}
|
|
4759
|
-
|
|
4760
|
-
|
|
5429
|
+
static async run(action) {
|
|
5430
|
+
PreCondition.assertNotUndefinedAndNotNull(action, "action");
|
|
5431
|
+
const currentProcess = _CurrentProcess.create();
|
|
5432
|
+
try {
|
|
5433
|
+
const result = await action(currentProcess);
|
|
5434
|
+
if (isNumber(result)) {
|
|
5435
|
+
currentProcess.setExitCode(result);
|
|
5436
|
+
}
|
|
5437
|
+
} catch (error) {
|
|
5438
|
+
currentProcess.setExitCode(-1);
|
|
5439
|
+
const writeStream = currentProcess.getOutputWriteStream();
|
|
5440
|
+
if (error instanceof Error && error.stack) {
|
|
5441
|
+
writeStream.writeLine(error.stack);
|
|
5442
|
+
} else {
|
|
5443
|
+
writeStream.writeLine(`${error}`);
|
|
5444
|
+
}
|
|
5445
|
+
}
|
|
4761
5446
|
}
|
|
4762
|
-
|
|
4763
|
-
|
|
5447
|
+
getArguments() {
|
|
5448
|
+
if (!this.args) {
|
|
5449
|
+
this.args = Iterable.create(process.argv);
|
|
5450
|
+
}
|
|
5451
|
+
return this.args;
|
|
4764
5452
|
}
|
|
4765
|
-
|
|
4766
|
-
|
|
5453
|
+
setArguments(args) {
|
|
5454
|
+
PreCondition.assertNotUndefinedAndNotNull(args, "args");
|
|
5455
|
+
PreCondition.assertUndefined(this.parameters, "this.parameters");
|
|
5456
|
+
this.args = isIterable(args) ? args : Iterable.create(args);
|
|
5457
|
+
return this;
|
|
4767
5458
|
}
|
|
4768
|
-
|
|
4769
|
-
|
|
5459
|
+
getParameters() {
|
|
5460
|
+
if (!this.parameters) {
|
|
5461
|
+
this.parameters = CommandLineParameters.create(this.getArguments());
|
|
5462
|
+
}
|
|
5463
|
+
return this.parameters;
|
|
4770
5464
|
}
|
|
4771
|
-
|
|
4772
|
-
|
|
5465
|
+
getOutputWriteStream() {
|
|
5466
|
+
if (!this.outputWriteStream) {
|
|
5467
|
+
this.outputWriteStream = NodeJSCharacterWriteStream.create(process.stdout);
|
|
5468
|
+
}
|
|
5469
|
+
return this.outputWriteStream;
|
|
4773
5470
|
}
|
|
4774
|
-
|
|
4775
|
-
|
|
5471
|
+
setOutputWriteStream(outputWriteStream) {
|
|
5472
|
+
PreCondition.assertNotUndefinedAndNotNull(outputWriteStream, "outputWriteStream");
|
|
5473
|
+
this.outputWriteStream = outputWriteStream;
|
|
5474
|
+
return this;
|
|
4776
5475
|
}
|
|
4777
|
-
|
|
4778
|
-
return
|
|
5476
|
+
getExitCode() {
|
|
5477
|
+
return this.getExitCodeProperty().getValue();
|
|
4779
5478
|
}
|
|
4780
|
-
|
|
4781
|
-
|
|
5479
|
+
setExitCode(exitCode) {
|
|
5480
|
+
PreCondition.assertNotUndefinedAndNotNull(exitCode, "exitCode");
|
|
5481
|
+
this.getExitCodeProperty().setValue(exitCode);
|
|
5482
|
+
return this;
|
|
4782
5483
|
}
|
|
4783
|
-
|
|
4784
|
-
|
|
5484
|
+
getExitCodeProperty() {
|
|
5485
|
+
if (!this.exitCodeProperty) {
|
|
5486
|
+
this.exitCodeProperty = Property.create({
|
|
5487
|
+
getter: () => process.exitCode,
|
|
5488
|
+
setter: (value) => {
|
|
5489
|
+
process.exitCode = value;
|
|
5490
|
+
}
|
|
5491
|
+
});
|
|
5492
|
+
}
|
|
5493
|
+
return this.exitCodeProperty;
|
|
4785
5494
|
}
|
|
4786
|
-
|
|
4787
|
-
|
|
5495
|
+
setExitCodeProperty(exitCodeProperty) {
|
|
5496
|
+
PreCondition.assertNotUndefinedAndNotNull(exitCodeProperty, "exitCodeProperty");
|
|
5497
|
+
this.exitCodeProperty = exitCodeProperty;
|
|
5498
|
+
return this;
|
|
4788
5499
|
}
|
|
4789
|
-
|
|
4790
|
-
|
|
5500
|
+
getNetwork() {
|
|
5501
|
+
if (!this.network) {
|
|
5502
|
+
this.network = RealNetwork.create();
|
|
5503
|
+
}
|
|
5504
|
+
return this.network;
|
|
4791
5505
|
}
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
return headers.getValue(value.getName()).then((headerValue) => equalFunctions.areEqual(headerValue, value.getValue()).await()).catch(NotFoundError, () => false).await();
|
|
4798
|
-
});
|
|
5506
|
+
setNetwork(network) {
|
|
5507
|
+
PreCondition.assertUndefined(this.network, "this.network");
|
|
5508
|
+
PreCondition.assertNotUndefinedAndNotNull(network, "network");
|
|
5509
|
+
this.network = network;
|
|
5510
|
+
return this;
|
|
4799
5511
|
}
|
|
4800
5512
|
};
|
|
4801
5513
|
|
|
4802
|
-
// sources/
|
|
4803
|
-
var
|
|
4804
|
-
};
|
|
5514
|
+
// sources/luxonDateTime.ts
|
|
5515
|
+
var luxon = __toESM(require("luxon"), 1);
|
|
4805
5516
|
|
|
4806
|
-
// sources/
|
|
4807
|
-
var
|
|
4808
|
-
|
|
4809
|
-
constructor(
|
|
4810
|
-
|
|
4811
|
-
super();
|
|
4812
|
-
this.response = response;
|
|
5517
|
+
// sources/listStack.ts
|
|
5518
|
+
var ListStack = class _ListStack {
|
|
5519
|
+
list;
|
|
5520
|
+
constructor(list2) {
|
|
5521
|
+
this.list = list2 ?? List.create();
|
|
4813
5522
|
}
|
|
4814
|
-
static create(
|
|
4815
|
-
return new
|
|
5523
|
+
static create(list2) {
|
|
5524
|
+
return new _ListStack(list2);
|
|
4816
5525
|
}
|
|
4817
|
-
|
|
4818
|
-
return this.
|
|
5526
|
+
any() {
|
|
5527
|
+
return this.list.any();
|
|
4819
5528
|
}
|
|
4820
|
-
|
|
5529
|
+
getCount() {
|
|
5530
|
+
return this.list.getCount();
|
|
5531
|
+
}
|
|
5532
|
+
add(value) {
|
|
4821
5533
|
return SyncResult.create(() => {
|
|
4822
|
-
|
|
4823
|
-
for (const header of this.response.headers) {
|
|
4824
|
-
result.set(header[0], header[1]);
|
|
4825
|
-
}
|
|
4826
|
-
return result;
|
|
5534
|
+
this.list.add(value);
|
|
4827
5535
|
});
|
|
4828
5536
|
}
|
|
4829
|
-
|
|
4830
|
-
PreCondition.
|
|
5537
|
+
addAll(values) {
|
|
5538
|
+
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
4831
5539
|
return SyncResult.create(() => {
|
|
4832
|
-
|
|
4833
|
-
const lowerHeaderName = headerName.toLowerCase();
|
|
4834
|
-
for (const header of this.response.headers) {
|
|
4835
|
-
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
4836
|
-
result = HttpHeader.create(header[0], header[1]);
|
|
4837
|
-
break;
|
|
4838
|
-
}
|
|
4839
|
-
}
|
|
4840
|
-
if (result === void 0) {
|
|
4841
|
-
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
4842
|
-
}
|
|
4843
|
-
return result;
|
|
5540
|
+
this.list.addAll(values);
|
|
4844
5541
|
});
|
|
4845
5542
|
}
|
|
4846
|
-
|
|
4847
|
-
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
5543
|
+
remove() {
|
|
4848
5544
|
return SyncResult.create(() => {
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
for (const header of this.response.headers) {
|
|
4852
|
-
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
4853
|
-
result = header[1];
|
|
4854
|
-
break;
|
|
4855
|
-
}
|
|
4856
|
-
}
|
|
4857
|
-
if (result === void 0) {
|
|
4858
|
-
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
5545
|
+
if (!this.any().await()) {
|
|
5546
|
+
throw new EmptyError();
|
|
4859
5547
|
}
|
|
4860
|
-
return
|
|
5548
|
+
return this.list.removeLast().await();
|
|
4861
5549
|
});
|
|
4862
5550
|
}
|
|
4863
|
-
|
|
4864
|
-
return
|
|
5551
|
+
contains(value, equalFunctions) {
|
|
5552
|
+
return this.list.contains(value, equalFunctions);
|
|
4865
5553
|
}
|
|
4866
5554
|
};
|
|
4867
5555
|
|
|
4868
|
-
// sources/
|
|
4869
|
-
var
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
PreCondition.assertNotEmpty(url, "url");
|
|
4877
|
-
this.method = method;
|
|
4878
|
-
this.url = url;
|
|
4879
|
-
this.headers = HttpHeaders.create();
|
|
4880
|
-
this.body = "";
|
|
5556
|
+
// sources/stack.ts
|
|
5557
|
+
var Stack = class {
|
|
5558
|
+
/**
|
|
5559
|
+
* Create an instance of the default {@link Stack} implementation.
|
|
5560
|
+
* @returns A new {@link Stack} object.
|
|
5561
|
+
*/
|
|
5562
|
+
static create() {
|
|
5563
|
+
return ListStack.create();
|
|
4881
5564
|
}
|
|
4882
|
-
|
|
4883
|
-
|
|
5565
|
+
};
|
|
5566
|
+
|
|
5567
|
+
// sources/wonderlandTrailClient.ts
|
|
5568
|
+
var WonderlandTrailDirection = class _WonderlandTrailDirection {
|
|
5569
|
+
value;
|
|
5570
|
+
constructor(value) {
|
|
5571
|
+
PreCondition.assertNotEmpty(value, "value");
|
|
5572
|
+
this.value = value;
|
|
5573
|
+
}
|
|
5574
|
+
static clockwise = new _WonderlandTrailDirection("Clockwise");
|
|
5575
|
+
static counterClockwise = new _WonderlandTrailDirection("CounterClockwise");
|
|
5576
|
+
toString() {
|
|
5577
|
+
return this.value;
|
|
4884
5578
|
}
|
|
5579
|
+
reverse() {
|
|
5580
|
+
return this === _WonderlandTrailDirection.clockwise ? _WonderlandTrailDirection.counterClockwise : _WonderlandTrailDirection.clockwise;
|
|
5581
|
+
}
|
|
5582
|
+
};
|
|
5583
|
+
|
|
5584
|
+
// tests/test.ts
|
|
5585
|
+
var Test = class _Test {
|
|
4885
5586
|
/**
|
|
4886
|
-
*
|
|
4887
|
-
* @param
|
|
5587
|
+
* Assert that the provided value is undefined;
|
|
5588
|
+
* @param value The value to check.
|
|
4888
5589
|
*/
|
|
4889
|
-
|
|
4890
|
-
|
|
5590
|
+
assertUndefined(value) {
|
|
5591
|
+
_Test.assertUndefined(this, value);
|
|
4891
5592
|
}
|
|
4892
5593
|
/**
|
|
4893
|
-
*
|
|
5594
|
+
* Assert that the provided value is undefined.
|
|
5595
|
+
* @param test The current {@link Test}.
|
|
5596
|
+
* @param value The value to check.
|
|
4894
5597
|
*/
|
|
4895
|
-
|
|
4896
|
-
|
|
5598
|
+
static assertUndefined(test2, value) {
|
|
5599
|
+
test2.assertSame(value, void 0);
|
|
4897
5600
|
}
|
|
4898
5601
|
/**
|
|
4899
|
-
*
|
|
4900
|
-
* @param
|
|
5602
|
+
* Assert that the provided value is not undefined;
|
|
5603
|
+
* @param value The value to check.
|
|
4901
5604
|
*/
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
this.method = method;
|
|
4905
|
-
return this;
|
|
5605
|
+
assertNotUndefined(value) {
|
|
5606
|
+
_Test.assertNotUndefined(this, value);
|
|
4906
5607
|
}
|
|
4907
5608
|
/**
|
|
4908
|
-
*
|
|
5609
|
+
* Assert that the provided value is not undefined.
|
|
5610
|
+
* @param test The current {@link Test}.
|
|
5611
|
+
* @param value The value to check.
|
|
4909
5612
|
*/
|
|
4910
|
-
|
|
4911
|
-
|
|
5613
|
+
static assertNotUndefined(test2, value) {
|
|
5614
|
+
test2.assertNotSame(value, void 0);
|
|
4912
5615
|
}
|
|
4913
5616
|
/**
|
|
4914
|
-
*
|
|
4915
|
-
* @param
|
|
5617
|
+
* Assert that the provided value is null.
|
|
5618
|
+
* @param value The value to check.
|
|
4916
5619
|
*/
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
this.url = url;
|
|
4920
|
-
return this;
|
|
5620
|
+
assertNull(value) {
|
|
5621
|
+
_Test.assertNull(this, value);
|
|
4921
5622
|
}
|
|
4922
5623
|
/**
|
|
4923
|
-
*
|
|
5624
|
+
* Assert that the provided value is null.
|
|
5625
|
+
* @param value The value to check.
|
|
4924
5626
|
*/
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
}
|
|
4928
|
-
getHeader(headerName) {
|
|
4929
|
-
return this.headers.get(headerName);
|
|
4930
|
-
}
|
|
4931
|
-
getHeaderValue(headerName) {
|
|
4932
|
-
return this.headers.getValue(headerName);
|
|
5627
|
+
static assertNull(test2, value) {
|
|
5628
|
+
test2.assertSame(value, null);
|
|
4933
5629
|
}
|
|
4934
5630
|
/**
|
|
4935
|
-
*
|
|
5631
|
+
* Assert that the provided value is not null.
|
|
5632
|
+
* @param value The value to check.
|
|
4936
5633
|
*/
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
}
|
|
4940
|
-
setBody(body) {
|
|
4941
|
-
PreCondition.assertNotUndefinedAndNotNull(body, "body");
|
|
4942
|
-
this.body = body;
|
|
4943
|
-
return this;
|
|
4944
|
-
}
|
|
4945
|
-
};
|
|
4946
|
-
|
|
4947
|
-
// sources/fetchHttpClient.ts
|
|
4948
|
-
var FetchHttpClient = class _FetchHttpClient {
|
|
4949
|
-
constructor() {
|
|
4950
|
-
}
|
|
4951
|
-
static create() {
|
|
4952
|
-
return new _FetchHttpClient();
|
|
4953
|
-
}
|
|
4954
|
-
sendRequest(request) {
|
|
4955
|
-
PreCondition.assertNotUndefinedAndNotNull(request, "request");
|
|
4956
|
-
return PromiseAsyncResult.create(async () => {
|
|
4957
|
-
const requestInit = {
|
|
4958
|
-
method: _FetchHttpClient.convertMethod(request.getMethod()),
|
|
4959
|
-
headers: request.getHeaders().map((header) => [header.getName(), header.getValue()]).toArray().await(),
|
|
4960
|
-
body: request.getBody() || void 0
|
|
4961
|
-
};
|
|
4962
|
-
const fetchResponse = await fetch(request.getURL(), requestInit);
|
|
4963
|
-
return FetchHttpIncomingResponse.create(fetchResponse);
|
|
4964
|
-
});
|
|
4965
|
-
}
|
|
4966
|
-
sendGetRequest(url) {
|
|
4967
|
-
return this.sendRequest(HttpOutgoingRequest.create(0 /* GET */, url));
|
|
4968
|
-
}
|
|
4969
|
-
static convertMethod(method) {
|
|
4970
|
-
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
4971
|
-
let result;
|
|
4972
|
-
switch (method) {
|
|
4973
|
-
case 5 /* CONNECT */:
|
|
4974
|
-
result = "CONNECT";
|
|
4975
|
-
break;
|
|
4976
|
-
case 4 /* DELETE */:
|
|
4977
|
-
result = "DELETE";
|
|
4978
|
-
break;
|
|
4979
|
-
case 0 /* GET */:
|
|
4980
|
-
result = "GET";
|
|
4981
|
-
break;
|
|
4982
|
-
case 1 /* HEAD */:
|
|
4983
|
-
result = "HEAD";
|
|
4984
|
-
break;
|
|
4985
|
-
case 6 /* OPTIONS */:
|
|
4986
|
-
result = "OPTIONS";
|
|
4987
|
-
break;
|
|
4988
|
-
case 8 /* PATCH */:
|
|
4989
|
-
result = "PATCH";
|
|
4990
|
-
break;
|
|
4991
|
-
case 2 /* POST */:
|
|
4992
|
-
result = "POST";
|
|
4993
|
-
break;
|
|
4994
|
-
case 3 /* PUT */:
|
|
4995
|
-
result = "PUT";
|
|
4996
|
-
break;
|
|
4997
|
-
case 7 /* TRACE */:
|
|
4998
|
-
result = "TRACE";
|
|
4999
|
-
break;
|
|
5000
|
-
}
|
|
5001
|
-
PostCondition.assertNotEmpty(result, "result");
|
|
5002
|
-
return result;
|
|
5634
|
+
assertNotNull(value) {
|
|
5635
|
+
_Test.assertNull(this, value);
|
|
5003
5636
|
}
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
// sources/nodeJSHttpServer.ts
|
|
5011
|
-
var http = __toESM(require("http"), 1);
|
|
5012
|
-
|
|
5013
|
-
// sources/httpServer.ts
|
|
5014
|
-
var HttpServer = class {
|
|
5015
|
-
};
|
|
5016
|
-
|
|
5017
|
-
// sources/httpOutgoingResponse.ts
|
|
5018
|
-
var HttpOutgoingResponse = class _HttpOutgoingResponse {
|
|
5019
|
-
statusCode;
|
|
5020
|
-
headers;
|
|
5021
|
-
body;
|
|
5022
|
-
constructor() {
|
|
5023
|
-
this.statusCode = 200;
|
|
5024
|
-
this.headers = MutableHttpHeaders.create();
|
|
5025
|
-
this.body = "";
|
|
5637
|
+
/**
|
|
5638
|
+
* Assert that the provided value is not null.
|
|
5639
|
+
* @param value The value to check.
|
|
5640
|
+
*/
|
|
5641
|
+
static assertNotNull(test2, value) {
|
|
5642
|
+
test2.assertNotSame(value, null);
|
|
5026
5643
|
}
|
|
5027
|
-
|
|
5028
|
-
|
|
5644
|
+
/**
|
|
5645
|
+
* Assert that the provided value is not undefined and not null.
|
|
5646
|
+
* @param value The value to check.
|
|
5647
|
+
*/
|
|
5648
|
+
assertNotUndefinedAndNotNull(value) {
|
|
5649
|
+
_Test.assertNotUndefinedAndNotNull(this, value);
|
|
5029
5650
|
}
|
|
5030
5651
|
/**
|
|
5031
|
-
*
|
|
5652
|
+
* Assert that the provided value is not undefined and not null.
|
|
5653
|
+
* @param value The value to check.
|
|
5032
5654
|
*/
|
|
5033
|
-
|
|
5034
|
-
|
|
5655
|
+
static assertNotUndefinedAndNotNull(test2, value) {
|
|
5656
|
+
test2.assertNotSame(value, null);
|
|
5657
|
+
test2.assertNotSame(value, void 0);
|
|
5035
5658
|
}
|
|
5036
5659
|
/**
|
|
5037
|
-
*
|
|
5038
|
-
* @param
|
|
5660
|
+
* Assert that the provided collection is not undefined, not null, and not empty.
|
|
5661
|
+
* @param value The value to check.
|
|
5039
5662
|
*/
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
this.statusCode = statusCode;
|
|
5043
|
-
return this;
|
|
5663
|
+
assertNotEmpty(value) {
|
|
5664
|
+
_Test.assertNotEmpty(this, value);
|
|
5044
5665
|
}
|
|
5045
|
-
|
|
5046
|
-
|
|
5666
|
+
static assertNotEmpty(test2, value) {
|
|
5667
|
+
test2.assertNotUndefinedAndNotNull(value);
|
|
5668
|
+
test2.assertTrue(Iterable.any(value).await());
|
|
5047
5669
|
}
|
|
5048
5670
|
/**
|
|
5049
|
-
*
|
|
5050
|
-
*
|
|
5051
|
-
* @param headerName The name of the header to get.
|
|
5671
|
+
* Assert that the provided value is false.
|
|
5672
|
+
* @param value The value to check.
|
|
5052
5673
|
*/
|
|
5053
|
-
|
|
5054
|
-
|
|
5674
|
+
assertFalse(value) {
|
|
5675
|
+
_Test.assertFalse(this, value);
|
|
5676
|
+
}
|
|
5677
|
+
static assertFalse(test2, value) {
|
|
5678
|
+
PreCondition.assertNotUndefinedAndNotNull(test2, "test");
|
|
5679
|
+
test2.assertSame(value, false);
|
|
5055
5680
|
}
|
|
5056
5681
|
/**
|
|
5057
|
-
*
|
|
5058
|
-
*
|
|
5059
|
-
* @param headerName The name of the header value to get.
|
|
5682
|
+
* Assert that the provided value is true.
|
|
5683
|
+
* @param value The value to check.
|
|
5060
5684
|
*/
|
|
5061
|
-
|
|
5062
|
-
|
|
5685
|
+
assertTrue(value) {
|
|
5686
|
+
_Test.assertTrue(this, value);
|
|
5063
5687
|
}
|
|
5064
5688
|
/**
|
|
5065
|
-
*
|
|
5066
|
-
* @param
|
|
5067
|
-
* @param headerValue The value of the HTTP header.
|
|
5689
|
+
* Assert that the provided value is true.
|
|
5690
|
+
* @param value The value to check.
|
|
5068
5691
|
*/
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
}
|
|
5073
|
-
setContentTypeHeader(contentType) {
|
|
5074
|
-
this.headers.setContentType(contentType);
|
|
5075
|
-
return this;
|
|
5692
|
+
static assertTrue(test2, value) {
|
|
5693
|
+
PreCondition.assertNotUndefinedAndNotNull(test2, "test");
|
|
5694
|
+
test2.assertSame(value, true);
|
|
5076
5695
|
}
|
|
5077
5696
|
/**
|
|
5078
|
-
*
|
|
5697
|
+
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
5698
|
+
* @param value The value to check.
|
|
5699
|
+
* @param type The {@link Type} to check.
|
|
5700
|
+
* @param expression The expression that produced the value.
|
|
5701
|
+
* @param message An optional error message.
|
|
5079
5702
|
*/
|
|
5080
|
-
|
|
5081
|
-
return this
|
|
5703
|
+
assertInstanceOf(value, type, typeCheck) {
|
|
5704
|
+
return _Test.assertInstanceOf(this, value, type, typeCheck);
|
|
5082
5705
|
}
|
|
5083
5706
|
/**
|
|
5084
|
-
*
|
|
5085
|
-
* @param
|
|
5707
|
+
* Assert that the provided value is an instance of the provided {@link Type}.
|
|
5708
|
+
* @param value The value to check.
|
|
5709
|
+
* @param type The {@link Type} to check.
|
|
5710
|
+
* @param expression The expression that produced the value.
|
|
5711
|
+
* @param message An optional error message.
|
|
5086
5712
|
*/
|
|
5087
|
-
|
|
5088
|
-
PreCondition.assertNotUndefinedAndNotNull(
|
|
5089
|
-
|
|
5090
|
-
|
|
5713
|
+
static assertInstanceOf(test2, value, type, typeCheck) {
|
|
5714
|
+
PreCondition.assertNotUndefinedAndNotNull(type, "type");
|
|
5715
|
+
if (isUndefinedOrNull(typeCheck)) {
|
|
5716
|
+
typeCheck = ((value2) => value2 instanceof type);
|
|
5717
|
+
}
|
|
5718
|
+
if (!typeCheck(value)) {
|
|
5719
|
+
test2.fail(`Expected value to be of type ${type.name} but found ${value} instead.`);
|
|
5720
|
+
}
|
|
5091
5721
|
}
|
|
5092
5722
|
};
|
|
5093
5723
|
|
|
5094
|
-
//
|
|
5095
|
-
var
|
|
5096
|
-
httpServer;
|
|
5097
|
-
disposed;
|
|
5724
|
+
// tests/assertTest.ts
|
|
5725
|
+
var AssertTest = class _AssertTest {
|
|
5098
5726
|
constructor() {
|
|
5099
|
-
super();
|
|
5100
|
-
this.disposed = false;
|
|
5101
5727
|
}
|
|
5728
|
+
/**
|
|
5729
|
+
* Create a new {@link AssertTest} object.
|
|
5730
|
+
*/
|
|
5102
5731
|
static create() {
|
|
5103
|
-
return new
|
|
5104
|
-
}
|
|
5105
|
-
dispose() {
|
|
5106
|
-
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
5107
|
-
if (this.disposed) {
|
|
5108
|
-
resolve(false);
|
|
5109
|
-
} else if (!this.httpServer) {
|
|
5110
|
-
this.disposed = true;
|
|
5111
|
-
resolve(true);
|
|
5112
|
-
} else {
|
|
5113
|
-
this.httpServer.close((error) => {
|
|
5114
|
-
if (error) {
|
|
5115
|
-
reject(error);
|
|
5116
|
-
} else {
|
|
5117
|
-
this.disposed = true;
|
|
5118
|
-
this.httpServer = void 0;
|
|
5119
|
-
resolve(true);
|
|
5120
|
-
}
|
|
5121
|
-
});
|
|
5122
|
-
}
|
|
5123
|
-
}));
|
|
5124
|
-
}
|
|
5125
|
-
isDisposed() {
|
|
5126
|
-
return this.disposed;
|
|
5127
|
-
}
|
|
5128
|
-
isStarted() {
|
|
5129
|
-
return !!this.httpServer;
|
|
5130
|
-
}
|
|
5131
|
-
addRequestHandler(requestPath, handler) {
|
|
5132
|
-
throw new Error("Method not implemented.");
|
|
5732
|
+
return new _AssertTest();
|
|
5133
5733
|
}
|
|
5134
|
-
|
|
5135
|
-
|
|
5734
|
+
fail(message) {
|
|
5735
|
+
PreCondition.assertNotEmpty(message, "message");
|
|
5736
|
+
assert.fail(message);
|
|
5136
5737
|
}
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
PreCondition.assertFalse(this.isDisposed(), "this.isDisposed()");
|
|
5140
|
-
PreCondition.assertUndefined(this.httpServer, "this.httpServer");
|
|
5141
|
-
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
5142
|
-
if (this.httpServer) {
|
|
5143
|
-
reject(new Error("Can't run a HttpServer multiple times."));
|
|
5144
|
-
} else {
|
|
5145
|
-
this.httpServer = http.createServer();
|
|
5146
|
-
this.httpServer.on("request", (request, response) => {
|
|
5147
|
-
const httpResponse = HttpOutgoingResponse.create().setStatusCode(200).setHeader("Content-Type", "text/plain").setBody("Hello world!");
|
|
5148
|
-
const statusCode = httpResponse.getStatusCode();
|
|
5149
|
-
const headers = httpResponse.getHeaders();
|
|
5150
|
-
const responseHeaders = {};
|
|
5151
|
-
for (const header of headers) {
|
|
5152
|
-
responseHeaders[header.getName()] = header.getValue();
|
|
5153
|
-
}
|
|
5154
|
-
response.writeHead(statusCode, responseHeaders);
|
|
5155
|
-
response.end(httpResponse.getBody());
|
|
5156
|
-
});
|
|
5157
|
-
this.httpServer.on("close", () => {
|
|
5158
|
-
resolve();
|
|
5159
|
-
});
|
|
5160
|
-
this.httpServer.on("error", (error) => {
|
|
5161
|
-
reject(error);
|
|
5162
|
-
});
|
|
5163
|
-
this.httpServer.listen(portNumber);
|
|
5164
|
-
}
|
|
5165
|
-
}));
|
|
5738
|
+
assertUndefined(value) {
|
|
5739
|
+
Test.assertUndefined(this, value);
|
|
5166
5740
|
}
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
// sources/realNetwork.ts
|
|
5170
|
-
var RealNetwork = class _RealNetwork extends Network {
|
|
5171
|
-
constructor() {
|
|
5172
|
-
super();
|
|
5741
|
+
assertNotUndefined(value) {
|
|
5742
|
+
Test.assertNotUndefined(this, value);
|
|
5173
5743
|
}
|
|
5174
|
-
|
|
5175
|
-
|
|
5744
|
+
assertNull(value) {
|
|
5745
|
+
Test.assertNull(this, value);
|
|
5176
5746
|
}
|
|
5177
|
-
|
|
5178
|
-
|
|
5747
|
+
assertNotNull(value) {
|
|
5748
|
+
Test.assertNotNull(this, value);
|
|
5179
5749
|
}
|
|
5180
|
-
|
|
5181
|
-
|
|
5750
|
+
assertNotUndefinedAndNotNull(value) {
|
|
5751
|
+
Test.assertNotUndefinedAndNotNull(this, value);
|
|
5182
5752
|
}
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
// sources/currentProcess.ts
|
|
5186
|
-
var CurrentProcess = class _CurrentProcess {
|
|
5187
|
-
args;
|
|
5188
|
-
parameters;
|
|
5189
|
-
outputWriteStream;
|
|
5190
|
-
exitCodeProperty;
|
|
5191
|
-
network;
|
|
5192
|
-
constructor() {
|
|
5753
|
+
assertNotEmpty(value) {
|
|
5754
|
+
Test.assertNotEmpty(this, value);
|
|
5193
5755
|
}
|
|
5194
|
-
|
|
5195
|
-
|
|
5756
|
+
assertSame(left, right) {
|
|
5757
|
+
assert.strictEqual(left, right);
|
|
5196
5758
|
}
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
const currentProcess = _CurrentProcess.create();
|
|
5200
|
-
try {
|
|
5201
|
-
const result = await action(currentProcess);
|
|
5202
|
-
if (isNumber(result)) {
|
|
5203
|
-
currentProcess.setExitCode(result);
|
|
5204
|
-
}
|
|
5205
|
-
} catch (error) {
|
|
5206
|
-
currentProcess.setExitCode(-1);
|
|
5207
|
-
const writeStream = currentProcess.getOutputWriteStream();
|
|
5208
|
-
if (error instanceof Error && error.stack) {
|
|
5209
|
-
writeStream.writeLine(error.stack);
|
|
5210
|
-
} else {
|
|
5211
|
-
writeStream.writeLine(`${error}`);
|
|
5212
|
-
}
|
|
5213
|
-
}
|
|
5759
|
+
assertNotSame(left, right) {
|
|
5760
|
+
assert.notStrictEqual(left, right);
|
|
5214
5761
|
}
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
this.args = process.argv;
|
|
5218
|
-
}
|
|
5219
|
-
return this.args;
|
|
5762
|
+
assertEqual(left, right, message) {
|
|
5763
|
+
assert.deepStrictEqual(left, right, message);
|
|
5220
5764
|
}
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
PreCondition.assertUndefined(this.parameters, "this.parameters");
|
|
5224
|
-
this.args = args;
|
|
5225
|
-
return this;
|
|
5765
|
+
assertNotEqual(left, right) {
|
|
5766
|
+
assert.notDeepStrictEqual(left, right);
|
|
5226
5767
|
}
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
this.parameters = CommandLineParameters.create(this.getArguments());
|
|
5230
|
-
}
|
|
5231
|
-
return this.parameters;
|
|
5768
|
+
assertFalse(value) {
|
|
5769
|
+
Test.assertFalse(this, value);
|
|
5232
5770
|
}
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
this.outputWriteStream = NodeJSCharacterWriteStream.create(process.stdout);
|
|
5236
|
-
}
|
|
5237
|
-
return this.outputWriteStream;
|
|
5771
|
+
assertTrue(value) {
|
|
5772
|
+
Test.assertTrue(this, value);
|
|
5238
5773
|
}
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5774
|
+
assertThrows(action, expectedError) {
|
|
5775
|
+
if (!isFunction(action)) {
|
|
5776
|
+
const syncResult = action;
|
|
5777
|
+
action = () => {
|
|
5778
|
+
syncResult.await();
|
|
5779
|
+
};
|
|
5780
|
+
}
|
|
5781
|
+
assert.throws(action, expectedError);
|
|
5243
5782
|
}
|
|
5244
|
-
|
|
5245
|
-
|
|
5783
|
+
assertThrowsAsync(action, expectedError) {
|
|
5784
|
+
const promiseOrAsyncAction = isFunction(action) ? async () => await action() : action;
|
|
5785
|
+
return PromiseAsyncResult.create(assert.rejects(promiseOrAsyncAction, expectedError));
|
|
5246
5786
|
}
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
this.getExitCodeProperty().setValue(exitCode);
|
|
5250
|
-
return this;
|
|
5787
|
+
assertInstanceOf(value, type, typeCheck) {
|
|
5788
|
+
Test.assertInstanceOf(this, value, type, typeCheck);
|
|
5251
5789
|
}
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5790
|
+
};
|
|
5791
|
+
|
|
5792
|
+
// tests/assertTestTests.ts
|
|
5793
|
+
var import_assert = require("assert");
|
|
5794
|
+
function test(runner) {
|
|
5795
|
+
runner.testFile("assertTest.ts", () => {
|
|
5796
|
+
runner.testType("AssertTest", () => {
|
|
5797
|
+
runner.testFunction("assertThrows()", () => {
|
|
5798
|
+
runner.test("with throwing action", (test2) => {
|
|
5799
|
+
const at = AssertTest.create();
|
|
5800
|
+
at.assertThrows(() => {
|
|
5801
|
+
throw new Error("abc");
|
|
5802
|
+
}, new Error("abc"));
|
|
5803
|
+
});
|
|
5804
|
+
runner.test("with non-throwing action", (test2) => {
|
|
5805
|
+
const at = AssertTest.create();
|
|
5806
|
+
test2.assertThrows(
|
|
5807
|
+
() => at.assertThrows(() => {
|
|
5808
|
+
}, new Error("oops")),
|
|
5809
|
+
new import_assert.AssertionError({
|
|
5810
|
+
message: "Missing expected exception (Error).",
|
|
5811
|
+
operator: "throws",
|
|
5812
|
+
expected: new Error("oops")
|
|
5813
|
+
})
|
|
5814
|
+
);
|
|
5815
|
+
});
|
|
5259
5816
|
});
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5817
|
+
runner.testFunction("assertThrowsAsync()", () => {
|
|
5818
|
+
runner.test("with throwing sync action", async (test2) => {
|
|
5819
|
+
const at = AssertTest.create();
|
|
5820
|
+
await at.assertThrowsAsync(() => {
|
|
5821
|
+
throw new Error("abc");
|
|
5822
|
+
}, new Error("abc"));
|
|
5823
|
+
});
|
|
5824
|
+
runner.test("with throwing async action", async (test2) => {
|
|
5825
|
+
const at = AssertTest.create();
|
|
5826
|
+
await at.assertThrowsAsync(async () => {
|
|
5827
|
+
throw new Error("abc");
|
|
5828
|
+
}, new Error("abc"));
|
|
5829
|
+
});
|
|
5830
|
+
runner.test("with rejected Promise", async (test2) => {
|
|
5831
|
+
const at = AssertTest.create();
|
|
5832
|
+
await at.assertThrowsAsync(Promise.reject(new Error("abc")), new Error("abc"));
|
|
5833
|
+
});
|
|
5834
|
+
runner.test("with throwing action that returns a rejected Promise", async (test2) => {
|
|
5835
|
+
const at = AssertTest.create();
|
|
5836
|
+
await at.assertThrowsAsync(() => Promise.reject(new Error("abc")), new Error("abc"));
|
|
5837
|
+
});
|
|
5838
|
+
runner.test("with non-throwing async action", async (test2) => {
|
|
5839
|
+
const at = AssertTest.create();
|
|
5840
|
+
await test2.assertThrowsAsync(
|
|
5841
|
+
async () => await at.assertThrowsAsync(async () => {
|
|
5842
|
+
}, new Error("oops")),
|
|
5843
|
+
new import_assert.AssertionError({
|
|
5844
|
+
message: "Missing expected rejection (Error).",
|
|
5845
|
+
operator: "rejects",
|
|
5846
|
+
expected: new Error("oops")
|
|
5847
|
+
})
|
|
5848
|
+
);
|
|
5849
|
+
});
|
|
5850
|
+
});
|
|
5851
|
+
});
|
|
5852
|
+
});
|
|
5853
|
+
}
|
|
5854
|
+
|
|
5855
|
+
// tests/basicTestSkip.ts
|
|
5856
|
+
var BasicTestSkip = class _BasicTestSkip {
|
|
5857
|
+
shouldSkip;
|
|
5858
|
+
message;
|
|
5859
|
+
constructor(shouldSkip, message) {
|
|
5860
|
+
PreCondition.assertNotUndefinedAndNotNull(message, "message");
|
|
5861
|
+
this.shouldSkip = shouldSkip;
|
|
5862
|
+
this.message = message;
|
|
5267
5863
|
}
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5864
|
+
/**
|
|
5865
|
+
* Create a new {@link TestSkip} with the provided properties.
|
|
5866
|
+
* @param shouldSkip Whether the tests associated with the new {@link TestSkip}
|
|
5867
|
+
* should be skipped.
|
|
5868
|
+
* @param message The message that explains why the tests associated with this {@link TestSkip}
|
|
5869
|
+
* should be skipped.
|
|
5870
|
+
*/
|
|
5871
|
+
static create(shouldSkip, message) {
|
|
5872
|
+
if (shouldSkip === void 0 || shouldSkip === null) {
|
|
5873
|
+
shouldSkip = true;
|
|
5271
5874
|
}
|
|
5272
|
-
|
|
5875
|
+
if (message === void 0 || message === null) {
|
|
5876
|
+
message = "";
|
|
5877
|
+
}
|
|
5878
|
+
return new _BasicTestSkip(shouldSkip, message);
|
|
5273
5879
|
}
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
return this;
|
|
5880
|
+
getShouldSkip() {
|
|
5881
|
+
return this.shouldSkip;
|
|
5882
|
+
}
|
|
5883
|
+
getMessage() {
|
|
5884
|
+
return this.message;
|
|
5279
5885
|
}
|
|
5280
5886
|
};
|
|
5281
5887
|
|
|
5282
5888
|
// tests/failedTest.ts
|
|
5283
5889
|
var FailedTest = class _FailedTest {
|
|
5284
|
-
|
|
5890
|
+
testAction;
|
|
5285
5891
|
error;
|
|
5286
|
-
constructor(
|
|
5287
|
-
PreCondition.
|
|
5892
|
+
constructor(testAction, error) {
|
|
5893
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
5288
5894
|
PreCondition.assertNotUndefinedAndNotNull(error, "error");
|
|
5289
|
-
this.
|
|
5895
|
+
this.testAction = testAction;
|
|
5290
5896
|
this.error = error;
|
|
5291
5897
|
}
|
|
5292
|
-
static create(
|
|
5293
|
-
return new _FailedTest(
|
|
5294
|
-
}
|
|
5295
|
-
getFullTestNameParts() {
|
|
5296
|
-
return this.fullTestNameParts;
|
|
5898
|
+
static create(testAction, error) {
|
|
5899
|
+
return new _FailedTest(testAction, error);
|
|
5297
5900
|
}
|
|
5298
|
-
|
|
5299
|
-
return
|
|
5901
|
+
getTestAction() {
|
|
5902
|
+
return this.testAction;
|
|
5300
5903
|
}
|
|
5301
|
-
|
|
5904
|
+
getTestError() {
|
|
5302
5905
|
return this.error;
|
|
5303
5906
|
}
|
|
5304
|
-
getErrorMessage() {
|
|
5305
|
-
return this.error instanceof Error && this.error.stack ? this.error.stack : `${this.error}`;
|
|
5306
|
-
}
|
|
5307
5907
|
};
|
|
5308
5908
|
|
|
5309
5909
|
// tests/skippedTest.ts
|
|
5310
5910
|
var SkippedTest = class _SkippedTest {
|
|
5311
5911
|
skip;
|
|
5312
|
-
|
|
5313
|
-
constructor(skip,
|
|
5912
|
+
testAction;
|
|
5913
|
+
constructor(skip, testAction) {
|
|
5314
5914
|
PreCondition.assertNotUndefinedAndNotNull(skip, "skip");
|
|
5315
|
-
PreCondition.
|
|
5915
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
5316
5916
|
this.skip = skip;
|
|
5317
|
-
this.
|
|
5917
|
+
this.testAction = testAction;
|
|
5318
5918
|
}
|
|
5319
|
-
static create(skip,
|
|
5320
|
-
return new _SkippedTest(skip,
|
|
5919
|
+
static create(skip, testAction) {
|
|
5920
|
+
return new _SkippedTest(skip, testAction);
|
|
5321
5921
|
}
|
|
5322
5922
|
getSkipMessage() {
|
|
5323
5923
|
return this.skip.getMessage();
|
|
5324
5924
|
}
|
|
5325
|
-
|
|
5326
|
-
return this.
|
|
5327
|
-
}
|
|
5328
|
-
getFullTestName() {
|
|
5329
|
-
return join(" ", this.fullTestNameParts);
|
|
5925
|
+
getTestAction() {
|
|
5926
|
+
return this.testAction;
|
|
5330
5927
|
}
|
|
5331
5928
|
};
|
|
5332
5929
|
|
|
@@ -5334,18 +5931,21 @@ var SkippedTest = class _SkippedTest {
|
|
|
5334
5931
|
var TestAction = class _TestAction {
|
|
5335
5932
|
parent;
|
|
5336
5933
|
name;
|
|
5934
|
+
type;
|
|
5337
5935
|
skip;
|
|
5338
5936
|
action;
|
|
5339
|
-
constructor(parent, name, skip, action) {
|
|
5937
|
+
constructor(parent, name, type, skip, action) {
|
|
5340
5938
|
PreCondition.assertNotUndefinedAndNotNull(name, "name");
|
|
5939
|
+
PreCondition.assertNotEmpty(type, "type");
|
|
5341
5940
|
PreCondition.assertNotUndefinedAndNotNull(action, "action");
|
|
5342
5941
|
this.parent = parent;
|
|
5343
5942
|
this.name = name;
|
|
5943
|
+
this.type = type;
|
|
5344
5944
|
this.skip = skip;
|
|
5345
5945
|
this.action = action;
|
|
5346
5946
|
}
|
|
5347
|
-
static create(parent, name, skip, action) {
|
|
5348
|
-
return new _TestAction(parent, name, skip, action);
|
|
5947
|
+
static create(parent, name, type, skip, action) {
|
|
5948
|
+
return new _TestAction(parent, name, type, skip, action);
|
|
5349
5949
|
}
|
|
5350
5950
|
getParent() {
|
|
5351
5951
|
return this.parent;
|
|
@@ -5364,6 +5964,9 @@ var TestAction = class _TestAction {
|
|
|
5364
5964
|
getFullName() {
|
|
5365
5965
|
return join(" ", this.getFullNameParts());
|
|
5366
5966
|
}
|
|
5967
|
+
getType() {
|
|
5968
|
+
return this.type;
|
|
5969
|
+
}
|
|
5367
5970
|
getSkip() {
|
|
5368
5971
|
return this.skip || this.parent?.getSkip();
|
|
5369
5972
|
}
|
|
@@ -5378,34 +5981,6 @@ var TestAction = class _TestAction {
|
|
|
5378
5981
|
}
|
|
5379
5982
|
};
|
|
5380
5983
|
|
|
5381
|
-
// sources/english.ts
|
|
5382
|
-
function andList(values) {
|
|
5383
|
-
return list("and", values);
|
|
5384
|
-
}
|
|
5385
|
-
function list(conjunction, values) {
|
|
5386
|
-
PreCondition.assertNotEmpty(conjunction, "conjunction");
|
|
5387
|
-
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
5388
|
-
let result = "";
|
|
5389
|
-
let index = 0;
|
|
5390
|
-
const iterator = Iterator.create(values).start().await();
|
|
5391
|
-
while (iterator.hasCurrent()) {
|
|
5392
|
-
const currentValue = iterator.takeCurrent().await();
|
|
5393
|
-
if (index >= 1) {
|
|
5394
|
-
if (iterator.hasCurrent()) {
|
|
5395
|
-
result += `, `;
|
|
5396
|
-
} else {
|
|
5397
|
-
if (index >= 2) {
|
|
5398
|
-
result += `,`;
|
|
5399
|
-
}
|
|
5400
|
-
result += ` ${conjunction} `;
|
|
5401
|
-
}
|
|
5402
|
-
}
|
|
5403
|
-
result += currentValue;
|
|
5404
|
-
index++;
|
|
5405
|
-
}
|
|
5406
|
-
return result;
|
|
5407
|
-
}
|
|
5408
|
-
|
|
5409
5984
|
// tests/testSkip.ts
|
|
5410
5985
|
var TestSkip = class {
|
|
5411
5986
|
constructor() {
|
|
@@ -5449,139 +6024,404 @@ var TestRunner = class _TestRunner {
|
|
|
5449
6024
|
toString(value) {
|
|
5450
6025
|
return _TestRunner.toString(this, value);
|
|
5451
6026
|
}
|
|
5452
|
-
/**
|
|
5453
|
-
* Get the {@link string} representation of the provided value.
|
|
5454
|
-
* @param value The value to get the {@link string} representation of.
|
|
5455
|
-
*/
|
|
5456
|
-
static toString(_runner, value) {
|
|
5457
|
-
const toStringFunctions = ToStringFunctions.create();
|
|
5458
|
-
return toStringFunctions.toString(value);
|
|
6027
|
+
/**
|
|
6028
|
+
* Get the {@link string} representation of the provided value.
|
|
6029
|
+
* @param value The value to get the {@link string} representation of.
|
|
6030
|
+
*/
|
|
6031
|
+
static toString(_runner, value) {
|
|
6032
|
+
const toStringFunctions = ToStringFunctions.create();
|
|
6033
|
+
return toStringFunctions.toString(value);
|
|
6034
|
+
}
|
|
6035
|
+
skip(messageOrShouldSkip, message) {
|
|
6036
|
+
let shouldSkip;
|
|
6037
|
+
if (!isBoolean(messageOrShouldSkip)) {
|
|
6038
|
+
shouldSkip = true;
|
|
6039
|
+
message = messageOrShouldSkip;
|
|
6040
|
+
} else {
|
|
6041
|
+
shouldSkip = messageOrShouldSkip;
|
|
6042
|
+
}
|
|
6043
|
+
return _TestRunner.skip(this, shouldSkip, message);
|
|
6044
|
+
}
|
|
6045
|
+
/**
|
|
6046
|
+
* Create a {@link TestSkip} object that will prevent tests from being run.
|
|
6047
|
+
* @param shouldSkip Whether these tests should be skipped.
|
|
6048
|
+
* @param message The message that explains why the tests are being skipped.
|
|
6049
|
+
*/
|
|
6050
|
+
static skip(_runner, shouldSkip, message) {
|
|
6051
|
+
return TestSkip.create(shouldSkip, message);
|
|
6052
|
+
}
|
|
6053
|
+
};
|
|
6054
|
+
|
|
6055
|
+
// tests/ConsoleTestRunnerUI.ts
|
|
6056
|
+
var ConsoleTestRunnerUI = class {
|
|
6057
|
+
writeStream;
|
|
6058
|
+
styles;
|
|
6059
|
+
getErrorStringOptions;
|
|
6060
|
+
constructor() {
|
|
6061
|
+
this.styles = Map2.create();
|
|
6062
|
+
}
|
|
6063
|
+
static flat() {
|
|
6064
|
+
return FlatConsoleTestRunnerUI.create();
|
|
6065
|
+
}
|
|
6066
|
+
static tree() {
|
|
6067
|
+
return TreeConsoleTestRunnerUI.create();
|
|
6068
|
+
}
|
|
6069
|
+
setWriteStream(writeStream) {
|
|
6070
|
+
PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
|
|
6071
|
+
this.writeStream = IndentedCharacterWriteStream.create(writeStream);
|
|
6072
|
+
return this;
|
|
6073
|
+
}
|
|
6074
|
+
setStyle(style, styleFunction) {
|
|
6075
|
+
PreCondition.assertNotEmpty(style, "style");
|
|
6076
|
+
PreCondition.assertNotUndefinedAndNotNull(styleFunction, "styleFunction");
|
|
6077
|
+
this.styles.set(style, styleFunction);
|
|
6078
|
+
return this;
|
|
6079
|
+
}
|
|
6080
|
+
setStyles(styles) {
|
|
6081
|
+
PreCondition.assertNotUndefinedAndNotNull(styles, "styles");
|
|
6082
|
+
for (const entry of Object.entries(styles)) {
|
|
6083
|
+
this.setStyle(entry[0], entry[1]);
|
|
6084
|
+
}
|
|
6085
|
+
return this;
|
|
6086
|
+
}
|
|
6087
|
+
applyStyle(style, text) {
|
|
6088
|
+
PreCondition.assertNotEmpty(style, "style");
|
|
6089
|
+
PreCondition.assertNotUndefinedAndNotNull(text, "text");
|
|
6090
|
+
const styleFunction = this.styles.get(style).catch(NotFoundError, () => {
|
|
6091
|
+
return (text2) => text2;
|
|
6092
|
+
}).await();
|
|
6093
|
+
return styleFunction(text);
|
|
6094
|
+
}
|
|
6095
|
+
addIndentation() {
|
|
6096
|
+
this.writeStream?.addIndentation();
|
|
6097
|
+
}
|
|
6098
|
+
removeIndentation() {
|
|
6099
|
+
this.writeStream?.removeIndentation();
|
|
6100
|
+
}
|
|
6101
|
+
indent(action) {
|
|
6102
|
+
return this.writeStream?.indent(action) ?? AsyncResult.value(0);
|
|
6103
|
+
}
|
|
6104
|
+
writeString(text) {
|
|
6105
|
+
return this.writeStream?.writeString(text) ?? AsyncResult.value(0);
|
|
6106
|
+
}
|
|
6107
|
+
writeLine(text) {
|
|
6108
|
+
return this.writeStream?.writeLine(text) ?? AsyncResult.value(0);
|
|
6109
|
+
}
|
|
6110
|
+
writeTestActionName(testAction) {
|
|
6111
|
+
return this.writeString(this.applyStyle(testAction.getType(), testAction.getName()));
|
|
6112
|
+
}
|
|
6113
|
+
writeFullTestActionName(testAction) {
|
|
6114
|
+
return AsyncResult.create(async () => {
|
|
6115
|
+
let result = 0;
|
|
6116
|
+
const testActionStack = Stack.create();
|
|
6117
|
+
let currentTestAction = testAction;
|
|
6118
|
+
while (currentTestAction) {
|
|
6119
|
+
testActionStack.add(currentTestAction);
|
|
6120
|
+
currentTestAction = currentTestAction.getParent();
|
|
6121
|
+
}
|
|
6122
|
+
while (await testActionStack.any()) {
|
|
6123
|
+
currentTestAction = await testActionStack.remove();
|
|
6124
|
+
if (currentTestAction.getParent()) {
|
|
6125
|
+
result += await this.writeString(" ");
|
|
6126
|
+
}
|
|
6127
|
+
result += await this.writeTestActionName(currentTestAction);
|
|
6128
|
+
}
|
|
6129
|
+
return result;
|
|
6130
|
+
});
|
|
6131
|
+
}
|
|
6132
|
+
setGetErrorStringOptions(options) {
|
|
6133
|
+
this.getErrorStringOptions = options;
|
|
6134
|
+
return this;
|
|
6135
|
+
}
|
|
6136
|
+
beforeTestGroup(testGroup) {
|
|
6137
|
+
PreCondition.assertNotUndefinedAndNotNull(testGroup, "testGroup");
|
|
6138
|
+
return AsyncResult.empty();
|
|
6139
|
+
}
|
|
6140
|
+
afterTestGroup(testGroup) {
|
|
6141
|
+
PreCondition.assertNotUndefinedAndNotNull(testGroup, "testGroup");
|
|
6142
|
+
return AsyncResult.empty();
|
|
6143
|
+
}
|
|
6144
|
+
beforeTest(testAction) {
|
|
6145
|
+
return AsyncResult.empty();
|
|
6146
|
+
}
|
|
6147
|
+
afterPassedTest(testAction) {
|
|
6148
|
+
return AsyncResult.create(async () => {
|
|
6149
|
+
await this.writeLine(` - ${this.applyStyle("passed", "Passed")}`);
|
|
6150
|
+
});
|
|
6151
|
+
}
|
|
6152
|
+
afterSkippedTest(testAction, skip) {
|
|
6153
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
6154
|
+
PreCondition.assertNotUndefinedAndNotNull(skip, "skip");
|
|
6155
|
+
return AsyncResult.create(async () => {
|
|
6156
|
+
await this.writeLine(` - ${this.applyStyle("skipped", "Skipped")}`);
|
|
6157
|
+
});
|
|
6158
|
+
}
|
|
6159
|
+
afterFailedTest(currentTestAction, error) {
|
|
6160
|
+
PreCondition.assertNotUndefinedAndNotNull(currentTestAction, "currentTestAction");
|
|
6161
|
+
PreCondition.assertNotUndefinedAndNotNull(error, "error");
|
|
6162
|
+
return AsyncResult.create(async () => {
|
|
6163
|
+
await this.writeLine(` - ${this.applyStyle("failed", "Failed")}`);
|
|
6164
|
+
});
|
|
6165
|
+
}
|
|
6166
|
+
writeSummary(passedTestCount, skippedTests, failedTests) {
|
|
6167
|
+
PreCondition.assertGreaterThanOrEqualTo(passedTestCount, 0, "passedTestCount");
|
|
6168
|
+
PreCondition.assertNotUndefinedAndNotNull(skippedTests, "skippedTests");
|
|
6169
|
+
PreCondition.assertNotUndefinedAndNotNull(failedTests, "failedTests");
|
|
6170
|
+
return AsyncResult.create(async () => {
|
|
6171
|
+
await this.writeLine();
|
|
6172
|
+
if (await skippedTests.any()) {
|
|
6173
|
+
await this.writeLine(`${this.applyStyle("skipped", "Skipped Tests")}:`);
|
|
6174
|
+
let counter = 0;
|
|
6175
|
+
for (const skippedTest of skippedTests) {
|
|
6176
|
+
await this.writeString(`${++counter}) `);
|
|
6177
|
+
await this.writeFullTestActionName(skippedTest.getTestAction());
|
|
6178
|
+
await this.writeLine();
|
|
6179
|
+
const skipMessage = skippedTest.getSkipMessage();
|
|
6180
|
+
if (skipMessage) {
|
|
6181
|
+
await this.indent(() => this.writeLine(skipMessage));
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
await this.writeLine();
|
|
6185
|
+
}
|
|
6186
|
+
if (await failedTests.any()) {
|
|
6187
|
+
await this.writeLine(`${this.applyStyle("failed", "Failed Tests")}:`);
|
|
6188
|
+
let counter = 0;
|
|
6189
|
+
for (const failedTest of failedTests) {
|
|
6190
|
+
await this.writeString(`${++counter}) `);
|
|
6191
|
+
await this.writeFullTestActionName(failedTest.getTestAction());
|
|
6192
|
+
await this.writeLine();
|
|
6193
|
+
const testError = failedTest.getTestError();
|
|
6194
|
+
await this.indent(() => this.writeLine(testError.getErrorString(this.getErrorStringOptions)));
|
|
6195
|
+
await this.writeLine();
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
if (passedTestCount > 0) {
|
|
6199
|
+
await this.writeLine(`${this.applyStyle("passed", "Passed")}: ${passedTestCount}`);
|
|
6200
|
+
}
|
|
6201
|
+
if (await skippedTests.any()) {
|
|
6202
|
+
await this.writeLine(`${this.applyStyle("skipped", "Skipped")}: ${skippedTests.getCount().await()}`);
|
|
6203
|
+
}
|
|
6204
|
+
if (await failedTests.any()) {
|
|
6205
|
+
await this.writeLine(`${this.applyStyle("failed", "Failed")}: ${failedTests.getCount().await()}`);
|
|
6206
|
+
}
|
|
6207
|
+
});
|
|
6208
|
+
}
|
|
6209
|
+
};
|
|
6210
|
+
var FlatConsoleTestRunnerUI = class _FlatConsoleTestRunnerUI extends ConsoleTestRunnerUI {
|
|
6211
|
+
constructor() {
|
|
6212
|
+
super();
|
|
6213
|
+
}
|
|
6214
|
+
static create() {
|
|
6215
|
+
return new _FlatConsoleTestRunnerUI();
|
|
6216
|
+
}
|
|
6217
|
+
beforeTest(testAction) {
|
|
6218
|
+
return AsyncResult.create(async () => {
|
|
6219
|
+
await this.writeFullTestActionName(testAction);
|
|
6220
|
+
});
|
|
5459
6221
|
}
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
return _TestRunner.skip(this, shouldSkip, message);
|
|
6222
|
+
};
|
|
6223
|
+
var TreeConsoleTestRunnerUI = class _TreeConsoleTestRunnerUI extends ConsoleTestRunnerUI {
|
|
6224
|
+
testActions;
|
|
6225
|
+
testActionWrittenDepth;
|
|
6226
|
+
constructor() {
|
|
6227
|
+
super();
|
|
6228
|
+
this.testActions = List.create();
|
|
6229
|
+
this.testActionWrittenDepth = 0;
|
|
5469
6230
|
}
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
* @param shouldSkip Whether these tests should be skipped.
|
|
5473
|
-
* @param message The message that explains why the tests are being skipped.
|
|
5474
|
-
*/
|
|
5475
|
-
static skip(_runner, shouldSkip, message) {
|
|
5476
|
-
return TestSkip.create(shouldSkip, message);
|
|
6231
|
+
static create() {
|
|
6232
|
+
return new _TreeConsoleTestRunnerUI();
|
|
5477
6233
|
}
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
}
|
|
5482
|
-
runner.test(name, skip, testAction);
|
|
5483
|
-
}
|
|
6234
|
+
beforeTestGroup(testGroup) {
|
|
6235
|
+
return AsyncResult.create(() => {
|
|
6236
|
+
this.testActions.add(testGroup);
|
|
6237
|
+
});
|
|
5484
6238
|
}
|
|
5485
|
-
|
|
5486
|
-
|
|
6239
|
+
afterTestGroup(testGroup) {
|
|
6240
|
+
PreCondition.assertNotUndefinedAndNotNull(testGroup, "testGroup");
|
|
6241
|
+
PreCondition.assertTrue(this.testActions.any().await(), "this.testActions.any().await()");
|
|
6242
|
+
return AsyncResult.create(() => {
|
|
6243
|
+
this.testActions.removeLast().await();
|
|
6244
|
+
const testActionCount = this.testActions.getCount().await();
|
|
6245
|
+
if (this.testActionWrittenDepth > testActionCount) {
|
|
6246
|
+
this.testActionWrittenDepth--;
|
|
6247
|
+
this.removeIndentation();
|
|
6248
|
+
}
|
|
6249
|
+
});
|
|
5487
6250
|
}
|
|
5488
|
-
|
|
5489
|
-
* Create a test group that will test the provided file.
|
|
5490
|
-
* @param runner The {@link TestRunner} that will run the tests.
|
|
5491
|
-
* @param fileName The name of the file that is being tested.
|
|
5492
|
-
* @param testAction The action that will run the tests.
|
|
5493
|
-
*/
|
|
5494
|
-
static testFile(runner, fileName, skipOrTestAction, testAction) {
|
|
5495
|
-
PreCondition.assertNotUndefinedAndNotNull(runner, "runner");
|
|
5496
|
-
PreCondition.assertNotUndefinedAndNotNull(fileName, "fileName");
|
|
5497
|
-
PreCondition.assertNotEmpty(fileName, "fileName");
|
|
5498
|
-
let skip;
|
|
5499
|
-
if (isFunction(skipOrTestAction)) {
|
|
5500
|
-
PreCondition.assertUndefined(testAction, "testAction");
|
|
5501
|
-
skip = void 0;
|
|
5502
|
-
testAction = skipOrTestAction;
|
|
5503
|
-
} else {
|
|
5504
|
-
skip = skipOrTestAction;
|
|
5505
|
-
}
|
|
6251
|
+
beforeTest(testAction) {
|
|
5506
6252
|
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
5507
|
-
|
|
6253
|
+
return AsyncResult.create(async () => {
|
|
6254
|
+
const testActionCount = this.testActions.getCount().await();
|
|
6255
|
+
while (this.testActionWrittenDepth < testActionCount) {
|
|
6256
|
+
const testGroup = this.testActions.get(this.testActionWrittenDepth).await();
|
|
6257
|
+
await this.writeTestActionName(testGroup);
|
|
6258
|
+
await this.writeLine();
|
|
6259
|
+
this.addIndentation();
|
|
6260
|
+
this.testActionWrittenDepth++;
|
|
6261
|
+
}
|
|
6262
|
+
await this.writeTestActionName(testAction);
|
|
6263
|
+
});
|
|
5508
6264
|
}
|
|
5509
|
-
|
|
5510
|
-
|
|
6265
|
+
};
|
|
6266
|
+
|
|
6267
|
+
// tests/AssertTestCreator.ts
|
|
6268
|
+
var AssertTestCreator = class _AssertTestCreator {
|
|
6269
|
+
constructor() {
|
|
6270
|
+
}
|
|
6271
|
+
static create() {
|
|
6272
|
+
return new _AssertTestCreator();
|
|
6273
|
+
}
|
|
6274
|
+
createTest() {
|
|
6275
|
+
return AssertTest.create();
|
|
5511
6276
|
}
|
|
6277
|
+
};
|
|
6278
|
+
|
|
6279
|
+
// tests/TestCreator.ts
|
|
6280
|
+
var TestCreator = class {
|
|
5512
6281
|
/**
|
|
5513
|
-
* Create
|
|
5514
|
-
* @param runner The {@link TestRunner} that will run the tests.
|
|
5515
|
-
* @param type The {@link Type} or name of the type that is being tested.
|
|
5516
|
-
* @param testAction The action that will run the tests.
|
|
6282
|
+
* Create the default {@link TestCreator}.
|
|
5517
6283
|
*/
|
|
5518
|
-
static
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
6284
|
+
static create() {
|
|
6285
|
+
return AssertTestCreator.create();
|
|
6286
|
+
}
|
|
6287
|
+
};
|
|
6288
|
+
|
|
6289
|
+
// tests/BasicTestError.ts
|
|
6290
|
+
var import_url = require("url");
|
|
6291
|
+
var import_path = __toESM(require("path"), 1);
|
|
6292
|
+
var BasicTestError = class _BasicTestError {
|
|
6293
|
+
error;
|
|
6294
|
+
constructor(error) {
|
|
6295
|
+
PreCondition.assertNotUndefinedAndNotNull(error, "error");
|
|
6296
|
+
this.error = error;
|
|
6297
|
+
}
|
|
6298
|
+
static create(error) {
|
|
6299
|
+
return new _BasicTestError(error);
|
|
6300
|
+
}
|
|
6301
|
+
getError() {
|
|
6302
|
+
return this.error;
|
|
6303
|
+
}
|
|
6304
|
+
getErrorString(options) {
|
|
6305
|
+
let result = this.error instanceof Error && this.error.stack ? this.error.stack : `${this.error}`;
|
|
6306
|
+
const currentFolderPath = process.cwd();
|
|
6307
|
+
if (options?.removeNonProjectPaths ?? false) {
|
|
6308
|
+
result = _BasicTestError.removeNonProjectPaths(result, currentFolderPath);
|
|
5526
6309
|
}
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
if (isFunction(skipOrTestAction)) {
|
|
5530
|
-
PreCondition.assertUndefined(testAction, "testAction");
|
|
5531
|
-
skip = void 0;
|
|
5532
|
-
testAction = skipOrTestAction;
|
|
5533
|
-
} else {
|
|
5534
|
-
skip = skipOrTestAction;
|
|
6310
|
+
if (options?.relativeFilePaths ?? false) {
|
|
6311
|
+
result = _BasicTestError.makeFilePathsRelative(result, currentFolderPath);
|
|
5535
6312
|
}
|
|
5536
|
-
|
|
5537
|
-
_TestRunner.runTestAction(runner, typeName, skip, testAction);
|
|
6313
|
+
return result;
|
|
5538
6314
|
}
|
|
5539
|
-
|
|
5540
|
-
|
|
6315
|
+
static removeNonProjectPaths(errorString, currentFolderPath) {
|
|
6316
|
+
currentFolderPath = currentFolderPath.replaceAll("\\", "/");
|
|
6317
|
+
return errorString.split("\n").filter((line) => {
|
|
6318
|
+
let keepLine = false;
|
|
6319
|
+
const trimmedLine = line.trim();
|
|
6320
|
+
const match = trimmedLine.match(/^at .* \((.+)\)$/) ?? trimmedLine.match(/^at (.+)$/);
|
|
6321
|
+
if (!match) {
|
|
6322
|
+
keepLine = true;
|
|
6323
|
+
} else {
|
|
6324
|
+
const location = match[1];
|
|
6325
|
+
try {
|
|
6326
|
+
const filePath = import_path.default.resolve((0, import_url.fileURLToPath)(location)).replaceAll("\\", "/");
|
|
6327
|
+
keepLine = filePath.startsWith(currentFolderPath);
|
|
6328
|
+
} catch {
|
|
6329
|
+
}
|
|
6330
|
+
}
|
|
6331
|
+
return keepLine;
|
|
6332
|
+
}).join("\n");
|
|
6333
|
+
}
|
|
6334
|
+
static makeFilePathsRelative(errorString, currentFolderPath) {
|
|
6335
|
+
return errorString.split("\n").map((line) => {
|
|
6336
|
+
const match = line.match(/^(\s*)at (.+?) \((.+)\)$/) ?? line.match(/^(\s*)at (.+)$/);
|
|
6337
|
+
if (match) {
|
|
6338
|
+
const hasFunctionName = match.length === 4;
|
|
6339
|
+
const indentation = match[1];
|
|
6340
|
+
const functionName = hasFunctionName ? match[2] : void 0;
|
|
6341
|
+
const location = hasFunctionName ? match[3] : match[2];
|
|
6342
|
+
let relativeLocation = location;
|
|
6343
|
+
try {
|
|
6344
|
+
const pathMatch = location.match(/^(.*?):(\d+):(\d+)$/);
|
|
6345
|
+
if (pathMatch) {
|
|
6346
|
+
const fullPath = pathMatch[1];
|
|
6347
|
+
const lineNumber = pathMatch[2];
|
|
6348
|
+
const columnNumber = pathMatch[3];
|
|
6349
|
+
let absolutePath;
|
|
6350
|
+
if (fullPath.startsWith("file:///")) {
|
|
6351
|
+
absolutePath = (0, import_url.fileURLToPath)(fullPath);
|
|
6352
|
+
} else if (/^[A-Za-z]:[\\/]/.test(fullPath) || fullPath.startsWith("/")) {
|
|
6353
|
+
absolutePath = fullPath;
|
|
6354
|
+
}
|
|
6355
|
+
if (absolutePath) {
|
|
6356
|
+
let relativePath = import_path.default.relative(
|
|
6357
|
+
currentFolderPath,
|
|
6358
|
+
absolutePath
|
|
6359
|
+
);
|
|
6360
|
+
relativePath = relativePath.replace(/\\/g, "/");
|
|
6361
|
+
relativeLocation = `${relativePath}:${lineNumber}:${columnNumber}`;
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6364
|
+
} catch {
|
|
6365
|
+
}
|
|
6366
|
+
if (relativeLocation !== location) {
|
|
6367
|
+
if (functionName) {
|
|
6368
|
+
line = `${indentation}at ${functionName} (${relativeLocation})`;
|
|
6369
|
+
} else {
|
|
6370
|
+
line = `${indentation}at ${relativeLocation}`;
|
|
6371
|
+
}
|
|
6372
|
+
}
|
|
6373
|
+
}
|
|
6374
|
+
return line;
|
|
6375
|
+
}).join("\n");
|
|
5541
6376
|
}
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
static
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
_TestRunner.runTestAction(runner, functionSignature, skip, testAction);
|
|
6377
|
+
};
|
|
6378
|
+
|
|
6379
|
+
// tests/BasicTestErrorCreator.ts
|
|
6380
|
+
var BasicTestErrorCreator = class _BasicTestErrorCreator {
|
|
6381
|
+
constructor() {
|
|
6382
|
+
}
|
|
6383
|
+
static create() {
|
|
6384
|
+
return new _BasicTestErrorCreator();
|
|
6385
|
+
}
|
|
6386
|
+
createTestError(error) {
|
|
6387
|
+
return BasicTestError.create(error);
|
|
6388
|
+
}
|
|
6389
|
+
};
|
|
6390
|
+
|
|
6391
|
+
// tests/TestErrorCreator.ts
|
|
6392
|
+
var TestErrorCreator = class {
|
|
6393
|
+
static create() {
|
|
6394
|
+
return BasicTestErrorCreator.create();
|
|
5561
6395
|
}
|
|
5562
6396
|
};
|
|
5563
6397
|
|
|
5564
6398
|
// tests/consoleTestRunner.ts
|
|
5565
|
-
var ConsoleTestRunner = class _ConsoleTestRunner
|
|
6399
|
+
var ConsoleTestRunner = class _ConsoleTestRunner {
|
|
5566
6400
|
writeStream;
|
|
5567
|
-
|
|
5568
|
-
|
|
6401
|
+
testActions;
|
|
6402
|
+
testActionInsertIndex;
|
|
5569
6403
|
currentTestAction;
|
|
5570
6404
|
currentTest;
|
|
5571
6405
|
passedTestCount;
|
|
5572
6406
|
skippedTests;
|
|
5573
6407
|
testFailures;
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
this.
|
|
6408
|
+
testCreator;
|
|
6409
|
+
testErrorCreator;
|
|
6410
|
+
ui;
|
|
6411
|
+
constructor(testCreator, testErrorCreator, ui) {
|
|
6412
|
+
this.writeStream = IndentedCharacterWriteStream.create(NodeJSCharacterWriteStream.create(process.stdout));
|
|
6413
|
+
this.testActions = List.create();
|
|
6414
|
+
this.testActionInsertIndex = 0;
|
|
5579
6415
|
this.passedTestCount = 0;
|
|
5580
6416
|
this.skippedTests = List.create();
|
|
5581
6417
|
this.testFailures = List.create();
|
|
6418
|
+
this.testCreator = testCreator || TestCreator.create();
|
|
6419
|
+
this.testErrorCreator = testErrorCreator || TestErrorCreator.create();
|
|
6420
|
+
this.ui = ui || ConsoleTestRunnerUI.tree();
|
|
6421
|
+
this.ui.setWriteStream(this.writeStream);
|
|
5582
6422
|
}
|
|
5583
|
-
static create() {
|
|
5584
|
-
return new _ConsoleTestRunner();
|
|
6423
|
+
static create(testCreator, testErrorCreator, ui) {
|
|
6424
|
+
return new _ConsoleTestRunner(testCreator, testErrorCreator, ui);
|
|
5585
6425
|
}
|
|
5586
6426
|
static run(testFunctionOrTestFunctions) {
|
|
5587
6427
|
let testFunction;
|
|
@@ -5602,7 +6442,15 @@ var ConsoleTestRunner = class _ConsoleTestRunner extends TestRunner {
|
|
|
5602
6442
|
};
|
|
5603
6443
|
}
|
|
5604
6444
|
return CurrentProcess.run(async (currentProcess) => {
|
|
5605
|
-
const runner = _ConsoleTestRunner.create().setWriteStream(currentProcess.getOutputWriteStream())
|
|
6445
|
+
const runner = _ConsoleTestRunner.create().setWriteStream(currentProcess.getOutputWriteStream()).setStyles({
|
|
6446
|
+
file: (t) => ANSIStyles.blue(t),
|
|
6447
|
+
function: (t) => ANSIStyles.blue(t),
|
|
6448
|
+
type: (t) => ANSIStyles.blue(t),
|
|
6449
|
+
group: (t) => ANSIStyles.blue(t),
|
|
6450
|
+
passed: (t) => ANSIStyles.green(`\u2713 ${t}`),
|
|
6451
|
+
skipped: (t) => ANSIStyles.yellow(`\u25CC ${t}`),
|
|
6452
|
+
failed: (t) => ANSIStyles.red(`\u2717 ${t}`)
|
|
6453
|
+
});
|
|
5606
6454
|
await testFunction(runner);
|
|
5607
6455
|
await runner.runAsync();
|
|
5608
6456
|
await runner.printSummary();
|
|
@@ -5610,21 +6458,50 @@ var ConsoleTestRunner = class _ConsoleTestRunner extends TestRunner {
|
|
|
5610
6458
|
}
|
|
5611
6459
|
setWriteStream(writeStream) {
|
|
5612
6460
|
PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
|
|
5613
|
-
this.writeStream = writeStream;
|
|
6461
|
+
this.writeStream = IndentedCharacterWriteStream.create(writeStream);
|
|
6462
|
+
this.ui.setWriteStream(this.writeStream);
|
|
6463
|
+
return this;
|
|
6464
|
+
}
|
|
6465
|
+
setStyle(style, styleFunction) {
|
|
6466
|
+
this.ui.setStyle(style, styleFunction);
|
|
6467
|
+
return this;
|
|
6468
|
+
}
|
|
6469
|
+
setStyles(styles) {
|
|
6470
|
+
this.ui.setStyles(styles);
|
|
6471
|
+
return this;
|
|
6472
|
+
}
|
|
6473
|
+
setGetErrorStringOptions(options) {
|
|
6474
|
+
this.ui.setGetErrorStringOptions(options);
|
|
5614
6475
|
return this;
|
|
5615
6476
|
}
|
|
5616
6477
|
/**
|
|
5617
6478
|
* Get the number of {@link TestAction}s that have yet to be executed.
|
|
5618
6479
|
*/
|
|
5619
|
-
|
|
5620
|
-
return this.
|
|
6480
|
+
getTestActionCount() {
|
|
6481
|
+
return this.testActions.getCount().await();
|
|
5621
6482
|
}
|
|
5622
6483
|
/**
|
|
5623
|
-
* Get the index in the
|
|
6484
|
+
* Get the index in the {@link TestAction} list that new {@link TestAction}s will be
|
|
5624
6485
|
* inserted at.
|
|
5625
6486
|
*/
|
|
5626
|
-
|
|
5627
|
-
return this.
|
|
6487
|
+
getTestActionInsertIndex() {
|
|
6488
|
+
return this.testActionInsertIndex;
|
|
6489
|
+
}
|
|
6490
|
+
resetTestActionInsertIndex() {
|
|
6491
|
+
this.testActionInsertIndex = 0;
|
|
6492
|
+
}
|
|
6493
|
+
insertTestAction(testActionName, testActionType, skip, action) {
|
|
6494
|
+
const parentTestAction = this.getCurrentTestAction();
|
|
6495
|
+
const testAction = TestAction.create(parentTestAction, testActionName, testActionType, skip, async () => {
|
|
6496
|
+
try {
|
|
6497
|
+
await action();
|
|
6498
|
+
} catch (error) {
|
|
6499
|
+
const testError = this.testErrorCreator.createTestError(error);
|
|
6500
|
+
await this.afterFailedTest(testAction, testError);
|
|
6501
|
+
}
|
|
6502
|
+
});
|
|
6503
|
+
this.testActions.insert(this.testActionInsertIndex, testAction);
|
|
6504
|
+
this.testActionInsertIndex++;
|
|
5628
6505
|
}
|
|
5629
6506
|
/**
|
|
5630
6507
|
* Get the number of tests that have been skipped.
|
|
@@ -5658,37 +6535,103 @@ var ConsoleTestRunner = class _ConsoleTestRunner extends TestRunner {
|
|
|
5658
6535
|
return this.currentTest;
|
|
5659
6536
|
}
|
|
5660
6537
|
assertNoCurrentTest() {
|
|
5661
|
-
if (this.currentTest
|
|
6538
|
+
if (this.currentTest) {
|
|
5662
6539
|
this.currentTest.fail("Can't start a new test group or a new test while running a test.");
|
|
5663
6540
|
}
|
|
5664
6541
|
}
|
|
5665
|
-
|
|
5666
|
-
return
|
|
5667
|
-
await this.writeStream.writeString(join(" ", fullTestNameParts));
|
|
5668
|
-
});
|
|
6542
|
+
beforeTestGroup(testAction) {
|
|
6543
|
+
return this.ui.beforeTestGroup(testAction);
|
|
5669
6544
|
}
|
|
5670
|
-
|
|
5671
|
-
return
|
|
5672
|
-
|
|
6545
|
+
afterTestGroup(testAction) {
|
|
6546
|
+
return this.ui.afterTestGroup(testAction);
|
|
6547
|
+
}
|
|
6548
|
+
beforeTest(testAction) {
|
|
6549
|
+
return this.ui.beforeTest(testAction);
|
|
6550
|
+
}
|
|
6551
|
+
afterPassedTest(testAction) {
|
|
6552
|
+
return AsyncResult.create(async () => {
|
|
6553
|
+
await this.ui.afterPassedTest(testAction);
|
|
5673
6554
|
this.passedTestCount++;
|
|
5674
6555
|
});
|
|
5675
6556
|
}
|
|
5676
|
-
afterSkippedTest(
|
|
5677
|
-
PreCondition.
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
this.skippedTests.add(SkippedTest.create(skip,
|
|
5681
|
-
await this.writeStream.writeLine(" - Skipped");
|
|
6557
|
+
afterSkippedTest(testAction, skip) {
|
|
6558
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
6559
|
+
return AsyncResult.create(async () => {
|
|
6560
|
+
await this.ui.afterSkippedTest(testAction, skip);
|
|
6561
|
+
this.skippedTests.add(SkippedTest.create(skip, testAction));
|
|
5682
6562
|
});
|
|
5683
6563
|
}
|
|
5684
|
-
afterFailedTest(
|
|
5685
|
-
PreCondition.
|
|
6564
|
+
afterFailedTest(testAction, error) {
|
|
6565
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
5686
6566
|
PreCondition.assertNotUndefinedAndNotNull(error, "error");
|
|
5687
|
-
return
|
|
5688
|
-
this.
|
|
5689
|
-
|
|
6567
|
+
return AsyncResult.create(async () => {
|
|
6568
|
+
await this.ui.afterFailedTest(testAction, error);
|
|
6569
|
+
this.testFailures.add(FailedTest.create(testAction, error));
|
|
5690
6570
|
});
|
|
5691
6571
|
}
|
|
6572
|
+
andList(values) {
|
|
6573
|
+
return TestRunner.andList(this, values);
|
|
6574
|
+
}
|
|
6575
|
+
toString(value) {
|
|
6576
|
+
return TestRunner.toString(this, value);
|
|
6577
|
+
}
|
|
6578
|
+
skip(messageOrShouldSkip, message) {
|
|
6579
|
+
let shouldSkip;
|
|
6580
|
+
if (!isBoolean(messageOrShouldSkip)) {
|
|
6581
|
+
shouldSkip = true;
|
|
6582
|
+
message = messageOrShouldSkip;
|
|
6583
|
+
} else {
|
|
6584
|
+
shouldSkip = messageOrShouldSkip;
|
|
6585
|
+
}
|
|
6586
|
+
return TestRunner.skip(this, shouldSkip, message);
|
|
6587
|
+
}
|
|
6588
|
+
testFile(fileName, skipOrTestAction, testAction) {
|
|
6589
|
+
PreCondition.assertNotUndefinedAndNotNull(fileName, "fileName");
|
|
6590
|
+
PreCondition.assertNotEmpty(fileName, "fileName");
|
|
6591
|
+
let skip;
|
|
6592
|
+
if (isFunction(skipOrTestAction)) {
|
|
6593
|
+
PreCondition.assertUndefined(testAction, "testAction");
|
|
6594
|
+
skip = void 0;
|
|
6595
|
+
testAction = skipOrTestAction;
|
|
6596
|
+
} else {
|
|
6597
|
+
skip = skipOrTestAction;
|
|
6598
|
+
}
|
|
6599
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
6600
|
+
this.testGroupOrTest(fileName, "file", skip, testAction);
|
|
6601
|
+
}
|
|
6602
|
+
testType(typeNameOrType, skipOrTestAction, testAction) {
|
|
6603
|
+
PreCondition.assertNotUndefinedAndNotNull(typeNameOrType, "typeNameOrType");
|
|
6604
|
+
let typeName;
|
|
6605
|
+
if (isString(typeNameOrType)) {
|
|
6606
|
+
typeName = typeNameOrType;
|
|
6607
|
+
} else {
|
|
6608
|
+
typeName = getName(typeNameOrType);
|
|
6609
|
+
}
|
|
6610
|
+
PreCondition.assertNotEmpty(typeName, "typeName");
|
|
6611
|
+
let skip;
|
|
6612
|
+
if (isFunction(skipOrTestAction)) {
|
|
6613
|
+
PreCondition.assertUndefined(testAction, "testAction");
|
|
6614
|
+
skip = void 0;
|
|
6615
|
+
testAction = skipOrTestAction;
|
|
6616
|
+
} else {
|
|
6617
|
+
skip = skipOrTestAction;
|
|
6618
|
+
}
|
|
6619
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
6620
|
+
this.testGroupOrTest(typeName, "type", skip, testAction);
|
|
6621
|
+
}
|
|
6622
|
+
testFunction(functionSignature, skipOrTestAction, testAction) {
|
|
6623
|
+
PreCondition.assertNotEmpty(functionSignature, "functionSignature");
|
|
6624
|
+
let skip;
|
|
6625
|
+
if (isFunction(skipOrTestAction)) {
|
|
6626
|
+
PreCondition.assertUndefined(testAction, "testAction");
|
|
6627
|
+
skip = void 0;
|
|
6628
|
+
testAction = skipOrTestAction;
|
|
6629
|
+
} else {
|
|
6630
|
+
skip = skipOrTestAction;
|
|
6631
|
+
}
|
|
6632
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
6633
|
+
this.testGroupOrTest(functionSignature, "function", skip, testAction);
|
|
6634
|
+
}
|
|
5692
6635
|
testGroup(testGroupName, skipOrTestAction, testAction) {
|
|
5693
6636
|
PreCondition.assertNotUndefinedAndNotNull(testGroupName, "testGroupName");
|
|
5694
6637
|
PreCondition.assertNotEmpty(testGroupName, "testGroupName");
|
|
@@ -5701,27 +6644,7 @@ var ConsoleTestRunner = class _ConsoleTestRunner extends TestRunner {
|
|
|
5701
6644
|
skip = skipOrTestAction;
|
|
5702
6645
|
}
|
|
5703
6646
|
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
5704
|
-
this.
|
|
5705
|
-
this.pendingActions.insert(
|
|
5706
|
-
this.pendingActionsInsertIndex,
|
|
5707
|
-
TestAction.create(
|
|
5708
|
-
this.getCurrentTestAction(),
|
|
5709
|
-
testGroupName,
|
|
5710
|
-
skip,
|
|
5711
|
-
async () => {
|
|
5712
|
-
const previousTestActionInsertIndex = this.pendingActionsInsertIndex;
|
|
5713
|
-
this.pendingActionsInsertIndex = this.pendingActions.getCount().await();
|
|
5714
|
-
const currentTestAction = this.getCurrentTestAction();
|
|
5715
|
-
try {
|
|
5716
|
-
await testAction();
|
|
5717
|
-
} catch (error) {
|
|
5718
|
-
await this.afterFailedTest(currentTestAction.getFullNameParts(), error);
|
|
5719
|
-
} finally {
|
|
5720
|
-
this.pendingActionsInsertIndex = previousTestActionInsertIndex;
|
|
5721
|
-
}
|
|
5722
|
-
}
|
|
5723
|
-
)
|
|
5724
|
-
);
|
|
6647
|
+
this.innerTestGroup(testGroupName, "group", skip, testAction);
|
|
5725
6648
|
}
|
|
5726
6649
|
test(testName, skipOrTestAction, testAction) {
|
|
5727
6650
|
PreCondition.assertNotUndefinedAndNotNull(testName, "testName");
|
|
@@ -5735,85 +6658,81 @@ var ConsoleTestRunner = class _ConsoleTestRunner extends TestRunner {
|
|
|
5735
6658
|
skip = skipOrTestAction;
|
|
5736
6659
|
}
|
|
5737
6660
|
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
6661
|
+
this.innerTest(testName, "test", skip, testAction);
|
|
6662
|
+
}
|
|
6663
|
+
innerTestGroup(testGroupName, type, skip, testGroupAction) {
|
|
6664
|
+
PreCondition.assertNotEmpty(testGroupName, "testGroupName");
|
|
6665
|
+
PreCondition.assertNotUndefinedAndNotNull(testGroupAction, "testGroupAction");
|
|
6666
|
+
this.assertNoCurrentTest();
|
|
6667
|
+
this.insertTestAction(
|
|
6668
|
+
testGroupName,
|
|
6669
|
+
type,
|
|
6670
|
+
skip,
|
|
6671
|
+
() => this.beforeTestGroup(this.getCurrentTestAction())
|
|
6672
|
+
);
|
|
6673
|
+
this.insertTestAction(
|
|
6674
|
+
testGroupName,
|
|
6675
|
+
type,
|
|
6676
|
+
skip,
|
|
6677
|
+
async () => {
|
|
6678
|
+
this.resetTestActionInsertIndex();
|
|
6679
|
+
await testGroupAction();
|
|
6680
|
+
}
|
|
6681
|
+
);
|
|
6682
|
+
this.insertTestAction(
|
|
6683
|
+
testGroupName,
|
|
6684
|
+
type,
|
|
6685
|
+
skip,
|
|
6686
|
+
() => this.afterTestGroup(this.getCurrentTestAction())
|
|
6687
|
+
);
|
|
6688
|
+
}
|
|
6689
|
+
innerTest(testName, testType, skip, testAction) {
|
|
6690
|
+
PreCondition.assertNotEmpty(testName, "testName");
|
|
6691
|
+
PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
|
|
5738
6692
|
this.assertNoCurrentTest();
|
|
5739
|
-
this.
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
6693
|
+
this.insertTestAction(
|
|
6694
|
+
testName,
|
|
6695
|
+
testType,
|
|
6696
|
+
skip,
|
|
6697
|
+
async () => {
|
|
6698
|
+
const currentTestAction = this.getCurrentTestAction();
|
|
6699
|
+
await this.beforeTest(currentTestAction);
|
|
6700
|
+
const skip2 = currentTestAction.getSkip();
|
|
6701
|
+
if (skip2?.getShouldSkip()) {
|
|
6702
|
+
await this.afterSkippedTest(currentTestAction, skip2);
|
|
6703
|
+
} else {
|
|
6704
|
+
this.currentTest = this.testCreator.createTest();
|
|
5747
6705
|
try {
|
|
5748
|
-
await this.
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
} else {
|
|
5752
|
-
this.currentTest = AssertTest.create(testName);
|
|
5753
|
-
try {
|
|
5754
|
-
await testAction(this.currentTest);
|
|
5755
|
-
await this.afterPassedTest();
|
|
5756
|
-
} finally {
|
|
5757
|
-
this.currentTest = void 0;
|
|
5758
|
-
}
|
|
5759
|
-
}
|
|
5760
|
-
} catch (error) {
|
|
5761
|
-
await this.afterFailedTest(currentTestAction.getFullNameParts(), error);
|
|
6706
|
+
await testAction(this.currentTest);
|
|
6707
|
+
} finally {
|
|
6708
|
+
this.currentTest = void 0;
|
|
5762
6709
|
}
|
|
6710
|
+
await this.afterPassedTest(currentTestAction);
|
|
5763
6711
|
}
|
|
5764
|
-
|
|
6712
|
+
}
|
|
5765
6713
|
);
|
|
5766
6714
|
}
|
|
6715
|
+
testGroupOrTest(name, type, skip, testAction) {
|
|
6716
|
+
if (getParameterCount(testAction) === 0) {
|
|
6717
|
+
this.innerTestGroup(name, type, skip, testAction);
|
|
6718
|
+
} else {
|
|
6719
|
+
this.innerTest(name, type, skip, testAction);
|
|
6720
|
+
}
|
|
6721
|
+
}
|
|
5767
6722
|
async runAsync() {
|
|
5768
|
-
while (this.
|
|
5769
|
-
this.
|
|
6723
|
+
while (this.testActions.any().await()) {
|
|
6724
|
+
this.resetTestActionInsertIndex();
|
|
6725
|
+
this.currentTestAction = this.testActions.removeFirst().await();
|
|
5770
6726
|
try {
|
|
5771
|
-
|
|
5772
|
-
if (isPromise(result)) {
|
|
5773
|
-
await result;
|
|
5774
|
-
}
|
|
6727
|
+
await this.currentTestAction.runAsync();
|
|
5775
6728
|
} finally {
|
|
5776
6729
|
this.currentTestAction = void 0;
|
|
5777
6730
|
}
|
|
5778
6731
|
}
|
|
6732
|
+
this.resetTestActionInsertIndex();
|
|
5779
6733
|
}
|
|
5780
6734
|
printSummary() {
|
|
5781
|
-
return
|
|
5782
|
-
await this.writeStream.writeLine();
|
|
5783
|
-
const skippedTests = this.getSkippedTests();
|
|
5784
|
-
if (await skippedTests.any()) {
|
|
5785
|
-
await this.writeStream.writeLine(`Skipped Tests:`);
|
|
5786
|
-
let counter = 0;
|
|
5787
|
-
for (const skippedTest of skippedTests) {
|
|
5788
|
-
await this.writeStream.writeLine(`${++counter}) ${skippedTest.getFullTestName()}`);
|
|
5789
|
-
const skipMessage = skippedTest.getSkipMessage();
|
|
5790
|
-
if (skipMessage) {
|
|
5791
|
-
await this.writeStream.writeLine(` ${skipMessage}`);
|
|
5792
|
-
}
|
|
5793
|
-
}
|
|
5794
|
-
await this.writeStream.writeLine();
|
|
5795
|
-
}
|
|
5796
|
-
const failedTests = this.getFailedTests();
|
|
5797
|
-
if (await failedTests.any()) {
|
|
5798
|
-
await this.writeStream.writeLine("Failed Tests:");
|
|
5799
|
-
let counter = 0;
|
|
5800
|
-
for (const failedTest of failedTests) {
|
|
5801
|
-
await this.writeStream.writeLine(`${++counter}) ${failedTest.getFullTestName()}`);
|
|
5802
|
-
await this.writeStream.writeLine(` ${failedTest.getErrorMessage()}`);
|
|
5803
|
-
await this.writeStream.writeLine();
|
|
5804
|
-
}
|
|
5805
|
-
}
|
|
5806
|
-
const passedTestCount = this.getPassedTestCount();
|
|
5807
|
-
if (passedTestCount > 0) {
|
|
5808
|
-
await this.writeStream.writeLine(`Passed: ${passedTestCount}`);
|
|
5809
|
-
}
|
|
5810
|
-
if (await skippedTests.any()) {
|
|
5811
|
-
await this.writeStream.writeLine(`Skipped: ${skippedTests.getCount().await()}`);
|
|
5812
|
-
}
|
|
5813
|
-
if (await failedTests.any()) {
|
|
5814
|
-
await this.writeStream.writeLine(`Failed: ${failedTests.getCount().await()}`);
|
|
5815
|
-
}
|
|
5816
|
-
});
|
|
6735
|
+
return this.ui.writeSummary(this.passedTestCount, this.getSkippedTests(), this.getFailedTests());
|
|
5817
6736
|
}
|
|
5818
6737
|
};
|
|
5819
6738
|
// Annotate the CommonJS export names for ESM import in node:
|