forked from Svehla/ts-generics-RegEx-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
101 lines (83 loc) · 1.61 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import {DebugTest, Test} from "./index";
/**
* Successful tests
*/
/**
* Exact match
*/
// $ExpectType true
type T1 = Test<'hello', 'hello'>
// $ExpectType false
type T2 = Test<'goodbye', 'hello'>
/**
* Any character
*/
// $ExpectType true
type AC1 = Test<'.', '4'>
// $ExpectType false
type AC2 = Test<'.', ''>
/**
* Zero or one
*/
// $ExpectType true
type ZOO1 = Test<'2?', '2'>
// $ExpectType true
type ZOO2 = Test<'2?', ''>
// $ExpectType false
type ZOO3 = Test<'2?', '3'>
/**
* Zero Or More
*/
// $ExpectType true
type ZOM1 = Test<'1*', '111'>
// $ExpectType true
type ZOM2 = Test<'1*', '1'>
// $ExpectType true
type ZOM3 = Test<'1*', ''>
// $ExpectType false
type ZOM4 = Test<'1*', '2'>
/**
* One Or More
*/
// $ExpectType true
type OOM1 = Test<'4+', '444'>
// $ExpectType true
type OOM2 = Test<'4+', '4'>
// $ExpectType false
type OOM3 = Test<'4+', ''>
// $ExpectType false
type OOM4 = Test<'4+', '8'>
/**
* Group tests
*/
// $ExpectType true
type GRP1 = Test<'(2)', '2'>
// $ExpectType false
type GRP2 = Test<'(2)', ''>
/**
* Escape character
*/
// $ExpectType true
type EC1 = Test<'\\\\', '\\'>;
// $ExpectType true
type EC2 = Test<'\\(', '('>
// $ExpectType false
type EC3 = Test<'\\)', '('>
/**
* Complex tests
*/
// $ExpectType true
type T3123 = Test<'a?(b(xy)*c)*c', 'abxyxycc'>
// $ExpectType true
type T4123123 = Test<'(\\(\\.\\))*', '(.)(.)(.)'>
/**
* Debug tests - just test to make sure no errors
*/
type DEBUG1 = DebugTest<'a?(b(zz)*c)+(zy)+x', 'bzzzzzzcbcbczyx'>
/**
* Partial matches
*/
// $ExpectType false
type T1000 = Test<'h', 'hello'>
// $ExpectType false
type FT2 = Test<'.', '44'>