This repository was archived by the owner on Dec 23, 2024. It is now read-only.
forked from nosami/visualfsharp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtests.fs
3065 lines (2080 loc) · 116 KB
/
tests.fs
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
// To run these tests in F# Interactive , 'build net40', then send this chunk, then evaluate body of a test
#if INTERACTIVE
#r @"../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll"
#load "../../src/scripts/scriptlib.fsx"
#load "../FSharp.Test.Utilities/TestFramework.fs"
#load "single-test.fs"
#else
module FSharp.Tests.Core
#endif
open System
open System.IO
open System.Reflection
open System.Reflection.PortableExecutable
open NUnit.Framework
open TestFramework
open Scripting
open SingleTest
open HandleExpects
#if NETCOREAPP
// Use these lines if you want to test CoreCLR
let FSC_BASIC = FSC_CORECLR
let FSC_BUILDONLY = FSC_CORECLR_BUILDONLY
let FSI_BASIC = FSI_CORECLR
#else
let FSC_BASIC = FSC_OPT_PLUS_DEBUG
let FSI_BASIC = FSI_FILE
#endif
// ^^^^^^^^^^^^ To run these tests in F# Interactive , 'build net40', then send this chunk, then evaluate body of a test ^^^^^^^^^^^^
let inline getTestsDirectory dir = __SOURCE_DIRECTORY__ ++ dir
let singleTestBuildAndRun' = getTestsDirectory >> singleTestBuildAndRun
let singleTestBuildAndRunVersion' = getTestsDirectory >> singleTestBuildAndRunVersion
let testConfig' = getTestsDirectory >> testConfig
module CoreTests =
// These tests are enabled for .NET Framework and .NET Core
[<Test>]
let ``access-FSC_BASIC``() = singleTestBuildAndRun' "core/access" FSC_BASIC
[<Test>]
let ``access-FSI_BASIC``() = singleTestBuildAndRun' "core/access" FSI_BASIC
[<Test>]
let ``apporder-FSC_BASIC`` () = singleTestBuildAndRun' "core/apporder" FSC_BASIC
[<Test>]
let ``apporder-FSI_BASIC`` () = singleTestBuildAndRun' "core/apporder" FSI_BASIC
[<Test>]
let ``array-FSC_BASIC`` () = singleTestBuildAndRun' "core/array" FSC_BASIC
[<Test>]
let ``array-FSI_BASIC`` () = singleTestBuildAndRun' "core/array" FSI_BASIC
[<Test>]
let ``comprehensions-FSC_BASIC`` () = singleTestBuildAndRun' "core/comprehensions" FSC_BASIC
[<Test>]
let ``comprehensions-FSI_BASIC`` () = singleTestBuildAndRun' "core/comprehensions" FSI_BASIC
[<Test>]
let ``comprehensionshw-FSC_BASIC`` () = singleTestBuildAndRun' "core/comprehensions-hw" FSC_BASIC
[<Test>]
let ``comprehensionshw-FSI_BASIC`` () = singleTestBuildAndRun' "core/comprehensions-hw" FSI_BASIC
[<Test>]
let ``genericmeasures-FSC_BASIC`` () = singleTestBuildAndRun' "core/genericmeasures" FSC_BASIC
[<Test>]
let ``genericmeasures-FSI_BASIC`` () = singleTestBuildAndRun' "core/genericmeasures" FSI_BASIC
[<Test>]
let ``innerpoly-FSC_BASIC`` () = singleTestBuildAndRun' "core/innerpoly" FSC_BASIC
[<Test>]
let ``innerpoly-FSI_BASIC`` () = singleTestBuildAndRun' "core/innerpoly" FSI_BASIC
[<Test>]
let ``namespaceAttributes-FSC_BASIC`` () = singleTestBuildAndRun' "core/namespaces" FSC_BASIC
[<Test>]
let ``unicode2-FSC_BASIC`` () = singleTestBuildAndRun' "core/unicode" FSC_BASIC // TODO: fails on coreclr
[<Test>]
let ``unicode2-FSI_BASIC`` () = singleTestBuildAndRun' "core/unicode" FSI_BASIC
[<Test>]
let ``lazy test-FSC_BASIC`` () = singleTestBuildAndRun' "core/lazy" FSC_BASIC
[<Test>]
let ``lazy test-FSI_BASIC`` () = singleTestBuildAndRun' "core/lazy" FSI_BASIC
[<Test>]
let ``letrec-FSC_BASIC`` () = singleTestBuildAndRun' "core/letrec" FSC_BASIC
[<Test>]
let ``letrec-FSI_BASIC`` () = singleTestBuildAndRun' "core/letrec" FSI_BASIC
[<Test>]
let ``letrec (mutrec variations part one) FSC_BASIC`` () = singleTestBuildAndRun' "core/letrec-mutrec" FSC_BASIC
[<Test>]
let ``letrec (mutrec variations part one) FSI_BASIC`` () = singleTestBuildAndRun' "core/letrec-mutrec" FSI_BASIC
[<Test>]
let ``libtest-FSC_BASIC`` () = singleTestBuildAndRun' "core/libtest" FSC_BASIC
[<Test>]
let ``libtest-FSI_BASIC`` () = singleTestBuildAndRun' "core/libtest" FSI_BASIC
[<Test>]
let ``lift-FSC_BASIC`` () = singleTestBuildAndRun' "core/lift" FSC_BASIC
[<Test>]
let ``lift-FSI_BASIC`` () = singleTestBuildAndRun' "core/lift" FSI_BASIC
[<Test>]
let ``map-FSC_BASIC`` () = singleTestBuildAndRun' "core/map" FSC_BASIC
[<Test>]
let ``map-FSI_BASIC`` () = singleTestBuildAndRun' "core/map" FSI_BASIC
[<Test>]
let ``measures-FSC_BASIC`` () = singleTestBuildAndRun' "core/measures" FSC_BASIC
[<Test>]
let ``measures-FSI_BASIC`` () = singleTestBuildAndRun' "core/measures" FSI_BASIC
[<Test>]
let ``nested-FSC_BASIC`` () = singleTestBuildAndRun' "core/nested" FSC_BASIC
[<Test>]
let ``nested-FSI_BASIC`` () = singleTestBuildAndRun' "core/nested" FSI_BASIC
[<Test>]
let ``members-ops-FSC_BASIC`` () = singleTestBuildAndRun' "core/members/ops" FSC_BASIC
[<Test>]
let ``members-ops-FSI_BASIC`` () = singleTestBuildAndRun' "core/members/ops" FSI_BASIC
[<Test>]
let ``members-ops-mutrec-FSC_BASIC`` () = singleTestBuildAndRun' "core/members/ops-mutrec" FSC_BASIC
[<Test>]
let ``members-ops-mutrec-FSI_BASIC`` () = singleTestBuildAndRun' "core/members/ops-mutrec" FSI_BASIC
[<Test>]
let ``seq-FSC_BASIC`` () = singleTestBuildAndRun' "core/seq" FSC_BASIC
[<Test>]
let ``seq-FSI_BASIC`` () = singleTestBuildAndRun' "core/seq" FSI_BASIC
[<Test>]
let ``math-numbers-FSC_BASIC`` () = singleTestBuildAndRun' "core/math/numbers" FSC_BASIC
[<Test>]
let ``math-numbers-FSI_BASIC`` () = singleTestBuildAndRun' "core/math/numbers" FSI_BASIC
[<Test>]
let ``members-ctree-FSC_BASIC`` () = singleTestBuildAndRun' "core/members/ctree" FSC_BASIC
[<Test>]
let ``members-ctree-FSI_BASIC`` () = singleTestBuildAndRun' "core/members/ctree" FSI_BASIC
[<Test>]
let ``members-factors-FSC_BASIC`` () = singleTestBuildAndRun' "core/members/factors" FSC_BASIC
[<Test>]
let ``members-factors-FSI_BASIC`` () = singleTestBuildAndRun' "core/members/factors" FSI_BASIC
[<Test>]
let ``members-factors-mutrec-FSC_BASIC`` () = singleTestBuildAndRun' "core/members/factors-mutrec" FSC_BASIC
[<Test>]
let ``members-factors-mutrec-FSI_BASIC`` () = singleTestBuildAndRun' "core/members/factors-mutrec" FSI_BASIC
[<Test>]
let ``graph-FSC_BASIC`` () = singleTestBuildAndRun' "perf/graph" FSC_BASIC
[<Test>]
let ``graph-FSI_BASIC`` () = singleTestBuildAndRun' "perf/graph" FSI_BASIC
[<Test>]
let ``nbody-FSC_BASIC`` () = singleTestBuildAndRun' "perf/nbody" FSC_BASIC
[<Test>]
let ``nbody-FSI_BASIC`` () = singleTestBuildAndRun' "perf/nbody" FSI_BASIC
[<Test>]
let ``letrec (mutrec variations part two) FSC_BASIC`` () = singleTestBuildAndRun' "core/letrec-mutrec2" FSC_BASIC
[<Test>]
let ``letrec (mutrec variations part two) FSI_BASIC`` () = singleTestBuildAndRun' "core/letrec-mutrec2" FSI_BASIC
[<Test>]
let ``printf`` () = singleTestBuildAndRun' "core/printf" FSC_BASIC
[<Test>]
let ``printf-interpolated`` () = singleTestBuildAndRunVersion' "core/printf-interpolated" FSC_BASIC "preview"
[<Test>]
let ``tlr-FSC_BASIC`` () = singleTestBuildAndRun' "core/tlr" FSC_BASIC
[<Test>]
let ``tlr-FSI_BASIC`` () = singleTestBuildAndRun' "core/tlr" FSI_BASIC
[<Test>]
let ``subtype-FSC_BASIC`` () = singleTestBuildAndRun' "core/subtype" FSC_BASIC
[<Test>]
let ``subtype-FSI_BASIC`` () = singleTestBuildAndRun' "core/subtype" FSI_BASIC
[<Test>]
let ``syntax-FSC_BASIC`` () = singleTestBuildAndRun' "core/syntax" FSC_BASIC
[<Test>]
let ``syntax-FSI_BASIC`` () = singleTestBuildAndRun' "core/syntax" FSI_BASIC
[<Test>]
let ``test int32-FSC_BASIC`` () = singleTestBuildAndRun' "core/int32" FSC_BASIC
[<Test>]
let ``test int32-FSI_BASIC`` () = singleTestBuildAndRun' "core/int32" FSI_BASIC
[<Test>]
let ``quotes-FSC-BASIC`` () = singleTestBuildAndRun' "core/quotes" FSC_BASIC
[<Test>]
let ``quotes-FSI-BASIC`` () = singleTestBuildAndRun' "core/quotes" FSI_BASIC
[<Test>]
let ``recordResolution-FSC_BASIC`` () = singleTestBuildAndRun' "core/recordResolution" FSC_BASIC
[<Test>]
let ``recordResolution-FSI_BASIC`` () = singleTestBuildAndRun' "core/recordResolution" FSI_BASIC
[<Test>]
let ``SDKTests`` () =
let cfg = testConfig' "SDKTests"
exec cfg cfg.DotNetExe ("msbuild " + Path.Combine(cfg.Directory, "AllSdkTargetsTests.proj") + " /p:Configuration=" + cfg.BUILD_CONFIG)
#if !NETCOREAPP
[<Test>]
let ``attributes-FSC_BASIC`` () = singleTestBuildAndRun' "core/attributes" FSC_BASIC
[<Test>]
let ``attributes-FSI_BASIC`` () = singleTestBuildAndRun' "core/attributes" FSI_BASIC
[<Test>]
let byrefs () =
let cfg = testConfig' "core/byrefs"
begin
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe -g --langversion:4.7" cfg.fsc_flags ["test.fsx"]
singleVersionedNegTest cfg "4.7" "test"
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe -g --langversion:5.0" cfg.fsc_flags ["test.fsx"]
singleVersionedNegTest cfg "5.0" "test"
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test2.ok"
fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"]
singleNegTest { cfg with fsc_flags = sprintf "%s --warnaserror-" cfg.fsc_flags } "test2"
exec cfg ("." ++ "test2.exe") ""
testOkFile.CheckExists()
end
begin
csc cfg """/langversion:7.2 /nologo /target:library /out:cslib3.dll""" ["cslib3.cs"]
use testOkFile = fileguard cfg "test3.ok"
fsc cfg "%s -r:cslib3.dll -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"]
singleNegTest { cfg with fsc_flags = sprintf "%s -r:cslib3.dll" cfg.fsc_flags } "test3"
exec cfg ("." ++ "test3.exe") ""
testOkFile.CheckExists()
end
[<Test>]
let span () =
let cfg = testConfig' "core/span"
let cfg = { cfg with fsc_flags = sprintf "%s --test:StackSpan" cfg.fsc_flags}
begin
use testOkFile = fileguard cfg "test.ok"
singleNegTest cfg "test"
fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"]
// Execution is disabled until we can be sure .NET 4.7.2 is on the machine
//exec cfg ("." ++ "test.exe") ""
//testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test2.ok"
singleNegTest cfg "test2"
fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"]
// Execution is disabled until we can be sure .NET 4.7.2 is on the machine
//exec cfg ("." ++ "test.exe") ""
//testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test3.ok"
singleNegTest cfg "test3"
fsc cfg "%s -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"]
// Execution is disabled until we can be sure .NET 4.7.2 is on the machine
//exec cfg ("." ++ "test.exe") ""
//testOkFile.CheckExists()
end
[<Test>]
let asyncStackTraces () =
let cfg = testConfig' "core/asyncStackTraces"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe -g --tailcalls- --optimize-" cfg.fsc_flags ["test.fsx"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-conditionals``() =
let cfg = testConfig' "core/large/conditionals"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-200.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-conditionals-maxtested``() =
let cfg = testConfig' "core/large/conditionals"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-maxtested.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-lets``() =
let cfg = testConfig' "core/large/lets"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-500.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-lets-maxtested``() =
let cfg = testConfig' "core/large/lets"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-maxtested.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-lists``() =
let cfg = testConfig' "core/large/lists"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test-500.exe " cfg.fsc_flags ["LargeList-500.fs"]
exec cfg ("." ++ "test-500.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-matches``() =
let cfg = testConfig' "core/large/matches"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-200.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-matches-maxtested``() =
let cfg = testConfig' "core/large/matches"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-maxtested.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-sequential-and-let``() =
let cfg = testConfig' "core/large/mixed"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-500.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-sequential-and-let-maxtested``() =
let cfg = testConfig' "core/large/mixed"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-maxtested.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-sequential``() =
let cfg = testConfig' "core/large/sequential"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-500.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
[<Test>]
let ``lots-of-sequential-maxtested``() =
let cfg = testConfig' "core/large/sequential"
use testOkFile = fileguard cfg "test.ok"
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-maxtested.fs"]
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
#endif
[<Test>]
let ``control-FSC_BASIC`` () = singleTestBuildAndRun' "core/control" FSC_BASIC
[<Test>]
let ``control-FSI_BASIC`` () = singleTestBuildAndRun' "core/control" FSI_BASIC
[<Test>]
let ``control --tailcalls`` () =
let cfg = testConfig' "core/control"
singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_BASIC
[<Test>]
let ``controlChamenos-FSC_BASIC`` () =
let cfg = testConfig' "core/controlChamenos"
singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_BASIC
[<Test>]
let ``controlChamenos-FSI_BASIC`` () =
let cfg = testConfig' "core/controlChamenos"
singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSI_BASIC
[<Test>]
let ``controlMailbox-FSC_BASIC`` () = singleTestBuildAndRun' "core/controlMailbox" FSC_BASIC
[<Test>]
let ``controlMailbox-FSI_BASIC`` () = singleTestBuildAndRun' "core/controlMailbox" FSI_BASIC
[<Test>]
let ``controlMailbox --tailcalls`` () =
let cfg = testConfig' "core/controlMailbox"
singleTestBuildAndRunAux {cfg with fsi_flags = " --tailcalls" } FSC_BASIC
[<Test>]
let ``csext-FSC_BASIC`` () = singleTestBuildAndRun' "core/csext" FSC_BASIC
[<Test>]
let ``csext-FSI_BASIC`` () = singleTestBuildAndRun' "core/csext" FSI_BASIC
[<Test>]
let ``enum-FSC_BASIC`` () = singleTestBuildAndRun' "core/enum" FSC_BASIC
[<Test>]
let ``enum-FSI_BASIC`` () = singleTestBuildAndRun' "core/enum" FSI_BASIC
#if !NETCOREAPP
// Requires winforms will not run on coreclr
[<Test>]
let controlWpf () = singleTestBuildAndRun' "core/controlwpf" FSC_BASIC
// These tests are enabled for .NET Framework
[<Test>]
let ``anon-FSC_BASIC``() =
let cfg = testConfig' "core/anon"
fsc cfg "%s -a -o:lib.dll" cfg.fsc_flags ["lib.fs"]
peverify cfg "lib.dll"
fsc cfg "%s -r:lib.dll" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
begin
use testOkFile = fileguard cfg "test.ok"
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test.ok"
fsi cfg "-r:lib.dll" ["test.fsx"]
testOkFile.CheckExists()
end
[<Test>]
let events () =
let cfg = testConfig' "core/events"
fsc cfg "%s -a -o:test.dll -g" cfg.fsc_flags ["test.fs"]
peverify cfg "test.dll"
csc cfg """/r:"%s" /reference:test.dll /debug+""" cfg.FSCOREDLLPATH ["testcs.cs"]
peverify cfg "testcs.exe"
use testOkFile = fileguard cfg "test.ok"
fsi cfg "" ["test.fs"]
testOkFile.CheckExists()
exec cfg ("." ++ "testcs.exe") ""
//
// Shadowcopy does not work for public signed assemblies
// =====================================================
//
//module ``FSI-Shadowcopy`` =
//
// [<Test>]
// // "%FSI%" %fsi_flags% < test1.fsx
// [<FSharpSuiteTestCase("core/fsi-shadowcopy", "")
// // "%FSI%" %fsi_flags% --shadowcopyreferences- < test1.fsx
// [<FSharpSuiteTestCase("core/fsi-shadowcopy", "--shadowcopyreferences-")
// let ``shadowcopy disabled`` (flags: string) =
// let cfg = testConfig' ()
//
//
//
//
//
// // if exist test1.ok (del /f /q test1.ok)
// use testOkFile = fileguard cfg "test1.ok"
//
// fsiStdin cfg "%s %s" cfg.fsi_flags flags "test1.fsx"
//
// // if NOT EXIST test1.ok goto SetError
// testOkFile.CheckExists()
//
//
// [<Test>]
// // "%FSI%" %fsi_flags% /shadowcopyreferences+ < test2.fsx
// [<FSharpSuiteTestCase("core/fsi-shadowcopy", "/shadowcopyreferences+")
// // "%FSI%" %fsi_flags% --shadowcopyreferences < test2.fsx
// [<FSharpSuiteTestCase("core/fsi-shadowcopy", "--shadowcopyreferences")
// let ``shadowcopy enabled`` (flags: string) =
// let cfg = testConfig' ()
//
//
//
//
//
// // if exist test2.ok (del /f /q test2.ok)
// use testOkFile = fileguard cfg "test2.ok"
//
// // "%FSI%" %fsi_flags% /shadowcopyreferences+ < test2.fsx
// fsiStdin cfg "%s %s" cfg.fsi_flags flags "test2.fsx"
//
// // if NOT EXIST test2.ok goto SetError
// testOkFile.CheckExists()
//
[<Test>]
let forwarders () =
let cfg = testConfig' "core/forwarders"
mkdir cfg "orig"
mkdir cfg "split"
csc cfg """/nologo /target:library /out:orig\a.dll /define:PART1;PART2""" ["a.cs"]
csc cfg """/nologo /target:library /out:orig\b.dll /r:orig\a.dll""" ["b.cs"]
fsc cfg """-a -o:orig\c.dll -r:orig\b.dll -r:orig\a.dll""" ["c.fs"]
csc cfg """/nologo /target:library /out:split\a-part1.dll /define:PART1;SPLIT""" ["a.cs"]
csc cfg """/nologo /target:library /r:split\a-part1.dll /out:split\a.dll /define:PART2;SPLIT""" ["a.cs"]
copy_y cfg ("orig" ++ "b.dll") ("split" ++ "b.dll")
copy_y cfg ("orig" ++ "c.dll") ("split" ++ "c.dll")
fsc cfg """-o:orig\test.exe -r:orig\b.dll -r:orig\a.dll""" ["test.fs"]
fsc cfg """-o:split\test.exe -r:split\b.dll -r:split\a-part1.dll -r:split\a.dll""" ["test.fs"]
fsc cfg """-o:split\test-against-c.exe -r:split\c.dll -r:split\a-part1.dll -r:split\a.dll""" ["test.fs"]
peverify cfg ("split" ++ "a-part1.dll")
peverify cfg ("split" ++ "b.dll")
peverify cfg ("split" ++ "c.dll")
[<Test>]
let fsfromcs () =
let cfg = testConfig' "core/fsfromcs"
fsc cfg "%s -a --doc:lib.xml -o:lib.dll -g" cfg.fsc_flags ["lib.fs"]
peverify cfg "lib.dll"
csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib.dll /out:test.exe""" cfg.FSCOREDLLPATH ["test.cs"]
fsc cfg """%s -a --doc:lib--optimize.xml -o:lib--optimize.dll -g""" cfg.fsc_flags ["lib.fs"]
peverify cfg "lib--optimize.dll"
csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib--optimize.dll /out:test--optimize.exe""" cfg.FSCOREDLLPATH ["test.cs"]
exec cfg ("." ++ "test.exe") ""
exec cfg ("." ++ "test--optimize.exe") ""
[<Test>]
let fsfromfsviacs () =
let cfg = testConfig' "core/fsfromfsviacs"
fsc cfg "%s -a -o:lib.dll -g" cfg.fsc_flags ["lib.fs"]
peverify cfg "lib.dll"
csc cfg """/nologo /target:library /r:"%s" /r:lib.dll /out:lib2.dll /langversion:7.2""" cfg.FSCOREDLLPATH ["lib2.cs"]
csc cfg """/nologo /target:library /r:"%s" /out:lib3.dll /langversion:7.2""" cfg.FSCOREDLLPATH ["lib3.cs"]
// some features missing in 4.7
for version in ["4.7"] do
let outFile = "compilation.langversion.old.output.txt"
let expectedFile = "compilation.langversion.old.output.bsl"
fscBothToOutExpectFail cfg outFile "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --nologo --define:LANGVERSION_%s --langversion:%s" cfg.fsc_flags (version.Replace(".","_")) version ["test.fsx"]
let diffs = fsdiff cfg outFile expectedFile
match diffs with
| "" -> ()
| _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs)
// all features available in preview
fsc cfg "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --define:LANGVERSION_PREVIEW --langversion:preview" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
exec cfg ("." ++ "test.exe") ""
// Same with library references the other way around
fsc cfg "%s -r:lib.dll -r:lib3.dll -r:lib2.dll -o:test.exe -g --define:LANGVERSION_PREVIEW --langversion:preview" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
exec cfg ("." ++ "test.exe") ""
// Same without the reference to lib.dll - testing an incomplete reference set, but only compiling a subset of the code
fsc cfg "%s --define:NO_LIB_REFERENCE -r:lib3.dll -r:lib2.dll -o:test.exe -g --define:LANGVERSION_PREVIEW --langversion:preview" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
exec cfg ("." ++ "test.exe") ""
// check error messages for some cases
let outFile = "compilation.errors.output.txt"
let expectedFile = "compilation.errors.output.bsl"
fscBothToOutExpectFail cfg outFile "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g --nologo --define:LANGVERSION_PREVIEW --langversion:preview --define:CHECK_ERRORS" cfg.fsc_flags ["test.fsx"]
let diffs = fsdiff cfg outFile expectedFile
match diffs with
| "" -> ()
| _ -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" outFile expectedFile diffs)
[<Test>]
let ``fsi-reference`` () =
let cfg = testConfig' "core/fsi-reference"
begin
use testOkFile = fileguard cfg "test.ok"
fsc cfg @"--target:library -o:ImplementationAssembly\ReferenceAssemblyExample.dll" ["ImplementationAssembly.fs"]
fsc cfg @"--target:library -o:ReferenceAssembly\ReferenceAssemblyExample.dll" ["ReferenceAssembly.fs"]
fsiStdin cfg "test.fsx" "" []
testOkFile.CheckExists()
end
[<Test>]
let ``fsi-reload`` () =
let cfg = testConfig' "core/fsi-reload"
begin
use testOkFile = fileguard cfg "test.ok"
fsiStdin cfg "test1.ml" "--maxerrors:1" []
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test.ok"
fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load1.fsx"]
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test.ok"
fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load2.fsx"]
testOkFile.CheckExists()
end
fsc cfg "" ["load1.fsx"]
fsc cfg "" ["load2.fsx"]
[<Test>]
let fsiAndModifiers () =
let cfg = testConfig' "core/fsiAndModifiers"
do if fileExists cfg "TestLibrary.dll" then rm cfg "TestLibrary.dll"
fsiStdin cfg "prepare.fsx" "--maxerrors:1" []
use testOkFile = fileguard cfg "test.ok"
fsiStdin cfg "test.fsx" "--maxerrors:1" []
testOkFile.CheckExists()
[<Test>]
let ``genericmeasures-AS_DLL`` () = singleTestBuildAndRun' "core/genericmeasures" AS_DLL
[<Test>]
let hiding () =
let cfg = testConfig' "core/hiding"
fsc cfg "%s -a --optimize -o:lib.dll" cfg.fsc_flags ["lib.mli";"lib.ml";"libv.ml"]
peverify cfg "lib.dll"
fsc cfg "%s -a --optimize -r:lib.dll -o:lib2.dll" cfg.fsc_flags ["lib2.mli";"lib2.ml";"lib3.ml"]
peverify cfg "lib2.dll"
fsc cfg "%s --optimize -r:lib.dll -r:lib2.dll -o:client.exe" cfg.fsc_flags ["client.ml"]
peverify cfg "client.exe"
[<Test>]
let ``innerpoly-AS_DLL`` () = singleTestBuildAndRun' "core/innerpoly" AS_DLL
[<Test>]
let queriesCustomQueryOps () =
let cfg = testConfig' "core/queriesCustomQueryOps"
fsc cfg """%s -o:test.exe -g""" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
fsc cfg """%s --optimize -o:test--optimize.exe -g""" cfg.fsc_flags ["test.fsx"]
peverify cfg "test--optimize.exe"
singleNegTest cfg "negativetest"
begin
use testOkFile = fileguard cfg "test.ok"
fsi cfg "%s" cfg.fsi_flags ["test.fsx"]
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test.ok"
exec cfg ("." ++ "test.exe") ""
testOkFile.CheckExists()
end
begin
use testOkFile = fileguard cfg "test.ok"
exec cfg ("." ++ "test--optimize.exe") ""
testOkFile.CheckExists()
end
// Debug with
// ..\..\..\..\debug\net40\bin\fsi.exe --nologo < test.fsx >a.out 2>a.err
// then
/// windiff z.output.test.default.stdout.bsl a.out
let printing flag diffFileOut expectedFileOut diffFileErr expectedFileErr =
let cfg = testConfig' "core/printing"
if requireENCulture () then
let copy from' = Commands.copy_y cfg.Directory from' >> checkResult
let ``fsi <a >b 2>c`` =
// "%FSI%" %fsc_flags_errors_ok% --nologo <test.fsx >z.raw.output.test.default.txt 2>&1
let ``exec <a >b 2>c`` (inFile, outFile, errFile) p =
Command.exec cfg.Directory cfg.EnvironmentVariables { Output = OutputAndError(Overwrite(outFile), Overwrite(errFile)); Input = Some(RedirectInput(inFile)); } p
>> checkResult
Printf.ksprintf (fun flags (inFile, outFile, errFile) -> Commands.fsi (``exec <a >b 2>c`` (inFile, outFile, errFile)) cfg.FSI flags [])
let fsc_flags_errors_ok = ""
let rawFileOut = Path.GetTempFileName()
let rawFileErr = Path.GetTempFileName()
``fsi <a >b 2>c`` "%s --nologo %s" fsc_flags_errors_ok flag ("test.fsx", rawFileOut, rawFileErr)
// REM REVIEW: want to normalise CWD paths, not suppress them.
let ``findstr /v`` text = Seq.filter (fun (s: string) -> not <| s.Contains(text))
let removeCDandHelp from' to' =
File.ReadLines from' |> (``findstr /v`` cfg.Directory) |> (``findstr /v`` "--help' for options") |> (fun lines -> File.WriteAllLines(getfullpath cfg to', lines))
removeCDandHelp rawFileOut diffFileOut
removeCDandHelp rawFileErr diffFileErr
let withDefault default' to' =
if not (fileExists cfg to') then copy default' to'
expectedFileOut |> withDefault diffFileOut
expectedFileErr |> withDefault diffFileErr
match fsdiff cfg diffFileOut expectedFileOut with
| "" -> ()
| diffs -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" diffFileOut expectedFileOut diffs)
match fsdiff cfg diffFileErr expectedFileErr with
| "" -> ()
| diffs -> Assert.Fail (sprintf "'%s' and '%s' differ; %A" diffFileErr expectedFileErr diffs)
[<Test>]
let ``printing-1 --langversion:4.7`` () =
printing "--langversion:4.7" "z.output.test.default.stdout.47.txt" "z.output.test.default.stdout.47.bsl" "z.output.test.default.stderr.txt" "z.output.test.default.stderr.bsl"
[<Test>]
let ``printing-1 --langversion:5.0`` () =
printing "--langversion:5.0" "z.output.test.default.stdout.50.txt" "z.output.test.default.stdout.50.bsl" "z.output.test.default.stderr.txt" "z.output.test.default.stderr.bsl"
[<Test>]
let ``printing-2 --langversion:4.7`` () =
printing "--langversion:4.7 --use:preludePrintSize1000.fsx" "z.output.test.1000.stdout.47.txt" "z.output.test.1000.stdout.47.bsl" "z.output.test.1000.stderr.txt" "z.output.test.1000.stderr.bsl"
[<Test>]
let ``printing-2 --langversion:5.0`` () =
printing "--langversion:5.0 --use:preludePrintSize1000.fsx" "z.output.test.1000.stdout.50.txt" "z.output.test.1000.stdout.50.bsl" "z.output.test.1000.stderr.txt" "z.output.test.1000.stderr.bsl"
[<Test>]
let ``printing-3 --langversion:4.7`` () =
printing "--langversion:4.7 --use:preludePrintSize200.fsx" "z.output.test.200.stdout.47.txt" "z.output.test.200.stdout.47.bsl" "z.output.test.200.stderr.txt" "z.output.test.200.stderr.bsl"
[<Test>]
let ``printing-3 --langversion:5.0`` () =
printing "--langversion:5.0 --use:preludePrintSize200.fsx" "z.output.test.200.stdout.50.txt" "z.output.test.200.stdout.50.bsl" "z.output.test.200.stderr.txt" "z.output.test.200.stderr.bsl"
[<Test>]
let ``printing-4 --langversion:4.7`` () =
printing "--langversion:4.7 --use:preludeShowDeclarationValuesFalse.fsx" "z.output.test.off.stdout.47.txt" "z.output.test.off.stdout.47.bsl" "z.output.test.off.stderr.txt" "z.output.test.off.stderr.bsl"
[<Test>]
let ``printing-4 --langversion:5.0`` () =
printing "--langversion:5.0 --use:preludeShowDeclarationValuesFalse.fsx" "z.output.test.off.stdout.50.txt" "z.output.test.off.stdout.50.bsl" "z.output.test.off.stderr.txt" "z.output.test.off.stderr.bsl"
[<Test>]
let ``printing-5`` () =
printing "--quiet" "z.output.test.quiet.stdout.txt" "z.output.test.quiet.stdout.bsl" "z.output.test.quiet.stderr.txt" "z.output.test.quiet.stderr.bsl"
type SigningType =
| DelaySigned
| PublicSigned
| NotSigned
let signedtest(programId:string, args:string, expectedSigning:SigningType) =
let cfg = testConfig' "core/signedtests"
let newFlags = cfg.fsc_flags + " " + args
let exefile = programId + ".exe"
fsc cfg "%s -o:%s" newFlags exefile ["test.fs"]
let assemblyPath = Path.Combine(cfg.Directory, exefile)
let assemblyName = AssemblyName.GetAssemblyName(assemblyPath)
let publicKeyToken = assemblyName.GetPublicKeyToken()
let isPublicKeyTokenPresent = not (Array.isEmpty publicKeyToken)
use exeStream = new FileStream(assemblyPath, FileMode.Open)
let peHeader = PEHeaders(exeStream)
let isSigned = peHeader.CorHeader.Flags.HasFlag(CorFlags.StrongNameSigned)
let actualSigning =
match isSigned, isPublicKeyTokenPresent with
| true, true-> SigningType.PublicSigned
| true, false -> failwith "unreachable"
| false, true -> SigningType.DelaySigned
| false, false -> SigningType.NotSigned
Assert.AreEqual(expectedSigning, actualSigning)
[<Test; Category("signedtest")>]
let ``signedtest-1`` () = signedtest("test-unsigned", "", SigningType.NotSigned)
[<Test; Category("signedtest")>]
let ``signedtest-2`` () = signedtest("test-sha1-full-cl", "--keyfile:sha1full.snk", SigningType.PublicSigned)
[<Test; Category("signedtest")>]
let ``signedtest-3`` () = signedtest("test-sha256-full-cl", "--keyfile:sha256full.snk", SigningType.PublicSigned)
[<Test; Category("signedtest")>]
let ``signedtest-4`` () = signedtest("test-sha512-full-cl", "--keyfile:sha512full.snk", SigningType.PublicSigned)
[<Test; Category("signedtest")>]
let ``signedtest-5`` () = signedtest("test-sha1024-full-cl", "--keyfile:sha1024full.snk", SigningType.PublicSigned)
[<Test; Category("signedtest")>]
let ``signedtest-6`` () = signedtest("test-sha1-delay-cl", "--keyfile:sha1delay.snk --delaysign", SigningType.DelaySigned)
[<Test; Category("signedtest")>]
let ``signedtest-7`` () = signedtest("test-sha256-delay-cl", "--keyfile:sha256delay.snk --delaysign", SigningType.DelaySigned)
[<Test; Category("signedtest")>]
let ``signedtest-8`` () = signedtest("test-sha512-delay-cl", "--keyfile:sha512delay.snk --delaysign", SigningType.DelaySigned)
[<Test; Category("signedtest")>]
let ``signedtest-9`` () = signedtest("test-sha1024-delay-cl", "--keyfile:sha1024delay.snk --delaysign", SigningType.DelaySigned)
// Test SHA1 key full signed Attributes
[<Test; Category("signedtest")>]
let ``signedtest-10`` () = signedtest("test-sha1-full-attributes", "--define:SHA1", SigningType.PublicSigned)
// Test SHA1 key delayl signed Attributes
[<Test; Category("signedtest")>]
let ``signedtest-11`` () = signedtest("test-sha1-delay-attributes", "--keyfile:sha1delay.snk --define:SHA1 --define:DELAY", SigningType.DelaySigned)
[<Test; Category("signedtest")>]
let ``signedtest-12`` () = signedtest("test-sha256-full-attributes", "--define:SHA256", SigningType.PublicSigned)
// Test SHA 256 bit key delay signed Attributes
[<Test; Category("signedtest")>]
let ``signedtest-13`` () = signedtest("test-sha256-delay-attributes", "--define:SHA256 --define:DELAY", SigningType.DelaySigned)
// Test SHA 512 bit key fully signed Attributes
[<Test; Category("signedtest")>]
let ``signedtest-14`` () = signedtest("test-sha512-full-attributes", "--define:SHA512", SigningType.PublicSigned)
// Test SHA 512 bit key delay signed Attributes
[<Test; Category("signedtest")>]
let ``signedtest-15`` () = signedtest("test-sha512-delay-attributes", "--define:SHA512 --define:DELAY", SigningType.DelaySigned)
// Test SHA 1024 bit key fully signed Attributes
[<Test; Category("signedtest")>]
let ``signedtest-16`` () = signedtest("test-sha1024-full-attributes", "--define:SHA1024", SigningType.PublicSigned)
#endif
#if !NETCOREAPP
[<Test>]
let quotes () =
let cfg = testConfig' "core/quotes"
csc cfg """/nologo /target:library /out:cslib.dll""" ["cslib.cs"]
fsc cfg "%s --define:LANGVERSION_PREVIEW --langversion:5.0 -o:test.exe -r cslib.dll -g" cfg.fsc_flags ["test.fsx"]