Skip to content

Commit 3c95c96

Browse files
committed
group tests to the classes
1 parent 9302319 commit 3c95c96

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/tests.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {e,t} from "./base";
88
declare const regexp1: TypedRegExp<["$1","$2"],{some?:"test group",other?:"more"},"gdi"|"dim">;
99
declare const regexp2: TypedRegExp<["2-$1","2-$2"],undefined>;
1010

11+
// --- TypedRegExp ---
1112
t(regexp1.dotAll)<true>();
1213
t(regexp1.global)<true|false>();
1314
t(regexp1.ignoreCase)<true>();
@@ -25,6 +26,7 @@ t(regexp1[Symbol.replace]("",""))<string>();
2526
t(regexp1[Symbol.replace]("", ( _m: string, _g1: "$1", _g2: "$2", _i: number, _s: string, _g: { some?: "test group", other?: "more" } ) => "" ))<string>();
2627
t(regexp2[Symbol.replace]("", ( _m: string, _g1: "2-$1", _g2: "2-$2", _i: number, _s: string ) => "" ))<string>();
2728

29+
// --- TypedRegExpMatchArray ---
2830
const match = "".match(regexp1);
2931

3032
t(match)<TypedRegExpMatchArray<["$1","$2"],{some?:"test group",other?:"more"}>|null>();
@@ -44,6 +46,16 @@ if (match) {
4446
t(match)<null>();
4547
}
4648

49+
declare const match2: TypedRegExpMatchArray<[],undefined|{some?:"test group",other?:"more"}>;
50+
51+
t(match2.groups)<{some?:"test group",other?:"more"}|undefined>(); // TODO fix never is ignored
52+
if (match2.groups) {
53+
t(match2.groups)<{some?:"test group",other?:"more"}>();
54+
} else {
55+
t(match2.groups)<undefined>();
56+
}
57+
58+
// --- TypedRegExpExecArray ---
4759
const exec = regexp2.exec("exec string");
4860

4961
t(exec)<TypedRegExpExecArray<["2-$1","2-$2"],undefined,"exec string">|null>();
@@ -61,12 +73,3 @@ if (exec) {
6173
} else {
6274
t(exec)<null>();
6375
}
64-
65-
declare const match2: TypedRegExpMatchArray<[],undefined|{some?:"test group",other?:"more"}>;
66-
67-
t(match2.groups)<{some?:"test group",other?:"more"}|undefined>(); // TODO fix never is ignored
68-
if (match2.groups) {
69-
t(match2.groups)<{some?:"test group",other?:"more"}>();
70-
} else {
71-
t(match2.groups)<undefined>();
72-
}

0 commit comments

Comments
 (0)