/
duplicateLocalVariable1.types
1875 lines (1629 loc) · 123 KB
/
duplicateLocalVariable1.types
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=== tests/cases/compiler/duplicateLocalVariable1.ts ===
/ /@module: commonjs
>/ / : RegExp
>module : any
>commonjs : any
//import FileManager = require('filemanager');
//import App = require('app');
declare var FileManager: any;
>FileManager : any
declare var App: any;
>App : any
var TestFileDir = ".\\TempTestFiles";
>TestFileDir : string
>".\\TempTestFiles" : ".\\TempTestFiles"
export class TestCase {
>TestCase : TestCase
constructor (public name: string, public test: ()=>boolean, public errorMessageRegEx?: string) {
>name : string
>test : () => boolean
>errorMessageRegEx : string
}
}
export class TestRunner {
>TestRunner : TestRunner
private tests: TestCase[] = [];
>tests : TestCase[]
>[] : undefined[]
static arrayCompare(arg1: any[], arg2: any[]): boolean {
>arrayCompare : (arg1: any[], arg2: any[]) => boolean
>arg1 : any[]
>arg2 : any[]
return (arg1.every(function (val, index) { return val === arg2[index] }));
>(arg1.every(function (val, index) { return val === arg2[index] })) : boolean
>arg1.every(function (val, index) { return val === arg2[index] }) : boolean
>arg1.every : (callbackfn: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean
>arg1 : any[]
>every : (callbackfn: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean
>function (val, index) { return val === arg2[index] } : (val: any, index: number) => boolean
>val : any
>index : number
>val === arg2[index] : boolean
>val : any
>arg2[index] : any
>arg2 : any[]
>index : number
}
public addTest(test: TestCase) {
>addTest : (test: TestCase) => void
>test : TestCase
this.tests.push(test);
>this.tests.push(test) : number
>this.tests.push : (...items: TestCase[]) => number
>this.tests : TestCase[]
>this : this
>tests : TestCase[]
>push : (...items: TestCase[]) => number
>test : TestCase
}
public run() {
>run : () => void
var success = true;
>success : boolean
>true : true
for (var test in this.tests) {
>test : string
>this.tests : TestCase[]
>this : this
>tests : TestCase[]
var exception = false;
>exception : boolean
>false : false
var testcase = <TestCase>this.tests[test]
>testcase : TestCase
><TestCase>this.tests[test] : TestCase
>this.tests[test] : TestCase
>this.tests : TestCase[]
>this : this
>tests : TestCase[]
>test : string
var testResult: boolean = false;
>testResult : boolean
>false : false
try {
testResult = testcase.test();
>testResult = testcase.test() : boolean
>testResult : boolean
>testcase.test() : boolean
>testcase.test : () => boolean
>testcase : TestCase
>test : () => boolean
}
catch (e) {
>e : any
exception = true;
>exception = true : true
>exception : boolean
>true : true
testResult = false;
>testResult = false : false
>testResult : boolean
>false : false
if (typeof testcase.errorMessageRegEx === "string") {
>typeof testcase.errorMessageRegEx === "string" : boolean
>typeof testcase.errorMessageRegEx : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>testcase.errorMessageRegEx : string
>testcase : TestCase
>errorMessageRegEx : string
>"string" : "string"
if (testcase.errorMessageRegEx === "") { // Any error is fine
>testcase.errorMessageRegEx === "" : boolean
>testcase.errorMessageRegEx : string
>testcase : TestCase
>errorMessageRegEx : string
>"" : ""
testResult = true;
>testResult = true : true
>testResult : boolean
>true : true
} else if (e.message) {
>e.message : any
>e : any
>message : any
var regex = new RegExp(testcase.errorMessageRegEx);
>regex : RegExp
>new RegExp(testcase.errorMessageRegEx) : RegExp
>RegExp : RegExpConstructor
>testcase.errorMessageRegEx : string
>testcase : TestCase
>errorMessageRegEx : string
testResult = regex.test(e.message);
>testResult = regex.test(e.message) : boolean
>testResult : boolean
>regex.test(e.message) : boolean
>regex.test : (string: string) => boolean
>regex : RegExp
>test : (string: string) => boolean
>e.message : any
>e : any
>message : any
}
}
if (testResult === false) {
>testResult === false : boolean
>testResult : boolean
>false : false
//console.log(e.message);
}
}
if ((testcase.errorMessageRegEx !== undefined) && !exception) {
>(testcase.errorMessageRegEx !== undefined) && !exception : boolean
>(testcase.errorMessageRegEx !== undefined) : boolean
>testcase.errorMessageRegEx !== undefined : boolean
>testcase.errorMessageRegEx : string
>testcase : TestCase
>errorMessageRegEx : string
>undefined : undefined
>!exception : boolean
>exception : boolean
success = false;
>success = false : false
>success : boolean
>false : false
} else if (!testResult) {
>!testResult : boolean
>testResult : boolean
success = false;
>success = false : false
>success : boolean
>false : false
}
}
if (success) {
>success : boolean
} else {
}
}
}
export var tests: TestRunner = (function () {
>tests : TestRunner
>(function () { var testRunner = new TestRunner(); // First 3 are for simple harness validation testRunner.addTest(new TestCase("Basic test", function () { return true; })); testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, "")); testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass")); testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); })); testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); })); // File detection tests testRunner.addTest(new TestCase("Check file exists", function () { return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt"); })); testRunner.addTest(new TestCase("Check file doesn't exist", function () { return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt"); })); // File pattern matching tests testRunner.addTest(new TestCase("Check text file match", function () { return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) })); testRunner.addTest(new TestCase("Check makefile match", function () { return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile"); })); testRunner.addTest(new TestCase("Check binary file doesn't match", function () { return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")); })); // Command-line parameter tests testRunner.addTest(new TestCase("Check App defaults", function () { var app = new App.App([]); return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom"); })); testRunner.addTest(new TestCase("Check App params", function () { var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]); return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2); })); // File BOM detection tests testRunner.addTest(new TestCase("Check encoding detection no BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding detection UTF8 BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); return fb.bom === 'utf8' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding detection UTF16be BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt"); return fb.bom === 'utf16be' && fb.encoding === 'utf16be'; })); testRunner.addTest(new TestCase("Check encoding detection UTF16le BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt"); return fb.bom === 'utf16le' && fb.encoding === 'utf16le'; })); testRunner.addTest(new TestCase("Check encoding on 1 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding on 0 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); // UTF8 encoding tests testRunner.addTest(new TestCase("Check byte reader", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 11; i++) { chars.push(fb.readByte()); } return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]); })); testRunner.addTest(new TestCase("Check UTF8 decoding", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 6; i++) { chars.push(fb.readUtf8CodePoint()); } return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]); })); testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb = new FileManager.FileBuffer(20); fb.writeUtf8Bom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; return TestRunner.arrayCompare(bytes, expected); })); // Test reading and writing files testRunner.addTest(new TestCase("Check saving a file", function () { var filename = TestFileDir + "\\tmpUTF16LE.txt"; var fb = new FileManager.FileBuffer(14); fb.writeUtf16leBom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; chars.forEach(function (val) { fb.writeUtf16CodePoint(val, false); }); fb.save(filename); var savedFile = new FileManager.FileBuffer(filename); if (savedFile.encoding !== 'utf16le') { throw Error("Incorrect encoding"); } var expectedBytes = [0xFF, 0xFE, 0x54, 0x00, 0xE8, 0x00, 0x23, 0x1D, 0x20, 0x20, 0x0D, 0x00, 0x0A, 0x00] savedFile.index = 0; expectedBytes.forEach(function (val) { var byteVal = savedFile.readByte(); if (byteVal !== val) { throw Error("Incorrect byte value"); } }); return true; })); testRunner.addTest(new TestCase("Check reading past buffer asserts", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var result = fb.readByte(200); return true; }, "read beyond buffer length")); testRunner.addTest(new TestCase("Check writing past buffer asserts", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); fb.writeByte(5, 200); return true; }, "write beyond buffer length")); // Non-BMP unicode char tests testRunner.addTest(new TestCase("Read non-BMP utf16 chars", function () { var savedFile = new FileManager.FileBuffer(TestFileDir + "\\utf16leNonBmp.txt"); if (savedFile.encoding !== 'utf16le') { throw Error("Incorrect encoding"); } var codePoints = []; for (var i = 0; i < 6; i++) { codePoints.push(savedFile.readUtf16CodePoint(false)); } var expectedCodePoints = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; return TestRunner.arrayCompare(codePoints, expectedCodePoints); })); testRunner.addTest(new TestCase("Read non-BMP utf8 chars", function () { var savedFile = new FileManager.FileBuffer(TestFileDir + "\\utf8NonBmp.txt"); if (savedFile.encoding !== 'utf8') { throw Error("Incorrect encoding"); } var codePoints = []; for (var i = 0; i < 6; i++) { codePoints.push(savedFile.readUtf8CodePoint()); } var expectedCodePoints = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; return TestRunner.arrayCompare(codePoints, expectedCodePoints); })); testRunner.addTest(new TestCase("Write non-BMP utf8 chars", function () { var filename = TestFileDir + "\\tmpUTF8nonBmp.txt"; var fb = new FileManager.FileBuffer(15); var chars = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; chars.forEach(function (val) { fb.writeUtf8CodePoint(val); }); fb.save(filename); var savedFile = new FileManager.FileBuffer(filename); if (savedFile.encoding !== 'utf8') { throw Error("Incorrect encoding"); } var expectedBytes = [0xF0, 0x90, 0x92, 0x80, 0xF0, 0x90, 0x92, 0x81, 0xF0, 0x90, 0x92, 0x82, 0x54, 0x68, 0x69]; expectedBytes.forEach(function (val) { var byteVal = savedFile.readByte(); if (byteVal !== val) { throw Error("Incorrect byte value"); } }); return true; })); testRunner.addTest(new TestCase("Test invalid lead UTF8 byte", function () { var filename = TestFileDir + "\\utf8BadLeadByte.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Invalid UTF8 byte sequence at index: 4")); testRunner.addTest(new TestCase("Test invalid tail UTF8 byte", function () { var filename = TestFileDir + "\\utf8InvalidTail.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trailing byte invalid at index: 8")); testRunner.addTest(new TestCase("Test ANSI fails validation", function () { var filename = TestFileDir + "\\ansi.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trailing byte invalid at index: 6")); testRunner.addTest(new TestCase("Test UTF-16LE with invalid surrogate trail fails", function () { var filename = TestFileDir + "\\utf16leInvalidSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trail surrogate has an invalid value")); testRunner.addTest(new TestCase("Test UTF-16BE with invalid surrogate head fails", function () { var filename = TestFileDir + "\\UTF16BEInvalidSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Byte sequence starts with a trail surrogate")); testRunner.addTest(new TestCase("Test UTF-16LE with missing trail surrogate fails", function () { var filename = TestFileDir + "\\utf16leMissingTrailSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trail surrogate has an invalid value")); // Count of CRs & LFs testRunner.addTest(new TestCase("Count character occurrences", function () { var filename = TestFileDir + "\\charCountASCII.txt"; var fb = new FileManager.FileBuffer(filename); var result = (fb.countCR === 5 && fb.countLF === 4 && fb.countCRLF === 5 && fb.countHT === 3); return result; })); // Control characters in text testRunner.addTest(new TestCase("Test file with control character", function () { var filename = TestFileDir + "\\controlChar.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Codepoint at index: 3 has control value: 8")); return testRunner;})() : TestRunner
>(function () { var testRunner = new TestRunner(); // First 3 are for simple harness validation testRunner.addTest(new TestCase("Basic test", function () { return true; })); testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, "")); testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass")); testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); })); testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); })); // File detection tests testRunner.addTest(new TestCase("Check file exists", function () { return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt"); })); testRunner.addTest(new TestCase("Check file doesn't exist", function () { return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt"); })); // File pattern matching tests testRunner.addTest(new TestCase("Check text file match", function () { return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) })); testRunner.addTest(new TestCase("Check makefile match", function () { return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile"); })); testRunner.addTest(new TestCase("Check binary file doesn't match", function () { return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")); })); // Command-line parameter tests testRunner.addTest(new TestCase("Check App defaults", function () { var app = new App.App([]); return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom"); })); testRunner.addTest(new TestCase("Check App params", function () { var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]); return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2); })); // File BOM detection tests testRunner.addTest(new TestCase("Check encoding detection no BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding detection UTF8 BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); return fb.bom === 'utf8' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding detection UTF16be BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt"); return fb.bom === 'utf16be' && fb.encoding === 'utf16be'; })); testRunner.addTest(new TestCase("Check encoding detection UTF16le BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt"); return fb.bom === 'utf16le' && fb.encoding === 'utf16le'; })); testRunner.addTest(new TestCase("Check encoding on 1 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding on 0 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); // UTF8 encoding tests testRunner.addTest(new TestCase("Check byte reader", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 11; i++) { chars.push(fb.readByte()); } return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]); })); testRunner.addTest(new TestCase("Check UTF8 decoding", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 6; i++) { chars.push(fb.readUtf8CodePoint()); } return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]); })); testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb = new FileManager.FileBuffer(20); fb.writeUtf8Bom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; return TestRunner.arrayCompare(bytes, expected); })); // Test reading and writing files testRunner.addTest(new TestCase("Check saving a file", function () { var filename = TestFileDir + "\\tmpUTF16LE.txt"; var fb = new FileManager.FileBuffer(14); fb.writeUtf16leBom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; chars.forEach(function (val) { fb.writeUtf16CodePoint(val, false); }); fb.save(filename); var savedFile = new FileManager.FileBuffer(filename); if (savedFile.encoding !== 'utf16le') { throw Error("Incorrect encoding"); } var expectedBytes = [0xFF, 0xFE, 0x54, 0x00, 0xE8, 0x00, 0x23, 0x1D, 0x20, 0x20, 0x0D, 0x00, 0x0A, 0x00] savedFile.index = 0; expectedBytes.forEach(function (val) { var byteVal = savedFile.readByte(); if (byteVal !== val) { throw Error("Incorrect byte value"); } }); return true; })); testRunner.addTest(new TestCase("Check reading past buffer asserts", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var result = fb.readByte(200); return true; }, "read beyond buffer length")); testRunner.addTest(new TestCase("Check writing past buffer asserts", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); fb.writeByte(5, 200); return true; }, "write beyond buffer length")); // Non-BMP unicode char tests testRunner.addTest(new TestCase("Read non-BMP utf16 chars", function () { var savedFile = new FileManager.FileBuffer(TestFileDir + "\\utf16leNonBmp.txt"); if (savedFile.encoding !== 'utf16le') { throw Error("Incorrect encoding"); } var codePoints = []; for (var i = 0; i < 6; i++) { codePoints.push(savedFile.readUtf16CodePoint(false)); } var expectedCodePoints = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; return TestRunner.arrayCompare(codePoints, expectedCodePoints); })); testRunner.addTest(new TestCase("Read non-BMP utf8 chars", function () { var savedFile = new FileManager.FileBuffer(TestFileDir + "\\utf8NonBmp.txt"); if (savedFile.encoding !== 'utf8') { throw Error("Incorrect encoding"); } var codePoints = []; for (var i = 0; i < 6; i++) { codePoints.push(savedFile.readUtf8CodePoint()); } var expectedCodePoints = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; return TestRunner.arrayCompare(codePoints, expectedCodePoints); })); testRunner.addTest(new TestCase("Write non-BMP utf8 chars", function () { var filename = TestFileDir + "\\tmpUTF8nonBmp.txt"; var fb = new FileManager.FileBuffer(15); var chars = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; chars.forEach(function (val) { fb.writeUtf8CodePoint(val); }); fb.save(filename); var savedFile = new FileManager.FileBuffer(filename); if (savedFile.encoding !== 'utf8') { throw Error("Incorrect encoding"); } var expectedBytes = [0xF0, 0x90, 0x92, 0x80, 0xF0, 0x90, 0x92, 0x81, 0xF0, 0x90, 0x92, 0x82, 0x54, 0x68, 0x69]; expectedBytes.forEach(function (val) { var byteVal = savedFile.readByte(); if (byteVal !== val) { throw Error("Incorrect byte value"); } }); return true; })); testRunner.addTest(new TestCase("Test invalid lead UTF8 byte", function () { var filename = TestFileDir + "\\utf8BadLeadByte.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Invalid UTF8 byte sequence at index: 4")); testRunner.addTest(new TestCase("Test invalid tail UTF8 byte", function () { var filename = TestFileDir + "\\utf8InvalidTail.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trailing byte invalid at index: 8")); testRunner.addTest(new TestCase("Test ANSI fails validation", function () { var filename = TestFileDir + "\\ansi.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trailing byte invalid at index: 6")); testRunner.addTest(new TestCase("Test UTF-16LE with invalid surrogate trail fails", function () { var filename = TestFileDir + "\\utf16leInvalidSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trail surrogate has an invalid value")); testRunner.addTest(new TestCase("Test UTF-16BE with invalid surrogate head fails", function () { var filename = TestFileDir + "\\UTF16BEInvalidSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Byte sequence starts with a trail surrogate")); testRunner.addTest(new TestCase("Test UTF-16LE with missing trail surrogate fails", function () { var filename = TestFileDir + "\\utf16leMissingTrailSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trail surrogate has an invalid value")); // Count of CRs & LFs testRunner.addTest(new TestCase("Count character occurrences", function () { var filename = TestFileDir + "\\charCountASCII.txt"; var fb = new FileManager.FileBuffer(filename); var result = (fb.countCR === 5 && fb.countLF === 4 && fb.countCRLF === 5 && fb.countHT === 3); return result; })); // Control characters in text testRunner.addTest(new TestCase("Test file with control character", function () { var filename = TestFileDir + "\\controlChar.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Codepoint at index: 3 has control value: 8")); return testRunner;}) : () => TestRunner
>function () { var testRunner = new TestRunner(); // First 3 are for simple harness validation testRunner.addTest(new TestCase("Basic test", function () { return true; })); testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, "")); testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass")); testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); })); testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); })); // File detection tests testRunner.addTest(new TestCase("Check file exists", function () { return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt"); })); testRunner.addTest(new TestCase("Check file doesn't exist", function () { return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt"); })); // File pattern matching tests testRunner.addTest(new TestCase("Check text file match", function () { return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) })); testRunner.addTest(new TestCase("Check makefile match", function () { return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile"); })); testRunner.addTest(new TestCase("Check binary file doesn't match", function () { return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")); })); // Command-line parameter tests testRunner.addTest(new TestCase("Check App defaults", function () { var app = new App.App([]); return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom"); })); testRunner.addTest(new TestCase("Check App params", function () { var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]); return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2); })); // File BOM detection tests testRunner.addTest(new TestCase("Check encoding detection no BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding detection UTF8 BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); return fb.bom === 'utf8' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding detection UTF16be BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt"); return fb.bom === 'utf16be' && fb.encoding === 'utf16be'; })); testRunner.addTest(new TestCase("Check encoding detection UTF16le BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt"); return fb.bom === 'utf16le' && fb.encoding === 'utf16le'; })); testRunner.addTest(new TestCase("Check encoding on 1 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); testRunner.addTest(new TestCase("Check encoding on 0 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })); // UTF8 encoding tests testRunner.addTest(new TestCase("Check byte reader", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 11; i++) { chars.push(fb.readByte()); } return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]); })); testRunner.addTest(new TestCase("Check UTF8 decoding", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 6; i++) { chars.push(fb.readUtf8CodePoint()); } return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]); })); testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb = new FileManager.FileBuffer(20); fb.writeUtf8Bom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; return TestRunner.arrayCompare(bytes, expected); })); // Test reading and writing files testRunner.addTest(new TestCase("Check saving a file", function () { var filename = TestFileDir + "\\tmpUTF16LE.txt"; var fb = new FileManager.FileBuffer(14); fb.writeUtf16leBom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; chars.forEach(function (val) { fb.writeUtf16CodePoint(val, false); }); fb.save(filename); var savedFile = new FileManager.FileBuffer(filename); if (savedFile.encoding !== 'utf16le') { throw Error("Incorrect encoding"); } var expectedBytes = [0xFF, 0xFE, 0x54, 0x00, 0xE8, 0x00, 0x23, 0x1D, 0x20, 0x20, 0x0D, 0x00, 0x0A, 0x00] savedFile.index = 0; expectedBytes.forEach(function (val) { var byteVal = savedFile.readByte(); if (byteVal !== val) { throw Error("Incorrect byte value"); } }); return true; })); testRunner.addTest(new TestCase("Check reading past buffer asserts", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var result = fb.readByte(200); return true; }, "read beyond buffer length")); testRunner.addTest(new TestCase("Check writing past buffer asserts", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); fb.writeByte(5, 200); return true; }, "write beyond buffer length")); // Non-BMP unicode char tests testRunner.addTest(new TestCase("Read non-BMP utf16 chars", function () { var savedFile = new FileManager.FileBuffer(TestFileDir + "\\utf16leNonBmp.txt"); if (savedFile.encoding !== 'utf16le') { throw Error("Incorrect encoding"); } var codePoints = []; for (var i = 0; i < 6; i++) { codePoints.push(savedFile.readUtf16CodePoint(false)); } var expectedCodePoints = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; return TestRunner.arrayCompare(codePoints, expectedCodePoints); })); testRunner.addTest(new TestCase("Read non-BMP utf8 chars", function () { var savedFile = new FileManager.FileBuffer(TestFileDir + "\\utf8NonBmp.txt"); if (savedFile.encoding !== 'utf8') { throw Error("Incorrect encoding"); } var codePoints = []; for (var i = 0; i < 6; i++) { codePoints.push(savedFile.readUtf8CodePoint()); } var expectedCodePoints = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; return TestRunner.arrayCompare(codePoints, expectedCodePoints); })); testRunner.addTest(new TestCase("Write non-BMP utf8 chars", function () { var filename = TestFileDir + "\\tmpUTF8nonBmp.txt"; var fb = new FileManager.FileBuffer(15); var chars = [0x10480, 0x10481, 0x10482, 0x54, 0x68, 0x69]; chars.forEach(function (val) { fb.writeUtf8CodePoint(val); }); fb.save(filename); var savedFile = new FileManager.FileBuffer(filename); if (savedFile.encoding !== 'utf8') { throw Error("Incorrect encoding"); } var expectedBytes = [0xF0, 0x90, 0x92, 0x80, 0xF0, 0x90, 0x92, 0x81, 0xF0, 0x90, 0x92, 0x82, 0x54, 0x68, 0x69]; expectedBytes.forEach(function (val) { var byteVal = savedFile.readByte(); if (byteVal !== val) { throw Error("Incorrect byte value"); } }); return true; })); testRunner.addTest(new TestCase("Test invalid lead UTF8 byte", function () { var filename = TestFileDir + "\\utf8BadLeadByte.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Invalid UTF8 byte sequence at index: 4")); testRunner.addTest(new TestCase("Test invalid tail UTF8 byte", function () { var filename = TestFileDir + "\\utf8InvalidTail.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trailing byte invalid at index: 8")); testRunner.addTest(new TestCase("Test ANSI fails validation", function () { var filename = TestFileDir + "\\ansi.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trailing byte invalid at index: 6")); testRunner.addTest(new TestCase("Test UTF-16LE with invalid surrogate trail fails", function () { var filename = TestFileDir + "\\utf16leInvalidSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trail surrogate has an invalid value")); testRunner.addTest(new TestCase("Test UTF-16BE with invalid surrogate head fails", function () { var filename = TestFileDir + "\\UTF16BEInvalidSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Byte sequence starts with a trail surrogate")); testRunner.addTest(new TestCase("Test UTF-16LE with missing trail surrogate fails", function () { var filename = TestFileDir + "\\utf16leMissingTrailSurrogate.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Trail surrogate has an invalid value")); // Count of CRs & LFs testRunner.addTest(new TestCase("Count character occurrences", function () { var filename = TestFileDir + "\\charCountASCII.txt"; var fb = new FileManager.FileBuffer(filename); var result = (fb.countCR === 5 && fb.countLF === 4 && fb.countCRLF === 5 && fb.countHT === 3); return result; })); // Control characters in text testRunner.addTest(new TestCase("Test file with control character", function () { var filename = TestFileDir + "\\controlChar.txt"; var fb = new FileManager.FileBuffer(filename); return true; }, "Codepoint at index: 3 has control value: 8")); return testRunner;} : () => TestRunner
var testRunner = new TestRunner();
>testRunner : TestRunner
>new TestRunner() : TestRunner
>TestRunner : typeof TestRunner
// First 3 are for simple harness validation
testRunner.addTest(new TestCase("Basic test", function () { return true; }));
>testRunner.addTest(new TestCase("Basic test", function () { return true; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Basic test", function () { return true; }) : TestCase
>TestCase : typeof TestCase
>"Basic test" : "Basic test"
>function () { return true; } : () => true
>true : true
testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, ""));
>testRunner.addTest(new TestCase("Test for any error", function () { throw new Error(); return false; }, "")) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Test for any error", function () { throw new Error(); return false; }, "") : TestCase
>TestCase : typeof TestCase
>"Test for any error" : "Test for any error"
>function () { throw new Error(); return false; } : () => false
>new Error() : Error
>Error : ErrorConstructor
>false : false
>"" : ""
testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass"));
>testRunner.addTest(new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass")) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Test RegEx error message match", function () { throw new Error("Should also pass"); return false; }, "Should [also]+ pass") : TestCase
>TestCase : typeof TestCase
>"Test RegEx error message match" : "Test RegEx error message match"
>function () { throw new Error("Should also pass"); return false; } : () => false
>new Error("Should also pass") : Error
>Error : ErrorConstructor
>"Should also pass" : "Should also pass"
>false : false
>"Should [also]+ pass" : "Should [also]+ pass"
testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); }));
>testRunner.addTest(new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Test array compare true", function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); }) : TestCase
>TestCase : typeof TestCase
>"Test array compare true" : "Test array compare true"
>function () { return TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]); } : () => boolean
>TestRunner.arrayCompare([1, 2, 3], [1, 2, 3]) : boolean
>TestRunner.arrayCompare : (arg1: any[], arg2: any[]) => boolean
>TestRunner : typeof TestRunner
>arrayCompare : (arg1: any[], arg2: any[]) => boolean
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); }));
>testRunner.addTest(new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Test array compare false", function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); }) : TestCase
>TestCase : typeof TestCase
>"Test array compare false" : "Test array compare false"
>function () { return !TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]); } : () => boolean
>!TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]) : boolean
>TestRunner.arrayCompare([3, 2, 3], [1, 2, 3]) : boolean
>TestRunner.arrayCompare : (arg1: any[], arg2: any[]) => boolean
>TestRunner : typeof TestRunner
>arrayCompare : (arg1: any[], arg2: any[]) => boolean
>[3, 2, 3] : number[]
>3 : 3
>2 : 2
>3 : 3
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
// File detection tests
testRunner.addTest(new TestCase("Check file exists",
>testRunner.addTest(new TestCase("Check file exists", function () { return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt"); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check file exists", function () { return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt"); }) : TestCase
>TestCase : typeof TestCase
>"Check file exists" : "Check file exists"
function () {
>function () { return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt"); } : () => any
return FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt");
>FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test.txt") : any
>FileManager.DirectoryManager.fileExists : any
>FileManager.DirectoryManager : any
>FileManager : any
>DirectoryManager : any
>fileExists : any
>TestFileDir + "\\Test.txt" : string
>TestFileDir : string
>"\\Test.txt" : "\\Test.txt"
}));
testRunner.addTest(new TestCase("Check file doesn't exist",
>testRunner.addTest(new TestCase("Check file doesn't exist", function () { return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt"); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check file doesn't exist", function () { return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt"); }) : TestCase
>TestCase : typeof TestCase
>"Check file doesn't exist" : "Check file doesn't exist"
function () {
>function () { return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt"); } : () => boolean
return !FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt");
>!FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt") : boolean
>FileManager.DirectoryManager.fileExists(TestFileDir + "\\Test2.txt") : any
>FileManager.DirectoryManager.fileExists : any
>FileManager.DirectoryManager : any
>FileManager : any
>DirectoryManager : any
>fileExists : any
>TestFileDir + "\\Test2.txt" : string
>TestFileDir : string
>"\\Test2.txt" : "\\Test2.txt"
}));
// File pattern matching tests
testRunner.addTest(new TestCase("Check text file match",
>testRunner.addTest(new TestCase("Check text file match", function () { return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check text file match", function () { return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) }) : TestCase
>TestCase : typeof TestCase
>"Check text file match" : "Check text file match"
function () {
>function () { return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) } : () => any
return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") &&
>(FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js")) : any
>FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js") : any
>FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") : any
>FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") : any
>FileManager.FileBuffer.isTextFile : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>isTextFile : any
>"C:\\somedir\\readme.txt" : "C:\\somedir\\readme.txt"
FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") &&
>FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") : any
>FileManager.FileBuffer.isTextFile : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>isTextFile : any
>"C:\\spaces path\\myapp.str" : "C:\\spaces path\\myapp.str"
FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js"))
>FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js") : any
>FileManager.FileBuffer.isTextFile : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>isTextFile : any
>"C:\\somedir\\code.js" : "C:\\somedir\\code.js"
}));
testRunner.addTest(new TestCase("Check makefile match",
>testRunner.addTest(new TestCase("Check makefile match", function () { return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile"); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check makefile match", function () { return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile"); }) : TestCase
>TestCase : typeof TestCase
>"Check makefile match" : "Check makefile match"
function () {
>function () { return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile"); } : () => any
return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile");
>FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile") : any
>FileManager.FileBuffer.isTextFile : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>isTextFile : any
>"C:\\some dir\\makefile" : "C:\\some dir\\makefile"
}));
testRunner.addTest(new TestCase("Check binary file doesn't match",
>testRunner.addTest(new TestCase("Check binary file doesn't match", function () { return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check binary file doesn't match", function () { return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")); }) : TestCase
>TestCase : typeof TestCase
>"Check binary file doesn't match" : "Check binary file doesn't match"
function () {
>function () { return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")); } : () => boolean
return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") &&
>(!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll")) : boolean
>!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll") : boolean
>!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") : boolean
>FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") : any
>FileManager.FileBuffer.isTextFile : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>isTextFile : any
>"C:\\somedir\\app.exe" : "C:\\somedir\\app.exe"
!FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll"));
>!FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll") : boolean
>FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll") : any
>FileManager.FileBuffer.isTextFile : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>isTextFile : any
>"C:\\somedir\\my lib.dll" : "C:\\somedir\\my lib.dll"
}));
// Command-line parameter tests
testRunner.addTest(new TestCase("Check App defaults",
>testRunner.addTest(new TestCase("Check App defaults", function () { var app = new App.App([]); return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom"); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check App defaults", function () { var app = new App.App([]); return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom"); }) : TestCase
>TestCase : typeof TestCase
>"Check App defaults" : "Check App defaults"
function () {
>function () { var app = new App.App([]); return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom"); } : () => boolean
var app = new App.App([]);
>app : any
>new App.App([]) : any
>App.App : any
>App : any
>App : any
>[] : undefined[]
return (app.fixLines === false &&
>(app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom") : boolean
>app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom" : boolean
>app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" : boolean
>app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" : boolean
>app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined : boolean
>app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" : boolean
>app.fixLines === false && app.recurse === true : boolean
>app.fixLines === false : boolean
>app.fixLines : any
>app : any
>fixLines : any
>false : false
app.recurse === true &&
>app.recurse === true : boolean
>app.recurse : any
>app : any
>recurse : any
>true : true
app.lineEndings === "CRLF" &&
>app.lineEndings === "CRLF" : boolean
>app.lineEndings : any
>app : any
>lineEndings : any
>"CRLF" : "CRLF"
app.matchPattern === undefined &&
>app.matchPattern === undefined : boolean
>app.matchPattern : any
>app : any
>matchPattern : any
>undefined : undefined
app.rootDirectory === ".\\" &&
>app.rootDirectory === ".\\" : boolean
>app.rootDirectory : any
>app : any
>rootDirectory : any
>".\\" : ".\\"
app.encodings[0] === "ascii" &&
>app.encodings[0] === "ascii" : boolean
>app.encodings[0] : any
>app.encodings : any
>app : any
>encodings : any
>0 : 0
>"ascii" : "ascii"
app.encodings[1] === "utf8nobom");
>app.encodings[1] === "utf8nobom" : boolean
>app.encodings[1] : any
>app.encodings : any
>app : any
>encodings : any
>1 : 1
>"utf8nobom" : "utf8nobom"
}));
testRunner.addTest(new TestCase("Check App params",
>testRunner.addTest(new TestCase("Check App params", function () { var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]); return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check App params", function () { var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]); return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2); }) : TestCase
>TestCase : typeof TestCase
>"Check App params" : "Check App params"
function () {
>function () { var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]); return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2); } : () => boolean
var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]);
>app : any
>new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]) : any
>App.App : any
>App : any
>App : any
>["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"] : string[]
>"-dir=C:\\test dir" : "-dir=C:\\test dir"
>"-lineEndings=LF" : "-lineEndings=LF"
>"-encodings=utf16be,ascii" : "-encodings=utf16be,ascii"
>"-recurse=false" : "-recurse=false"
>"-fixlines" : "-fixlines"
return (app.fixLines === true &&
>(app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2) : boolean
>app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2 : boolean
>app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" : boolean
>app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" : boolean
>app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" : boolean
>app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined : boolean
>app.fixLines === true && app.lineEndings === "LF" && app.recurse === false : boolean
>app.fixLines === true && app.lineEndings === "LF" : boolean
>app.fixLines === true : boolean
>app.fixLines : any
>app : any
>fixLines : any
>true : true
app.lineEndings === "LF" &&
>app.lineEndings === "LF" : boolean
>app.lineEndings : any
>app : any
>lineEndings : any
>"LF" : "LF"
app.recurse === false &&
>app.recurse === false : boolean
>app.recurse : any
>app : any
>recurse : any
>false : false
app.matchPattern === undefined &&
>app.matchPattern === undefined : boolean
>app.matchPattern : any
>app : any
>matchPattern : any
>undefined : undefined
app.rootDirectory === "C:\\test dir" &&
>app.rootDirectory === "C:\\test dir" : boolean
>app.rootDirectory : any
>app : any
>rootDirectory : any
>"C:\\test dir" : "C:\\test dir"
app.encodings[0] === "utf16be" &&
>app.encodings[0] === "utf16be" : boolean
>app.encodings[0] : any
>app.encodings : any
>app : any
>encodings : any
>0 : 0
>"utf16be" : "utf16be"
app.encodings[1] === "ascii" &&
>app.encodings[1] === "ascii" : boolean
>app.encodings[1] : any
>app.encodings : any
>app : any
>encodings : any
>1 : 1
>"ascii" : "ascii"
app.encodings.length === 2);
>app.encodings.length === 2 : boolean
>app.encodings.length : any
>app.encodings : any
>app : any
>encodings : any
>length : any
>2 : 2
}));
// File BOM detection tests
testRunner.addTest(new TestCase("Check encoding detection no BOM",
>testRunner.addTest(new TestCase("Check encoding detection no BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check encoding detection no BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; }) : TestCase
>TestCase : typeof TestCase
>"Check encoding detection no BOM" : "Check encoding detection no BOM"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\noBOM.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\noBOM.txt" : string
>TestFileDir : string
>"\\noBOM.txt" : "\\noBOM.txt"
return fb.bom === 'none' && fb.encoding === 'utf8';
>fb.bom === 'none' && fb.encoding === 'utf8' : boolean
>fb.bom === 'none' : boolean
>fb.bom : any
>fb : any
>bom : any
>'none' : "none"
>fb.encoding === 'utf8' : boolean
>fb.encoding : any
>fb : any
>encoding : any
>'utf8' : "utf8"
}));
testRunner.addTest(new TestCase("Check encoding detection UTF8 BOM",
>testRunner.addTest(new TestCase("Check encoding detection UTF8 BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); return fb.bom === 'utf8' && fb.encoding === 'utf8'; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check encoding detection UTF8 BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); return fb.bom === 'utf8' && fb.encoding === 'utf8'; }) : TestCase
>TestCase : typeof TestCase
>"Check encoding detection UTF8 BOM" : "Check encoding detection UTF8 BOM"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); return fb.bom === 'utf8' && fb.encoding === 'utf8'; } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\UTF8BOM.txt" : string
>TestFileDir : string
>"\\UTF8BOM.txt" : "\\UTF8BOM.txt"
return fb.bom === 'utf8' && fb.encoding === 'utf8';
>fb.bom === 'utf8' && fb.encoding === 'utf8' : boolean
>fb.bom === 'utf8' : boolean
>fb.bom : any
>fb : any
>bom : any
>'utf8' : "utf8"
>fb.encoding === 'utf8' : boolean
>fb.encoding : any
>fb : any
>encoding : any
>'utf8' : "utf8"
}));
testRunner.addTest(new TestCase("Check encoding detection UTF16be BOM",
>testRunner.addTest(new TestCase("Check encoding detection UTF16be BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt"); return fb.bom === 'utf16be' && fb.encoding === 'utf16be'; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check encoding detection UTF16be BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt"); return fb.bom === 'utf16be' && fb.encoding === 'utf16be'; }) : TestCase
>TestCase : typeof TestCase
>"Check encoding detection UTF16be BOM" : "Check encoding detection UTF16be BOM"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt"); return fb.bom === 'utf16be' && fb.encoding === 'utf16be'; } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\UTF16BE.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\UTF16BE.txt" : string
>TestFileDir : string
>"\\UTF16BE.txt" : "\\UTF16BE.txt"
return fb.bom === 'utf16be' && fb.encoding === 'utf16be';
>fb.bom === 'utf16be' && fb.encoding === 'utf16be' : boolean
>fb.bom === 'utf16be' : boolean
>fb.bom : any
>fb : any
>bom : any
>'utf16be' : "utf16be"
>fb.encoding === 'utf16be' : boolean
>fb.encoding : any
>fb : any
>encoding : any
>'utf16be' : "utf16be"
}));
testRunner.addTest(new TestCase("Check encoding detection UTF16le BOM",
>testRunner.addTest(new TestCase("Check encoding detection UTF16le BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt"); return fb.bom === 'utf16le' && fb.encoding === 'utf16le'; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check encoding detection UTF16le BOM", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt"); return fb.bom === 'utf16le' && fb.encoding === 'utf16le'; }) : TestCase
>TestCase : typeof TestCase
>"Check encoding detection UTF16le BOM" : "Check encoding detection UTF16le BOM"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt"); return fb.bom === 'utf16le' && fb.encoding === 'utf16le'; } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\UTF16LE.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\UTF16LE.txt" : string
>TestFileDir : string
>"\\UTF16LE.txt" : "\\UTF16LE.txt"
return fb.bom === 'utf16le' && fb.encoding === 'utf16le';
>fb.bom === 'utf16le' && fb.encoding === 'utf16le' : boolean
>fb.bom === 'utf16le' : boolean
>fb.bom : any
>fb : any
>bom : any
>'utf16le' : "utf16le"
>fb.encoding === 'utf16le' : boolean
>fb.encoding : any
>fb : any
>encoding : any
>'utf16le' : "utf16le"
}));
testRunner.addTest(new TestCase("Check encoding on 1 bytes file",
>testRunner.addTest(new TestCase("Check encoding on 1 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check encoding on 1 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; }) : TestCase
>TestCase : typeof TestCase
>"Check encoding on 1 bytes file" : "Check encoding on 1 bytes file"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\1bytefile.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\1bytefile.txt" : string
>TestFileDir : string
>"\\1bytefile.txt" : "\\1bytefile.txt"
return fb.bom === 'none' && fb.encoding === 'utf8';
>fb.bom === 'none' && fb.encoding === 'utf8' : boolean
>fb.bom === 'none' : boolean
>fb.bom : any
>fb : any
>bom : any
>'none' : "none"
>fb.encoding === 'utf8' : boolean
>fb.encoding : any
>fb : any
>encoding : any
>'utf8' : "utf8"
}));
testRunner.addTest(new TestCase("Check encoding on 0 bytes file",
>testRunner.addTest(new TestCase("Check encoding on 0 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check encoding on 0 bytes file", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; }) : TestCase
>TestCase : typeof TestCase
>"Check encoding on 0 bytes file" : "Check encoding on 0 bytes file"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt"); return fb.bom === 'none' && fb.encoding === 'utf8'; } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\0bytefile.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\0bytefile.txt" : string
>TestFileDir : string
>"\\0bytefile.txt" : "\\0bytefile.txt"
return fb.bom === 'none' && fb.encoding === 'utf8';
>fb.bom === 'none' && fb.encoding === 'utf8' : boolean
>fb.bom === 'none' : boolean
>fb.bom : any
>fb : any
>bom : any
>'none' : "none"
>fb.encoding === 'utf8' : boolean
>fb.encoding : any
>fb : any
>encoding : any
>'utf8' : "utf8"
}));
// UTF8 encoding tests
testRunner.addTest(new TestCase("Check byte reader",
>testRunner.addTest(new TestCase("Check byte reader", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 11; i++) { chars.push(fb.readByte()); } return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check byte reader", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 11; i++) { chars.push(fb.readByte()); } return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]); }) : TestCase
>TestCase : typeof TestCase
>"Check byte reader" : "Check byte reader"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 11; i++) { chars.push(fb.readByte()); } return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]); } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\UTF8BOM.txt" : string
>TestFileDir : string
>"\\UTF8BOM.txt" : "\\UTF8BOM.txt"
var chars = [];
>chars : any[]
>[] : undefined[]
for (var i = 0; i < 11; i++) {
>i : number
>0 : 0
>i < 11 : boolean
>i : number
>11 : 11
>i++ : number
>i : number
chars.push(fb.readByte());
>chars.push(fb.readByte()) : number
>chars.push : (...items: any[]) => number
>chars : any[]
>push : (...items: any[]) => number
>fb.readByte() : any
>fb.readByte : any
>fb : any
>readByte : any
}
return TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]);
>TestRunner.arrayCompare(chars, [0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]) : boolean
>TestRunner.arrayCompare : (arg1: any[], arg2: any[]) => boolean
>TestRunner : typeof TestRunner
>arrayCompare : (arg1: any[], arg2: any[]) => boolean
>chars : any[]
>[0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A] : number[]
>0x54 : 84
>0xC3 : 195
>0xA8 : 168
>0xE1 : 225
>0xB4 : 180
>0xA3 : 163
>0xE2 : 226
>0x80 : 128
>0xA0 : 160
>0x0D : 13
>0x0A : 10
}));
testRunner.addTest(new TestCase("Check UTF8 decoding",
>testRunner.addTest(new TestCase("Check UTF8 decoding", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 6; i++) { chars.push(fb.readUtf8CodePoint()); } return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check UTF8 decoding", function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 6; i++) { chars.push(fb.readUtf8CodePoint()); } return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]); }) : TestCase
>TestCase : typeof TestCase
>"Check UTF8 decoding" : "Check UTF8 decoding"
function () {
>function () { var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt"); var chars = []; for (var i = 0; i < 6; i++) { chars.push(fb.readUtf8CodePoint()); } return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]); } : () => boolean
var fb = new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt");
>fb : any
>new FileManager.FileBuffer(TestFileDir + "\\UTF8BOM.txt") : any
>FileManager.FileBuffer : any
>FileManager : any
>FileBuffer : any
>TestFileDir + "\\UTF8BOM.txt" : string
>TestFileDir : string
>"\\UTF8BOM.txt" : "\\UTF8BOM.txt"
var chars = [];
>chars : any[]
>[] : undefined[]
for (var i = 0; i < 6; i++) {
>i : number
>0 : 0
>i < 6 : boolean
>i : number
>6 : 6
>i++ : number
>i : number
chars.push(fb.readUtf8CodePoint());
>chars.push(fb.readUtf8CodePoint()) : number
>chars.push : (...items: any[]) => number
>chars : any[]
>push : (...items: any[]) => number
>fb.readUtf8CodePoint() : any
>fb.readUtf8CodePoint : any
>fb : any
>readUtf8CodePoint : any
}
return TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]);
>TestRunner.arrayCompare(chars, [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]) : boolean
>TestRunner.arrayCompare : (arg1: any[], arg2: any[]) => boolean
>TestRunner : typeof TestRunner
>arrayCompare : (arg1: any[], arg2: any[]) => boolean
>chars : any[]
>[0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A] : number[]
>0x0054 : 84
>0x00E8 : 232
>0x1D23 : 7459
>0x2020 : 8224
>0x000D : 13
>0x000A : 10
}));
testRunner.addTest(new TestCase("Check UTF8 encoding",
>testRunner.addTest(new TestCase("Check UTF8 encoding", function () { var fb = new FileManager.FileBuffer(20); fb.writeUtf8Bom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; return TestRunner.arrayCompare(bytes, expected); })) : void
>testRunner.addTest : (test: TestCase) => void
>testRunner : TestRunner
>addTest : (test: TestCase) => void
>new TestCase("Check UTF8 encoding", function () { var fb = new FileManager.FileBuffer(20); fb.writeUtf8Bom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; return TestRunner.arrayCompare(bytes, expected); }) : TestCase
>TestCase : typeof TestCase
>"Check UTF8 encoding" : "Check UTF8 encoding"
function () {
>function () { var fb = new FileManager.FileBuffer(20); fb.writeUtf8Bom(); var chars = [0x0054, 0x00E8, 0x1D23, 0x2020, 0x000D, 0x000A]; for (var i in chars) { fb.writeUtf8CodePoint(chars[i]); } fb.index = 0; var bytes = []; for (var i = 0; i < 14; i++) { bytes.push(fb.readByte()); } var expected = [0xEF, 0xBB, 0xBF, 0x54, 0xC3, 0xA8, 0xE1, 0xB4, 0xA3, 0xE2, 0x80, 0xA0, 0x0D, 0x0A]; return TestRunner.arrayCompare(bytes, expected); } : () => boolean
var fb = new FileManager.FileBuffer(20);
>fb : any
>new FileManager.FileBuffer(20) : any
>FileManager.FileBuffer : any