@litert/typeguard 1.4.0 → 1.4.1

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.
@@ -1,794 +0,0 @@
1
- /**
2
- * Copyright 2023 Angus Fenying <fenying@litert.org>
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import { createTestDefinition, defaultItems, ITestSuite } from './abstracts';
18
-
19
- const testItems: ITestSuite = {
20
-
21
- name: 'String Asserts',
22
- sections: [
23
- {
24
- 'name': 'Operator ==',
25
- 'rule': '==aasdsadsada',
26
- 'items': [
27
- {
28
- 'title': 'string \'aasdsadsada\'',
29
- 'value': 'aasdsadsada',
30
- 'expect': true
31
- },
32
- {
33
- 'title': 'string \'AASDSADSADA\'',
34
- 'value': 'AASDSADSADA',
35
- 'expect': false
36
- },
37
- ...defaultItems({})
38
- ]
39
- },
40
- {
41
- 'name': 'Operator =',
42
- 'rule': '=aasdsadsada',
43
- 'items': [
44
- {
45
- 'title': 'string \'aasdsadsada\'',
46
- 'value': 'aasdsadsada',
47
- 'expect': true
48
- },
49
- {
50
- 'title': 'string \'AASDSADSADA\'',
51
- 'value': 'AASDSADSADA',
52
- 'expect': false
53
- },
54
- ...defaultItems({})
55
- ]
56
- },
57
- {
58
- 'name': 'Symbol \':equal:\'',
59
- 'rule': ':equal:aasdsadsada',
60
- 'items': [
61
- {
62
- 'title': 'string \'aasdsadsada\'',
63
- 'value': 'aasdsadsada',
64
- 'expect': true
65
- },
66
- {
67
- 'title': 'string \'AASDSADSADA\'',
68
- 'value': 'AASDSADSADA',
69
- 'expect': false
70
- },
71
- ...defaultItems({})
72
- ]
73
- },
74
- {
75
- 'name': 'Symbol \':equal-i:\'',
76
- 'rule': ':equal-i:aasdsadsada',
77
- 'items': [
78
- {
79
- 'title': 'string \'aasdsadsada\'',
80
- 'value': 'aasdsadsada',
81
- 'expect': true
82
- },
83
- {
84
- 'title': 'string \'AASDSADSADA\'',
85
- 'value': 'AASDSADSADA',
86
- 'expect': true
87
- },
88
- ...defaultItems({})
89
- ]
90
- },
91
- {
92
- 'name': 'Operator %=',
93
- 'rule': '%=aasdsadsada',
94
- 'items': [
95
- {
96
- 'title': 'string \'aasdsadsada\'',
97
- 'value': 'aasdsadsada',
98
- 'expect': true
99
- },
100
- {
101
- 'title': 'string \'AASDSADSADA\'',
102
- 'value': 'AASDSADSADA',
103
- 'expect': true
104
- },
105
- ...defaultItems({})
106
- ]
107
- },
108
- {
109
- 'name': 'Operator !=',
110
- 'rule': '!=aasdsadsada',
111
- 'items': [
112
- {
113
- 'title': 'string \'aasdsadsada\'',
114
- 'value': 'aasdsadsada',
115
- 'expect': false
116
- },
117
- {
118
- 'title': 'string \'AASDSADSADA\'',
119
- 'value': 'AASDSADSADA',
120
- 'expect': true
121
- },
122
- ...defaultItems({
123
- 'string \'hello\'': true,
124
- 'empty string': true
125
- })
126
- ]
127
- },
128
- {
129
- 'name': 'Symbol \':not-equal:\'',
130
- 'rule': ':not-equal:aasdsadsada',
131
- 'items': [
132
- {
133
- 'title': 'string \'aasdsadsada\'',
134
- 'value': 'aasdsadsada',
135
- 'expect': false
136
- },
137
- {
138
- 'title': 'string \'AASDSADSADA\'',
139
- 'value': 'AASDSADSADA',
140
- 'expect': true
141
- },
142
- ...defaultItems({
143
- 'string \'hello\'': true,
144
- 'empty string': true
145
- })
146
- ]
147
- },
148
- {
149
- 'name': 'Symbol \':not-equal-i:\'',
150
- 'rule': ':not-equal-i:aasdsadsada',
151
- 'items': [
152
- {
153
- 'title': 'string \'aasdsadsada\'',
154
- 'value': 'aasdsadsada',
155
- 'expect': false
156
- },
157
- {
158
- 'title': 'string \'AASDSADSADA\'',
159
- 'value': 'AASDSADSADA',
160
- 'expect': false
161
- },
162
- ...defaultItems({
163
- 'string \'hello\'': true,
164
- 'empty string': true
165
- })
166
- ]
167
- },
168
- {
169
- 'name': 'Operator %!',
170
- 'rule': '%!aasdsadsada',
171
- 'items': [
172
- {
173
- 'title': 'string \'aasdsadsada\'',
174
- 'value': 'aasdsadsada',
175
- 'expect': false
176
- },
177
- {
178
- 'title': 'string \'AASDSADSADA\'',
179
- 'value': 'AASDSADSADA',
180
- 'expect': false
181
- },
182
- ...defaultItems({
183
- 'string \'hello\'': true,
184
- 'empty string': true
185
- })
186
- ]
187
- },
188
- {
189
- 'name': 'Operator ^=',
190
- 'rule': '^=hello',
191
- 'items': [
192
- {
193
- 'title': 'string \'hello world\'',
194
- 'value': 'hello world',
195
- 'expect': true
196
- },
197
- {
198
- 'title': 'string \'hello world\'',
199
- 'value': 'Hello world',
200
- 'expect': false
201
- },
202
- ...defaultItems({
203
- 'string \'hello\'': true,
204
- 'empty string': false
205
- })
206
- ]
207
- },
208
- {
209
- 'name': 'Symbol \':start-with:\'',
210
- 'rule': ':start-with:hello',
211
- 'items': [
212
- {
213
- 'title': 'string \'hello world\'',
214
- 'value': 'hello world',
215
- 'expect': true
216
- },
217
- {
218
- 'title': 'string \'hello world\'',
219
- 'value': 'Hello world',
220
- 'expect': false
221
- },
222
- ...defaultItems({
223
- 'string \'hello\'': true,
224
- 'empty string': false
225
- })
226
- ]
227
- },
228
- {
229
- 'name': 'Symbol \':start-with-i:\'',
230
- 'rule': ':start-with-i:hello',
231
- 'items': [
232
- {
233
- 'title': 'string \'hello world\'',
234
- 'value': 'hello world',
235
- 'expect': true
236
- },
237
- {
238
- 'title': 'string \'hello world\'',
239
- 'value': 'Hello world',
240
- 'expect': true
241
- },
242
- ...defaultItems({
243
- 'string \'hello\'': true,
244
- 'empty string': false
245
- })
246
- ]
247
- },
248
- {
249
- 'name': 'Operator ^!',
250
- 'rule': '^!hello',
251
- 'items': [
252
- {
253
- 'title': 'string \'hello world\'',
254
- 'value': 'hello world',
255
- 'expect': false
256
- },
257
- {
258
- 'title': 'string \'hello world\'',
259
- 'value': 'Hello world',
260
- 'expect': true
261
- },
262
- ...defaultItems({
263
- 'string \'hello\'': false,
264
- 'empty string': true
265
- })
266
- ]
267
- },
268
- {
269
- 'name': 'Symbol \':not-start-with:\'',
270
- 'rule': ':not-start-with:hello',
271
- 'items': [
272
- {
273
- 'title': 'string \'hello world\'',
274
- 'value': 'hello world',
275
- 'expect': false
276
- },
277
- {
278
- 'title': 'string \'hello world\'',
279
- 'value': 'Hello world',
280
- 'expect': true
281
- },
282
- ...defaultItems({
283
- 'string \'hello\'': false,
284
- 'empty string': true
285
- })
286
- ]
287
- },
288
- {
289
- 'name': 'Symbol \':not-start-with-i:\'',
290
- 'rule': ':not-start-with-i:hello',
291
- 'items': [
292
- {
293
- 'title': 'string \'hello world\'',
294
- 'value': 'hello world',
295
- 'expect': false
296
- },
297
- {
298
- 'title': 'string \'hello world\'',
299
- 'value': 'Hello world',
300
- 'expect': false
301
- },
302
- ...defaultItems({
303
- 'string \'hello\'': false,
304
- 'empty string': true
305
- })
306
- ]
307
- },
308
- {
309
- 'name': 'Operator $=',
310
- 'rule': '$=world',
311
- 'items': [
312
- {
313
- 'title': 'string \'hello world\'',
314
- 'value': 'hello world',
315
- 'expect': true
316
- },
317
- {
318
- 'title': 'string \'hello world\'',
319
- 'value': 'Hello World',
320
- 'expect': false
321
- },
322
- ...defaultItems({
323
- 'string \'hello\'': false,
324
- 'empty string': false
325
- })
326
- ]
327
- },
328
- {
329
- 'name': 'Symbol \':end-with:\'',
330
- 'rule': ':end-with:world',
331
- 'items': [
332
- {
333
- 'title': 'string \'hello world\'',
334
- 'value': 'hello world',
335
- 'expect': true
336
- },
337
- {
338
- 'title': 'string \'hello world\'',
339
- 'value': 'Hello World',
340
- 'expect': false
341
- },
342
- ...defaultItems({
343
- 'string \'hello\'': false,
344
- 'empty string': false
345
- })
346
- ]
347
- },
348
- {
349
- 'name': 'Symbol \':end-with-i:\'',
350
- 'rule': ':end-with-i:world',
351
- 'items': [
352
- {
353
- 'title': 'string \'hello world\'',
354
- 'value': 'hello world',
355
- 'expect': true
356
- },
357
- {
358
- 'title': 'string \'hello world\'',
359
- 'value': 'Hello World',
360
- 'expect': true
361
- },
362
- ...defaultItems({
363
- 'string \'hello\'': false,
364
- 'empty string': false
365
- })
366
- ]
367
- },
368
- {
369
- 'name': 'Operator $!',
370
- 'rule': '$!world',
371
- 'items': [
372
- {
373
- 'title': 'string \'hello world\'',
374
- 'value': 'hello world',
375
- 'expect': false
376
- },
377
- {
378
- 'title': 'string \'hello world\'',
379
- 'value': 'Hello World',
380
- 'expect': true
381
- },
382
- ...defaultItems({
383
- 'string \'hello\'': true,
384
- 'empty string': true
385
- })
386
- ]
387
- },
388
- {
389
- 'name': 'Symbol \':not-end-with:\'',
390
- 'rule': ':not-end-with:world',
391
- 'items': [
392
- {
393
- 'title': 'string \'hello world\'',
394
- 'value': 'hello world',
395
- 'expect': false
396
- },
397
- {
398
- 'title': 'string \'hello world\'',
399
- 'value': 'Hello World',
400
- 'expect': true
401
- },
402
- ...defaultItems({
403
- 'string \'hello\'': true,
404
- 'empty string': true
405
- })
406
- ]
407
- },
408
- {
409
- 'name': 'Symbol \':not-end-with-i:\'',
410
- 'rule': ':not-end-with-i:world',
411
- 'items': [
412
- {
413
- 'title': 'string \'hello world\'',
414
- 'value': 'hello World',
415
- 'expect': false
416
- },
417
- {
418
- 'title': 'string \'hello world\'',
419
- 'value': 'Hello world',
420
- 'expect': false
421
- },
422
- ...defaultItems({
423
- 'string \'hello\'': true,
424
- 'empty string': true
425
- })
426
- ]
427
- },
428
-
429
- /**
430
- * Include
431
- */
432
-
433
- {
434
- 'name': 'Operator ?=',
435
- 'rule': '?=hello',
436
- 'items': [
437
- {
438
- 'title': 'string \'hello world\'',
439
- 'value': 'hello world',
440
- 'expect': true
441
- },
442
- {
443
- 'title': 'string \'hello world\'',
444
- 'value': 'Hello world',
445
- 'expect': false
446
- },
447
- ...defaultItems({
448
- 'string \'hello\'': true,
449
- 'empty string': false
450
- })
451
- ]
452
- },
453
- {
454
- 'name': 'Symbol \':include:\'',
455
- 'rule': ':include:hello',
456
- 'items': [
457
- {
458
- 'title': 'string \'hello world\'',
459
- 'value': 'hello world',
460
- 'expect': true
461
- },
462
- {
463
- 'title': 'string \'hello world\'',
464
- 'value': 'Hello world',
465
- 'expect': false
466
- },
467
- ...defaultItems({
468
- 'string \'hello\'': true,
469
- 'empty string': false
470
- })
471
- ]
472
- },
473
- {
474
- 'name': 'Operator *=',
475
- 'rule': '*=hello',
476
- 'items': [
477
- {
478
- 'title': 'string \'hello world\'',
479
- 'value': 'hello world',
480
- 'expect': true
481
- },
482
- {
483
- 'title': 'string \'hello world\'',
484
- 'value': 'Hello world',
485
- 'expect': true
486
- },
487
- ...defaultItems({
488
- 'string \'hello\'': true,
489
- 'empty string': false
490
- })
491
- ]
492
- },
493
- {
494
- 'name': 'Symbol \':include-i:\'',
495
- 'rule': ':include-i:hello',
496
- 'items': [
497
- {
498
- 'title': 'string \'hello world\'',
499
- 'value': 'hello world',
500
- 'expect': true
501
- },
502
- {
503
- 'title': 'string \'hello world\'',
504
- 'value': 'Hello world',
505
- 'expect': true
506
- },
507
- ...defaultItems({
508
- 'string \'hello\'': true,
509
- 'empty string': false
510
- })
511
- ]
512
- },
513
- {
514
- 'name': 'Operator ?!',
515
- 'rule': '?!hello',
516
- 'items': [
517
- {
518
- 'title': 'string \'hello world\'',
519
- 'value': 'hello world',
520
- 'expect': false
521
- },
522
- {
523
- 'title': 'string \'hello world\'',
524
- 'value': 'Hello world',
525
- 'expect': true
526
- },
527
- ...defaultItems({
528
- 'string \'hello\'': false,
529
- 'empty string': true
530
- })
531
- ]
532
- },
533
- {
534
- 'name': 'Symbol \':not-include:\'',
535
- 'rule': ':not-include:hello',
536
- 'items': [
537
- {
538
- 'title': 'string \'hello world\'',
539
- 'value': 'hello world',
540
- 'expect': false
541
- },
542
- {
543
- 'title': 'string \'hello world\'',
544
- 'value': 'Hello world',
545
- 'expect': true
546
- },
547
- ...defaultItems({
548
- 'string \'hello\'': false,
549
- 'empty string': true
550
- })
551
- ]
552
- },
553
- {
554
- 'name': 'Symbol \':not-include-i:\'',
555
- 'rule': ':not-include-i:hello',
556
- 'items': [
557
- {
558
- 'title': 'string \'hello world\'',
559
- 'value': 'hello world',
560
- 'expect': false
561
- },
562
- {
563
- 'title': 'string \'hello world\'',
564
- 'value': 'Hello world',
565
- 'expect': false
566
- },
567
- ...defaultItems({
568
- 'string \'hello\'': false,
569
- 'empty string': true
570
- })
571
- ]
572
- },
573
- {
574
- 'name': 'Operator *!',
575
- 'rule': '*!hello',
576
- 'items': [
577
- {
578
- 'title': 'string \'hello world\'',
579
- 'value': 'hello world',
580
- 'expect': false
581
- },
582
- {
583
- 'title': 'string \'hello world\'',
584
- 'value': 'Hello world',
585
- 'expect': false
586
- },
587
- ...defaultItems({
588
- 'string \'hello\'': false,
589
- 'empty string': true
590
- })
591
- ]
592
- },
593
- {
594
- 'name': 'Operator ~=/hello/i',
595
- 'rule': '~=/hello/i',
596
- 'items': [
597
- {
598
- 'title': 'string \'hello world\'',
599
- 'value': 'hello world',
600
- 'expect': true
601
- },
602
- {
603
- 'title': 'string \'hello world\'',
604
- 'value': 'Hello world',
605
- 'expect': true
606
- },
607
- {
608
- 'title': 'string \'hi world\'',
609
- 'value': 'hi world',
610
- 'expect': false
611
- },
612
- ...defaultItems({
613
- 'string \'hello\'': true,
614
- 'empty string': false
615
- })
616
- ]
617
- },
618
- {
619
- 'name': 'Operator ~=hello',
620
- 'rule': '~=hello',
621
- 'items': [
622
- {
623
- 'title': 'string \'hello world\'',
624
- 'value': 'hello world',
625
- 'expect': true
626
- },
627
- {
628
- 'title': 'string \'hello world\'',
629
- 'value': 'Hello world',
630
- 'expect': false
631
- },
632
- {
633
- 'title': 'string \'hi world\'',
634
- 'value': 'hi world',
635
- 'expect': false
636
- },
637
- ...defaultItems({
638
- 'string \'hello\'': true,
639
- 'empty string': false
640
- })
641
- ]
642
- },
643
- {
644
- 'name': 'Operator ~/hello/i',
645
- 'rule': '~/hello/i',
646
- 'items': [
647
- {
648
- 'title': 'string \'hello world\'',
649
- 'value': 'hello world',
650
- 'expect': true
651
- },
652
- {
653
- 'title': 'string \'hello world\'',
654
- 'value': 'Hello world',
655
- 'expect': true
656
- },
657
- {
658
- 'title': 'string \'hi world\'',
659
- 'value': 'hi world',
660
- 'expect': false
661
- },
662
- ...defaultItems({
663
- 'string \'hello\'': true,
664
- 'empty string': false
665
- })
666
- ]
667
- },
668
- {
669
- 'name': 'Operator ~hello',
670
- 'rule': '~hello',
671
- 'items': [
672
- {
673
- 'title': 'string \'hello world\'',
674
- 'value': 'hello world',
675
- 'expect': true
676
- },
677
- {
678
- 'title': 'string \'hello world\'',
679
- 'value': 'Hello world',
680
- 'expect': false
681
- },
682
- {
683
- 'title': 'string \'hi world\'',
684
- 'value': 'hi world',
685
- 'expect': false
686
- },
687
- ...defaultItems({
688
- 'string \'hello\'': true,
689
- 'empty string': false
690
- })
691
- ]
692
- },
693
- {
694
- 'name': 'Operator ~!hello',
695
- 'rule': '~!hello',
696
- 'items': [
697
- {
698
- 'title': 'string \'hello world\'',
699
- 'value': 'hello world',
700
- 'expect': false
701
- },
702
- {
703
- 'title': 'string \'hello world\'',
704
- 'value': 'Hello world',
705
- 'expect': true
706
- },
707
- {
708
- 'title': 'string \'hi world\'',
709
- 'value': 'hi world',
710
- 'expect': true
711
- },
712
- ...defaultItems({
713
- 'string \'hello\'': false,
714
- 'empty string': true
715
- })
716
- ]
717
- },
718
- {
719
- 'name': 'Operator ~!/hello/i',
720
- 'rule': '~!/hello/i',
721
- 'items': [
722
- {
723
- 'title': 'string \'hello world\'',
724
- 'value': 'hello world',
725
- 'expect': false
726
- },
727
- {
728
- 'title': 'string \'hello world\'',
729
- 'value': 'Hello world',
730
- 'expect': false
731
- },
732
- {
733
- 'title': 'string \'hi world\'',
734
- 'value': 'hi world',
735
- 'expect': true
736
- },
737
- ...defaultItems({
738
- 'string \'hello\'': false,
739
- 'empty string': true
740
- })
741
- ]
742
- },
743
- {
744
- 'name': 'Operator ~!/hello/i with negative assert shortcut',
745
- 'rule': '!~!/hello/i',
746
- 'items': [
747
- {
748
- 'title': 'string \'hello world\'',
749
- 'value': 'hello world',
750
- 'expect': true
751
- },
752
- {
753
- 'title': 'string \'hello world\'',
754
- 'value': 'Hello world',
755
- 'expect': true
756
- },
757
- {
758
- 'title': 'string \'hi world\'',
759
- 'value': 'hi world',
760
- 'expect': false
761
- },
762
- ...defaultItems({
763
- 'empty string': false
764
- }, true)
765
- ]
766
- },
767
- {
768
- 'name': 'Operator ~!/hello/i with negative assert',
769
- 'rule': ['$.not', '~!/hello/i'],
770
- 'items': [
771
- {
772
- 'title': 'string \'hello world\'',
773
- 'value': 'hello world',
774
- 'expect': true
775
- },
776
- {
777
- 'title': 'string \'hello world\'',
778
- 'value': 'Hello world',
779
- 'expect': true
780
- },
781
- {
782
- 'title': 'string \'hi world\'',
783
- 'value': 'hi world',
784
- 'expect': false
785
- },
786
- ...defaultItems({
787
- 'empty string': false
788
- }, true)
789
- ]
790
- },
791
- ]
792
- };
793
-
794
- export default createTestDefinition(testItems);