forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExprTests.fs
3620 lines (3324 loc) · 502 KB
/
ExprTests.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
module FSharp.Compiler.Service.Tests.ExprTests
open Xunit
open FsUnit
open System
open System.IO
open System.Text
open System.Collections.Generic
open System.Diagnostics
open System.Threading
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Diagnostics
open FSharp.Compiler.IO
open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Symbols
open FSharp.Compiler.Symbols.FSharpExprPatterns
open TestFramework
type FSharpCore =
| FC45
| FC46
| FC47
| FC50
static member fsharpVersion fc =
match fc with
| FC45 -> "FSharp.Core 4.5"
| FC46 -> "FSharp.Core 4.6"
| FC47 -> "FSharp.Core 4.7"
| FC50 -> "FSharp.Core 5.0"
[<AutoOpen>]
module internal Utils =
let getTempPath() =
Path.Combine(Path.GetTempPath(), "ExprTests")
/// If it doesn't exists, create a folder 'ExprTests' in local user's %TEMP% folder
let createTempDir() =
let tempPath = getTempPath()
do
if Directory.Exists tempPath then ()
else Directory.CreateDirectory tempPath |> ignore
/// Returns the file name part of a temp file name created with tryCreateTemporaryFileName ()
/// and an added process id and thread id to ensure uniqueness between threads.
let getTempFileName() =
let tempFileName = tryCreateTemporaryFileName ()
try
let tempFile, tempExt = Path.GetFileNameWithoutExtension tempFileName, Path.GetExtension tempFileName
let procId, threadId = Process.GetCurrentProcess().Id, Thread.CurrentThread.ManagedThreadId
String.concat "" [tempFile; "_"; string procId; "_"; string threadId; tempExt] // ext includes dot
finally
try
FileSystem.FileDeleteShim tempFileName
with _ -> ()
/// Clean up after a test is run. If you need to inspect the create *.fs files, change this function to do nothing, or just break here.
let cleanupTempFiles files =
{ new IDisposable with
member _.Dispose() =
for fileName in files do
try
// cleanup: only the source file is written to the temp dir.
FileSystem.FileDeleteShim fileName
with _ -> ()
try
// remove the dir when empty
let tempPath = getTempPath()
if Directory.GetFiles tempPath |> Array.isEmpty then
Directory.Delete tempPath
with _ -> () }
/// Given just a file name, returns it with changed extension located in %TEMP%\ExprTests
let getTempFilePathChangeExt tmp ext =
Path.Combine(getTempPath(), Path.ChangeExtension(tmp, ext))
// This behaves slightly differently on Mono versions, 'null' is printed somethimes, 'None' other times
// Presumably this is very small differences in Mono reflection causing F# printing to change behaviour
// For now just disabling this test. See https://github.com/fsharp/FSharp.Compiler.Service/pull/766
let filterHack l =
l |> List.map (fun (s:string) ->
// potential difference on Mono
s.Replace("ILArrayShape [(Some 0, None)]", "ILArrayShape [(Some 0, null)]")
// spacing difference when run locally in VS
.Replace("I_ldelema (NormalAddress,false,ILArrayShape [(Some 0, null)],!0)]", "I_ldelema (NormalAddress, false, ILArrayShape [(Some 0, null)], !0)]")
// local VS IDE vs CI env difference
.Replace("Operators.Hash<Microsoft.FSharp.Core.string> (x)", "x.GetHashCode()"))
let rec printExpr low (e:FSharpExpr) =
match e with
| AddressOf(e1) -> "&"+printExpr 0 e1
| AddressSet(e1,e2) -> printExpr 0 e1 + " <- " + printExpr 0 e2
| Application(f,tyargs,args) -> quote low (printExpr 10 f + printTyargs tyargs + " " + printCurriedArgs args)
| BaseValue _ -> "base"
| CallWithWitnesses(Some obj,v,tyargs1,tyargs2,witnessL,argsL) -> printObjOpt (Some obj) + v.CompiledName + printTyargs tyargs2 + printTupledArgs (witnessL @ argsL)
| CallWithWitnesses(None,v,tyargs1,tyargs2,witnessL,argsL) -> v.DeclaringEntity.Value.CompiledName + printTyargs tyargs1 + "." + v.CompiledName + printTyargs tyargs2 + " " + printTupledArgs (witnessL @ argsL)
| Call(Some obj,v,tyargs1,tyargs2,argsL) -> printObjOpt (Some obj) + v.CompiledName + printTyargs tyargs2 + printTupledArgs argsL
| Call(None,v,tyargs1,tyargs2,argsL) -> v.DeclaringEntity.Value.CompiledName + printTyargs tyargs1 + "." + v.CompiledName + printTyargs tyargs2 + " " + printTupledArgs argsL
| Coerce(ty1,e1) -> quote low (printExpr 10 e1 + " :> " + printTy ty1)
| DefaultValue(ty1) -> "dflt"
| FastIntegerForLoop _ -> "for-loop"
| ILAsm(s,tyargs,args) -> s + printTupledArgs args
| ILFieldGet _ -> "ILFieldGet"
| ILFieldSet _ -> "ILFieldSet"
| IfThenElse (a,b,c) -> "(if " + printExpr 0 a + " then " + printExpr 0 b + " else " + printExpr 0 c + ")"
| Lambda(v,e1) -> "fun " + v.CompiledName + " -> " + printExpr 0 e1
| Let((v,e1, _dp),b) -> "let " + (if v.IsMutable then "mutable " else "") + v.CompiledName + ": " + printTy v.FullType + " = " + printExpr 0 e1 + " in " + printExpr 0 b
| LetRec(vse,b) -> "let rec ... in " + printExpr 0 b
| NewArray(ty,es) -> "[|" + (es |> Seq.map (printExpr 0) |> String.concat "; ") + "|]"
| NewDelegate(ty,es) -> "new-delegate"
| NewObject(v,tys,args) -> "new " + v.DeclaringEntity.Value.CompiledName + printTupledArgs args
| NewRecord(v,args) ->
let fields = v.TypeDefinition.FSharpFields
"{" + ((fields, args) ||> Seq.map2 (fun f a -> f.Name + " = " + printExpr 0 a) |> String.concat "; ") + "}"
| NewAnonRecord(v,args) ->
let fields = v.AnonRecordTypeDetails.SortedFieldNames
"{" + ((fields, args) ||> Seq.map2 (fun f a -> f+ " = " + printExpr 0 a) |> String.concat "; ") + "}"
| NewTuple(v,args) -> printTupledArgs args
| NewUnionCase(ty,uc,args) -> uc.CompiledName + printTupledArgs args
| Quote(e1) -> "quote" + printTupledArgs [e1]
| FSharpFieldGet(obj, ty,f) -> printObjOpt obj + f.Name
| AnonRecordGet(obj, ty, n) -> printExpr 0 obj + "." + ty.AnonRecordTypeDetails.SortedFieldNames[n]
| FSharpFieldSet(obj, ty,f,arg) -> printObjOpt obj + f.Name + " <- " + printExpr 0 arg
| Sequential(e1,e2) -> "(" + printExpr 0 e1 + "; " + printExpr 0 e2 + ")"
| ThisValue _ -> "this"
| TryFinally(e1,e2, _dp1, _dp2) -> "try " + printExpr 0 e1 + " finally " + printExpr 0 e2
| TryWith(e1,_,_,vC,eC, _dp1, _dp2) -> "try " + printExpr 0 e1 + " with " + vC.CompiledName + " -> " + printExpr 0 eC
| TupleGet(ty,n,e1) -> printExpr 10 e1 + ".Item" + string n
| DecisionTree(dtree,targets) -> "match " + printExpr 10 dtree + " targets ..."
| DecisionTreeSuccess (tg,es) -> "$" + string tg
| TypeLambda(gp1,e1) -> "FUN ... -> " + printExpr 0 e1
| TypeTest(ty,e1) -> printExpr 10 e1 + " :? " + printTy ty
| UnionCaseSet(obj,ty,uc,f1,e1) -> printExpr 10 obj + "." + f1.Name + " <- " + printExpr 0 e1
| UnionCaseGet(obj,ty,uc,f1) -> printExpr 10 obj + "." + f1.Name
| UnionCaseTest(obj,ty,f1) -> printExpr 10 obj + ".Is" + f1.Name
| UnionCaseTag(obj,ty) -> printExpr 10 obj + ".Tag"
| ObjectExpr(ty,basecall,overrides,iimpls) -> "{ " + printExpr 10 basecall + " with " + printOverrides overrides + " " + printIimpls iimpls + " }"
| TraitCall(tys,nm,_,argtys,tinst,args) -> "trait call " + nm + printTupledArgs args
| Const(obj,ty) ->
match obj with
| :? string as s -> "\"" + s + "\""
| null -> "()"
| _ -> string obj
| Value(v) -> v.CompiledName
| ValueSet(v,e1) -> quote low (v.CompiledName + " <- " + printExpr 0 e1)
| WhileLoop(e1,e2, _dp) -> "while " + printExpr 0 e1 + " do " + printExpr 0 e2 + " done"
| DebugPoint(_dp, innerExpr) -> printExpr low innerExpr
| _ -> failwith (sprintf "unrecognized %+A" e)
and quote low s = if low > 0 then "(" + s + ")" else s
and printObjOpt e = match e with None -> "" | Some e -> printExpr 10 e + "."
and printTupledArgs args = "(" + String.concat "," (List.map (printExpr 0) args) + ")"
and printCurriedArgs args = String.concat " " (List.map (printExpr 10) args)
and printParams (vs: FSharpMemberOrFunctionOrValue list) = "(" + String.concat "," (vs |> List.map (fun v -> v.CompiledName)) + ")"
and printCurriedParams (vs: FSharpMemberOrFunctionOrValue list list) = String.concat " " (List.map printParams vs)
and printTy ty = ty.Format(FSharpDisplayContext.Empty)
and printTyargs tyargs = match tyargs with [] -> "" | args -> "<" + String.concat "," (List.map printTy tyargs) + ">"
and printOverrides ors = String.concat ";" (List.map printOverride ors)
and printOverride o =
match o.CurriedParameterGroups with
| [t] :: a ->
"member " + t.CompiledName + "." + o.Signature.Name + printCurriedParams a + " = " + printExpr 10 o.Body
| _ -> failwith "wrong this argument in object expression override"
and printIimpls iis = String.concat ";" (List.map printImlementation iis)
and printImlementation (i, ors) = "interface " + printTy i + " with " + printOverrides ors
let rec printFSharpDecls prefix decls =
seq {
let mutable i = 0
for decl in decls do
i <- i + 1
match decl with
| FSharpImplementationFileDeclaration.Entity (e, sub) ->
yield sprintf "%s%i) ENTITY: %s %A" prefix i e.CompiledName (attribsOfSymbol e)
if not (Seq.isEmpty e.Attributes) then
yield sprintf "%sattributes: %A" prefix (Seq.toList e.Attributes)
if not (Seq.isEmpty e.DeclaredInterfaces) then
yield sprintf "%sinterfaces: %A" prefix (Seq.toList e.DeclaredInterfaces)
yield ""
yield! printFSharpDecls (prefix + "\t") sub
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue (meth, args, body) ->
yield sprintf "%s%i) METHOD: %s %A" prefix i meth.CompiledName (attribsOfSymbol meth)
yield sprintf "%stype: %A" prefix meth.FullType
yield sprintf "%sargs: %A" prefix args
// if not meth.IsCompilerGenerated then
yield sprintf "%sbody: %A" prefix body
yield ""
| FSharpImplementationFileDeclaration.InitAction expr ->
yield sprintf "%s%i) ACTION" prefix i
yield sprintf "%s%A" prefix expr
yield ""
}
let rec printDeclaration (excludes:HashSet<_> option) (d: FSharpImplementationFileDeclaration) =
seq {
match d with
| FSharpImplementationFileDeclaration.Entity(e,ds) ->
yield sprintf "type %s" e.LogicalName
yield! printDeclarations excludes ds
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(v,vs,e) ->
if not v.IsCompilerGenerated &&
not (match excludes with None -> false | Some t -> t.Contains v.CompiledName) then
let text =
//printfn "%s" v.CompiledName
// try
if v.IsMember then
sprintf "member %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToString())
else
sprintf "let %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToString())
// with e ->
// printfn "FAILURE STACK: %A" e
// sprintf "!!!!!!!!!! FAILED on %s @ %s, message: %s" v.CompiledName (v.DeclarationLocation.ToString()) e.Message
yield text
| FSharpImplementationFileDeclaration.InitAction(e) ->
yield sprintf "do %s" (printExpr 0 e) }
and printDeclarations excludes ds =
seq { for d in ds do
yield! printDeclaration excludes d }
let rec exprsOfDecl (d: FSharpImplementationFileDeclaration) =
seq {
match d with
| FSharpImplementationFileDeclaration.Entity(e,ds) ->
yield! exprsOfDecls ds
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(v,vs,e) ->
if not v.IsCompilerGenerated then
yield e, e.Range
| FSharpImplementationFileDeclaration.InitAction(e) ->
yield e, e.Range }
and exprsOfDecls ds =
seq { for d in ds do
yield! exprsOfDecl d }
let printGenericConstraint name (p: FSharpGenericParameterConstraint) =
if p.IsCoercesToConstraint then
Some <| name + " :> " + printTy p.CoercesToTarget
elif p.IsComparisonConstraint then
Some <| name + " : comparison"
elif p.IsEqualityConstraint then
Some <| name + " : equality"
elif p.IsReferenceTypeConstraint then
Some <| name + " : class"
elif p.IsNonNullableValueTypeConstraint then
Some <| name + " : struct"
elif p.IsEnumConstraint then
Some <| name + " : enum"
elif p.IsSupportsNullConstraint then
Some <| name + " : null"
else None
let printGenericParameter (p: FSharpGenericParameter) =
let name =
if p.Name.StartsWith("?", StringComparison.Ordinal) then "_"
elif p.IsSolveAtCompileTime then "^" + p.Name
else "'" + p.Name
let constraints =
p.Constraints |> Seq.choose (printGenericConstraint name) |> List.ofSeq
name, constraints
let printMemberSignature (v: FSharpMemberOrFunctionOrValue) =
let genParams =
let ps = v.GenericParameters |> Seq.map printGenericParameter |> List.ofSeq
if List.isEmpty ps then "" else
let constraints = ps |> List.collect snd
"<" + (ps |> Seq.map fst |> String.concat ", ") +
(if List.isEmpty constraints then "" else " when " + String.concat " and " constraints) + ">"
v.CompiledName + genParams + ": " + printTy v.FullType
let rec collectMembers (e:FSharpExpr) =
match e with
| AddressOf(e) -> collectMembers e
| AddressSet(e1,e2) -> Seq.append (collectMembers e1) (collectMembers e2)
| Application(f,_,args) -> Seq.append (collectMembers f) (Seq.collect collectMembers args)
| BaseValue _ -> Seq.empty
| Call(Some obj,v,_,_,argsL) -> Seq.concat [ collectMembers obj; Seq.singleton v; Seq.collect collectMembers argsL ]
| Call(None,v,_,_,argsL) -> Seq.concat [ Seq.singleton v; Seq.collect collectMembers argsL ]
| Coerce(_,e) -> collectMembers e
| DefaultValue _ -> Seq.empty
| FastIntegerForLoop (fromArg, toArg, body, _, _dp1, _dp2) -> Seq.collect collectMembers [ fromArg; toArg; body ]
| ILAsm(_,_,args) -> Seq.collect collectMembers args
| ILFieldGet (Some e,_,_) -> collectMembers e
| ILFieldGet _ -> Seq.empty
| ILFieldSet (Some e,_,_,v) -> Seq.append (collectMembers e) (collectMembers v)
| ILFieldSet _ -> Seq.empty
| IfThenElse (a,b,c) -> Seq.collect collectMembers [ a; b; c ]
| Lambda(v,e1) -> collectMembers e1
| Let((v,e1, _dp),b) -> Seq.append (collectMembers e1) (collectMembers b)
| LetRec(vse,b) -> Seq.append (vse |> Seq.collect (fun (_, a, _) -> a |> collectMembers)) (collectMembers b)
| NewArray(_,es) -> Seq.collect collectMembers es
| NewDelegate(ty,es) -> collectMembers es
| NewObject(v,tys,args) -> Seq.append (Seq.singleton v) (Seq.collect collectMembers args)
| NewRecord(v,args) -> Seq.collect collectMembers args
| NewTuple(v,args) -> Seq.collect collectMembers args
| NewUnionCase(ty,uc,args) -> Seq.collect collectMembers args
| Quote(e1) -> collectMembers e1
| FSharpFieldGet(Some obj, _,_) -> collectMembers obj
| FSharpFieldGet _ -> Seq.empty
| FSharpFieldSet(Some obj,_,_,arg) -> Seq.append (collectMembers obj) (collectMembers arg)
| FSharpFieldSet(None,_,_,arg) -> collectMembers arg
| Sequential(e1,e2) -> Seq.append (collectMembers e1) (collectMembers e2)
| ThisValue _ -> Seq.empty
| TryFinally(e1,e2, _dp1, _dp2) -> Seq.append (collectMembers e1) (collectMembers e2)
| TryWith(e1,_,f,_,eC, _dp1, _dp2) -> Seq.collect collectMembers [ e1; f; eC ]
| TupleGet(ty,n,e1) -> collectMembers e1
| DecisionTree(dtree,targets) -> Seq.append (collectMembers dtree) (targets |> Seq.collect (snd >> collectMembers))
| DecisionTreeSuccess (tg,es) -> Seq.collect collectMembers es
| TypeLambda(gp1,e1) -> collectMembers e1
| TypeTest(ty,e1) -> collectMembers e1
| UnionCaseSet(obj,ty,uc,f1,e1) -> Seq.append (collectMembers obj) (collectMembers e1)
| UnionCaseGet(obj,ty,uc,f1) -> collectMembers obj
| UnionCaseTest(obj,ty,f1) -> collectMembers obj
| UnionCaseTag(obj,ty) -> collectMembers obj
| ObjectExpr(ty,basecall,overrides,iimpls) ->
seq {
yield! collectMembers basecall
for o in overrides do
yield! collectMembers o.Body
for _, i in iimpls do
for o in i do
yield! collectMembers o.Body
}
| TraitCall(tys,nm,_,argtys,tinst,args) -> Seq.collect collectMembers args
| Const(obj,ty) -> Seq.empty
| Value(v) -> Seq.singleton v
| ValueSet(v,e1) -> Seq.append (Seq.singleton v) (collectMembers e1)
| WhileLoop(e1,e2,_dp) -> Seq.append (collectMembers e1) (collectMembers e2)
| DebugPoint(_dp, innerExpr) -> collectMembers innerExpr
| _ -> failwith (sprintf "unrecognized %+A" e)
let rec printMembersOfDeclatations ds =
seq {
for d in ds do
match d with
| FSharpImplementationFileDeclaration.Entity(_,ds) ->
yield! printMembersOfDeclatations ds
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(v,vs,e) ->
yield printMemberSignature v
yield! collectMembers e |> Seq.map printMemberSignature
| FSharpImplementationFileDeclaration.InitAction(e) ->
yield! collectMembers e |> Seq.map printMemberSignature
}
let createOptionsAux fileSources extraArgs =
let fileNames = fileSources |> List.map (fun _ -> Utils.getTempFileName())
let temp2 = Utils.getTempFileName()
let fileNames = fileNames |> List.map (fun temp1 -> Utils.getTempFilePathChangeExt temp1 ".fs")
let dllName = Utils.getTempFilePathChangeExt temp2 ".dll"
let projFileName = Utils.getTempFilePathChangeExt temp2 ".fsproj"
Utils.createTempDir()
for fileSource: string, fileName in List.zip fileSources fileNames do
FileSystem.OpenFileForWriteShim(fileName).Write(fileSource)
let args = [| yield! extraArgs; yield! mkProjectCommandLineArgs (dllName, []) |]
let options = { checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) with SourceFiles = fileNames |> List.toArray }
Utils.cleanupTempFiles (fileNames @ [dllName; projFileName]), options
//---------------------------------------------------------------------------------------------------------
// This project is a smoke test for a whole range of standard and obscure expressions
module internal Project1 =
let fileSource1 = """
module M
type IntAbbrev = int
let boolEx1 = true
let intEx1 = 1
let int64Ex1 = 1L
let tupleEx1 = (1, 1L)
let tupleEx2 = (1, 1L, 1u)
let tupleEx3 = (1, 1L, 1u, 1s)
let localExample =
let y = 1
let z = 1
y, z
let localGenericFunctionExample() =
let y = 1
let compiledAsLocalGenericFunction x = x
compiledAsLocalGenericFunction y, compiledAsLocalGenericFunction 1.0
let funcEx1 (x:int) = x
let genericFuncEx1 (x:'T) = x
let (topPair1a, topPair1b) = (1,2)
let testILCall1 = new obj()
let testILCall2 = System.Console.WriteLine("176")
// Test recursive values in a module
let rec recValNeverUsedAtRuntime = recFuncIgnoresFirstArg (fun _ -> recValNeverUsedAtRuntime) 1
and recFuncIgnoresFirstArg g v = v
let testFun4() =
// Test recursive values in expression position
let rec recValNeverUsedAtRuntime = recFuncIgnoresFirstArg (fun _ -> recValNeverUsedAtRuntime) 1
and recFuncIgnoresFirstArg g v = v
recValNeverUsedAtRuntime
type ClassWithImplicitConstructor(compiledAsArg: int) =
inherit obj()
let compiledAsField = 1
let compiledAsLocal = 1
let compiledAsLocal2 = compiledAsLocal + compiledAsLocal
let compiledAsInstanceMethod () = compiledAsField + compiledAsField
let compiledAsGenericInstanceMethod x = x
static let compiledAsStaticField = 1
static let compiledAsStaticLocal = 1
static let compiledAsStaticLocal2 = compiledAsStaticLocal + compiledAsStaticLocal
static let compiledAsStaticMethod () = compiledAsStaticField + compiledAsStaticField
static let compiledAsGenericStaticMethod x = x
member __.M1() = compiledAsField + compiledAsGenericInstanceMethod compiledAsField + compiledAsArg
member __.M2() = compiledAsInstanceMethod()
static member SM1() = compiledAsStaticField + compiledAsGenericStaticMethod compiledAsStaticField
static member SM2() = compiledAsStaticMethod()
//override _.ToString() = base.ToString() + string 999
member this.TestCallinToString() = this.ToString()
exception Error of int * int
let err = Error(3,4)
let matchOnException err = match err with Error(a,b) -> 3 | e -> raise e
let upwardForLoop () =
let mutable a = 1
for i in 0 .. 10 do a <- a + 1
a
let upwardForLoop2 () =
let mutable a = 1
for i = 0 to 10 do a <- a + 1
a
let downwardForLoop () =
let mutable a = 1
for i = 10 downto 1 do a <- a + 1
a
let quotationTest1() = <@ 1 + 1 @>
let quotationTest2 v = <@ %v + 1 @>
type RecdType = { Field1: int; Field2: int }
type UnionType = Case1 of int | Case2 | Case3 of int * string
type ClassWithEventsAndProperties() =
let ev = new Event<_>()
static let sev = new Event<_>()
member x.InstanceProperty = ev.Trigger(1); 1
static member StaticProperty = sev.Trigger(1); 1
member x.InstanceEvent = ev.Publish
member x.StaticEvent = sev.Publish
let c = ClassWithEventsAndProperties()
let v = c.InstanceProperty
System.Console.WriteLine("777") // do a top-levl action
let functionWithSubmsumption(x:obj) = x :?> string
//let functionWithCoercion(x:string) = (x :> obj) :?> string |> functionWithSubmsumption |> functionWithSubmsumption
type MultiArgMethods(c:int,d:int) =
member x.Method(a:int, b : int) = 1
member x.CurriedMethod(a1:int, b1: int) (a2:int, b2:int) = 1
let testFunctionThatCallsMultiArgMethods() =
let m = MultiArgMethods(3,4)
(m.Method(7,8) + m.CurriedMethod (9,10) (11,12))
//let functionThatUsesObjectExpression() =
// { new obj() with member x.ToString() = string 888 }
//
//let functionThatUsesObjectExpressionWithInterfaceImpl() =
// { new obj() with
// member x.ToString() = string 888
// interface System.IComparable with
// member x.CompareTo(y:obj) = 0 }
let testFunctionThatUsesUnitsOfMeasure (x : float<_>) (y: float<_>) = x + y
let testFunctionThatUsesAddressesAndByrefs (x: byref<int>) =
let mutable w = 4
let y1 = &x // address-of
let y2 = &w // address-of
let arr = [| 3;4 |] // address-of
let r = ref 3 // address-of
let y3 = &arr.[0] // address-of array
let y4 = &r.contents // address-of field
let z = x + y1 + y2 + y3 // dereference
w <- 3 // assign to pointer
x <- 4 // assign to byref
y2 <- 4 // assign to byref
y3 <- 5 // assign to byref
z + x + y1 + y2 + y3 + y4 + arr.[0] + r.contents
let testFunctionThatUsesStructs1 (dt:System.DateTime) = dt.AddDays(3.0)
let testFunctionThatUsesStructs2 () =
let dt1 = System.DateTime.Now
let mutable dt2 = System.DateTime.Now
let dt3 = dt1 - dt2
let dt4 = dt1.AddDays(3.0)
let dt5 = dt1.Millisecond
let dt6 = &dt2
let dt7 = dt6 - dt4
dt7
let testFunctionThatUsesWhileLoop() =
let mutable x = 1
while x < 100 do
x <- x + 1
x
let testFunctionThatUsesTryWith() =
try
testFunctionThatUsesWhileLoop()
with :? System.ArgumentException as e -> e.Message.Length
let testFunctionThatUsesTryFinally() =
try
testFunctionThatUsesWhileLoop()
finally
System.Console.WriteLine("8888")
type System.Console with
static member WriteTwoLines() = System.Console.WriteLine(); System.Console.WriteLine()
type System.DateTime with
member x.TwoMinute = x.Minute + x.Minute
let testFunctionThatUsesExtensionMembers() =
System.Console.WriteTwoLines()
let v = System.DateTime.Now.TwoMinute
System.Console.WriteTwoLines()
let testFunctionThatUsesOptionMembers() =
let x = Some(3)
(x.IsSome, x.IsNone)
let testFunctionThatUsesOverAppliedFunction() =
id id 3
let testFunctionThatUsesPatternMatchingOnLists(x) =
match x with
| [] -> 1
| [h] -> 2
| [h;h2] -> 3
| _ -> 4
let testFunctionThatUsesPatternMatchingOnOptions(x) =
match x with
| None -> 1
| Some h -> 2 + h
let testFunctionThatUsesPatternMatchingOnOptions2(x) =
match x with
| None -> 1
| Some _ -> 2
let testFunctionThatUsesConditionalOnOptions2(x: int option) =
if x.IsSome then 1 else 2
let f x y = x+y
let g = f 1
let h = (g 2) + 3
type TestFuncProp() =
member this.Id = fun x -> x
let wrong = TestFuncProp().Id 0 = 0
let start (name:string) =
name, name
let last (name:string, values:string ) =
id (name, values)
let last2 (name:string) =
id name
let test7(s:string) =
start s |> last
let test8() =
last
let test9(s:string) =
(s,s) |> last
let test10() =
last2
let test11(s:string) =
s |> last2
let rec badLoop : (int -> int) =
() // so that it is a function value
fun x -> badLoop (x + 1)
module LetLambda =
let f =
() // so that it is a function value
fun a b -> a + b
let letLambdaRes = [ 1, 2 ] |> List.map (fun (a, b) -> LetLambda.f a b)
let anonRecd = {| X = 1; Y = 2 |}
let anonRecdGet = (anonRecd.X, anonRecd.Y)
"""
let fileSource2 = """
module N
type IntAbbrev = int
let bool2 = false
let testHashChar (x:char) = hash x
let testHashSByte (x:sbyte) = hash x
let testHashInt16 (x:int16) = hash x
let testHashInt64 (x:int64) = hash x
let testHashUInt64 (x:uint64) = hash x
let testHashIntPtr (x:nativeint) = hash x
let testHashUIntPtr (x:unativeint) = hash x
let testHashString (x:string) = hash x
let testTypeOf (x:'T) = typeof<'T>
let inline mutableVar x =
if x > 0 then
let mutable acc = x
acc <- x
let inline mutableConst () =
let mutable acc = ()
acc <- ()
let testMutableVar = mutableVar 1
let testMutableConst = mutableConst ()
"""
let createOptionsWithArgs args = createOptionsAux [ fileSource1; fileSource2 ] args
let createOptions() = createOptionsWithArgs []
let operatorTests = """
module OperatorTests{0}
let test{0}EqualsOperator (e1:{1}) (e2:{1}) = (=) e1 e2
let test{0}NotEqualsOperator (e1:{1}) (e2:{1}) = (<>) e1 e2
let test{0}LessThanOperator (e1:{1}) (e2:{1}) = (<) e1 e2
let test{0}LessThanOrEqualsOperator (e1:{1}) (e2:{1}) = (<=) e1 e2
let test{0}GreaterThanOperator (e1:{1}) (e2:{1}) = (>) e1 e2
let test{0}GreaterThanOrEqualsOperator (e1:{1}) (e2:{1}) = (>=) e1 e2
let test{0}AdditionOperator (e1:{1}) (e2:{1}) = (+) e1 e2
let test{0}SubtractionOperator (e1:{1}) (e2:{1}) = (-) e1 e2
let test{0}MultiplyOperator (e1:{1}) (e2:{1}) = (*) e1 e2
let test{0}DivisionOperator (e1:{1}) (e2:{1}) = (/) e1 e2
let test{0}ModulusOperator (e1:{1}) (e2:{1}) = (%) e1 e2
let test{0}BitwiseAndOperator (e1:{1}) (e2:{1}) = (&&&) e1 e2
let test{0}BitwiseOrOperator (e1:{1}) (e2:{1}) = (|||) e1 e2
let test{0}BitwiseXorOperator (e1:{1}) (e2:{1}) = (^^^) e1 e2
let test{0}ShiftLeftOperator (e1:{1}) (e2:int) = (<<<) e1 e2
let test{0}ShiftRightOperator (e1:{1}) (e2:int) = (>>>) e1 e2
let test{0}UnaryNegOperator (e1:{1}) = (~-) e1
let test{0}AdditionChecked (e1:{1}) (e2:{1}) = Checked.(+) e1 e2
let test{0}SubtractionChecked (e1:{1}) (e2:{1}) = Checked.(-) e1 e2
let test{0}MultiplyChecked (e1:{1}) (e2:{1}) = Checked.(*) e1 e2
let test{0}UnaryNegChecked (e1:{1}) = Checked.(~-) e1
let test{0}ToByteChecked (e1:{1}) = Checked.byte e1
let test{0}ToSByteChecked (e1:{1}) = Checked.sbyte e1
let test{0}ToInt16Checked (e1:{1}) = Checked.int16 e1
let test{0}ToUInt16Checked (e1:{1}) = Checked.uint16 e1
let test{0}ToIntChecked (e1:{1}) = Checked.int e1
let test{0}ToInt32Checked (e1:{1}) = Checked.int32 e1
let test{0}ToUInt32Checked (e1:{1}) = Checked.uint32 e1
let test{0}ToInt64Checked (e1:{1}) = Checked.int64 e1
let test{0}ToUInt64Checked (e1:{1}) = Checked.uint64 e1
let test{0}ToIntPtrChecked (e1:{1}) = Checked.nativeint e1
let test{0}ToUIntPtrChecked (e1:{1}) = Checked.unativeint e1
let test{0}ToByteOperator (e1:{1}) = byte e1
let test{0}ToSByteOperator (e1:{1}) = sbyte e1
let test{0}ToInt16Operator (e1:{1}) = int16 e1
let test{0}ToUInt16Operator (e1:{1}) = uint16 e1
let test{0}ToIntOperator (e1:{1}) = int e1
let test{0}ToInt32Operator (e1:{1}) = int32 e1
let test{0}ToUInt32Operator (e1:{1}) = uint32 e1
let test{0}ToInt64Operator (e1:{1}) = int64 e1
let test{0}ToUInt64Operator (e1:{1}) = uint64 e1
let test{0}ToIntPtrOperator (e1:{1}) = nativeint e1
let test{0}ToUIntPtrOperator (e1:{1}) = unativeint e1
let test{0}ToSingleOperator (e1:{1}) = float32 e1
let test{0}ToDoubleOperator (e1:{1}) = float e1
let test{0}ToDecimalOperator (e1:{1}) = decimal e1
let test{0}ToCharOperator (e1:{1}) = char e1
let test{0}ToStringOperator (e1:{1}) = string e1
"""
/// This test is run in unison with its optimized counterpart below
[<Theory>]
[<InlineData(false)>]
[<InlineData(true)>]
let ``Test Unoptimized Declarations Project1`` useTransparentCompiler =
let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ]
use _holder = cleanup
let exprChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler)
let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate
for e in wholeProjectResults.Diagnostics do
printfn "Project1 error: <<<%s>>>" e.Message
wholeProjectResults.Diagnostics.Length |> shouldEqual 3 // recursive value warning
wholeProjectResults.Diagnostics[0].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning
wholeProjectResults.Diagnostics[1].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning
wholeProjectResults.Diagnostics[2].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning
wholeProjectResults.AssemblyContents.ImplementationFiles.Length |> shouldEqual 2
let file1 = wholeProjectResults.AssemblyContents.ImplementationFiles[0]
let file2 = wholeProjectResults.AssemblyContents.ImplementationFiles[1]
let expected =
["type M"; "type IntAbbrev"; "let boolEx1 = True @ (6,14--6,18)";
"let intEx1 = 1 @ (7,13--7,14)"; "let int64Ex1 = 1 @ (8,15--8,17)";
"let tupleEx1 = (1,1) @ (9,16--9,21)";
"let tupleEx2 = (1,1,1) @ (10,16--10,25)";
"let tupleEx3 = (1,1,1,1) @ (11,16--11,29)";
"let localExample = let y: Microsoft.FSharp.Core.int = 1 in let z: Microsoft.FSharp.Core.int = 1 in (y,z) @ (14,7--14,8)";
"let localGenericFunctionExample(unitVar0) = let y: Microsoft.FSharp.Core.int = 1 in let compiledAsLocalGenericFunction: 'a -> 'a = FUN ... -> fun x -> x in (compiledAsLocalGenericFunction<Microsoft.FSharp.Core.int> y,compiledAsLocalGenericFunction<Microsoft.FSharp.Core.float> 1) @ (19,7--19,8)";
"let funcEx1(x) = x @ (23,23--23,24)";
"let genericFuncEx1(x) = x @ (24,29--24,30)";
"let topPair1b = M.patternInput@25 ().Item1 @ (25,4--25,26)";
"let topPair1a = M.patternInput@25 ().Item0 @ (25,4--25,26)";
"let testILCall1 = new Object() @ (27,18--27,27)";
"let testILCall2 = Console.WriteLine (\"176\") @ (28,18--28,49)";
"let recValNeverUsedAtRuntime = [email protected]<Microsoft.FSharp.Core.int>(()) @ (31,8--31,32)";
"let recFuncIgnoresFirstArg(g) (v) = v @ (32,33--32,34)";
"let testFun4(unitVar0) = let rec ... in recValNeverUsedAtRuntime @ (36,4--39,28)";
"type ClassWithImplicitConstructor";
"member .ctor(compiledAsArg) = (new Object(); (this.compiledAsArg <- compiledAsArg; (this.compiledAsField <- 1; let compiledAsLocal: Microsoft.FSharp.Core.int = 1 in let compiledAsLocal2: Microsoft.FSharp.Core.int = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),compiledAsLocal,compiledAsLocal) in ()))) @ (41,5--41,33)";
"member .cctor(unitVar) = (compiledAsStaticField <- 1; let compiledAsStaticLocal: Microsoft.FSharp.Core.int = 1 in let compiledAsStaticLocal2: Microsoft.FSharp.Core.int = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),compiledAsStaticLocal,compiledAsStaticLocal) in ()) @ (49,11--49,40)";
"member M1(__) (unitVar1) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),__.compiledAsField,let x: Microsoft.FSharp.Core.int = __.compiledAsField in __.compiledAsGenericInstanceMethod<Microsoft.FSharp.Core.int>(x)),__.compiledAsArg) @ (55,21--55,102)";
"member M2(__) (unitVar1) = __.compiledAsInstanceMethod(()) @ (56,21--56,47)";
"member SM1(unitVar0) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),compiledAsStaticField,let x: Microsoft.FSharp.Core.int = compiledAsStaticField in ClassWithImplicitConstructor.compiledAsGenericStaticMethod<Microsoft.FSharp.Core.int> (x)) @ (57,26--57,101)";
"member SM2(unitVar0) = ClassWithImplicitConstructor.compiledAsStaticMethod (()) @ (58,26--58,50)";
"member TestCallinToString(this) (unitVar1) = this.ToString() @ (60,39--60,54)";
"type Error"; "let err = {Data0 = 3; Data1 = 4} @ (64,10--64,20)";
"let matchOnException(err) = match (if err :? M.Error then $0 else $1) targets ... @ (66,33--66,36)";
"let upwardForLoop(unitVar0) = let mutable a: Microsoft.FSharp.Core.int = 1 in (for-loop; a) @ (69,16--69,17)";
"let upwardForLoop2(unitVar0) = let mutable a: Microsoft.FSharp.Core.int = 1 in (for-loop; a) @ (74,16--74,17)";
"let downwardForLoop(unitVar0) = let mutable a: Microsoft.FSharp.Core.int = 1 in (for-loop; a) @ (79,16--79,17)";
"let quotationTest1(unitVar0) = quote(Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),1,1)) @ (83,24--83,35)";
"let quotationTest2(v) = quote(Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),ExtraTopLevelOperators.SpliceExpression<Microsoft.FSharp.Core.int> (v),1)) @ (84,24--84,36)";
"type RecdType"; "type UnionType";
"member get_IsCase1(this) (unitArg) = (if this.IsCase1 then True else False) @ (87,5--87,14)";
"member get_IsCase2(this) (unitArg) = (if this.IsCase2 then True else False) @ (87,5--87,14)";
"member get_IsCase3(this) (unitArg) = (if this.IsCase3 then True else False) @ (87,5--87,14)";
"type ClassWithEventsAndProperties";
"member .ctor(unitVar0) = (new Object(); (this.ev <- new FSharpEvent`1(()); ())) @ (89,5--89,33)";
"member .cctor(unitVar) = (sev <- new FSharpEvent`1(()); ()) @ (91,11--91,35)";
"member get_InstanceProperty(x) (unitVar1) = (x.ev.Trigger(1); 1) @ (92,32--92,48)";
"member get_StaticProperty(unitVar0) = (sev.Trigger(1); 1) @ (93,35--93,52)";
"member get_InstanceEvent(x) (unitVar1) = x.ev.get_Publish(()) @ (94,29--94,39)";
"member get_StaticEvent(x) (unitVar1) = sev.get_Publish(()) @ (95,27--95,38)";
"let c = new ClassWithEventsAndProperties(()) @ (97,8--97,38)";
"let v = M.c ().get_InstanceProperty(()) @ (98,8--98,26)";
"do Console.WriteLine (\"777\")";
"let functionWithSubmsumption(x) = IntrinsicFunctions.UnboxGeneric<Microsoft.FSharp.Core.string> (x) @ (102,40--102,52)";
"type MultiArgMethods";
"member .ctor(c,d) = (new Object(); ()) @ (105,5--105,20)";
"member Method(x) (a,b) = 1 @ (106,37--106,38)";
"member CurriedMethod(x) (a1,b1) (a2,b2) = 1 @ (107,63--107,64)";
"let testFunctionThatCallsMultiArgMethods(unitVar0) = let m: M.MultiArgMethods = new MultiArgMethods(3,4) in Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),m.Method(7,8),fun tupledArg -> let a1: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b1: Microsoft.FSharp.Core.int = tupledArg.Item1 in fun tupledArg -> let a2: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b2: Microsoft.FSharp.Core.int = tupledArg.Item1 in m.CurriedMethod(a1,b1,a2,b2) (9,10) (11,12)) @ (110,8--110,9)";
"let testFunctionThatUsesUnitsOfMeasure(x) (y) = Operators.op_Addition<Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>> (arg0_0,arg1_0),x,y) @ (122,70--122,75)";
"let testFunctionThatUsesAddressesAndByrefs(x) = let mutable w: Microsoft.FSharp.Core.int = 4 in let y1: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = x in let y2: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = &w in let arr: Microsoft.FSharp.Core.int Microsoft.FSharp.Core.array = [|3; 4|] in let r: Microsoft.FSharp.Core.int Microsoft.FSharp.Core.ref = Operators.Ref<Microsoft.FSharp.Core.int> (3) in let y3: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = [I_ldelema (NormalAddress, false, ILArrayShape [(Some 0, None)], !0)](arr,0) in let y4: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = &r.contents in let z: Microsoft.FSharp.Core.int = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x,y1),y2),y3) in (w <- 3; (x <- 4; (y2 <- 4; (y3 <- 5; Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),z,x),y1),y2),y3),y4),IntrinsicFunctions.GetArray<Microsoft.FSharp.Core.int> (arr,0)),r.contents))))) @ (125,16--125,17)";
"let testFunctionThatUsesStructs1(dt) = dt.AddDays(3) @ (139,57--139,72)";
"let testFunctionThatUsesStructs2(unitVar0) = let dt1: System.DateTime = DateTime.get_Now () in let mutable dt2: System.DateTime = DateTime.get_Now () in let dt3: System.TimeSpan = Operators.op_Subtraction<System.DateTime,System.DateTime,System.TimeSpan> (fun arg0_0 -> fun arg1_0 -> DateTime.op_Subtraction (arg0_0,arg1_0),dt1,dt2) in let dt4: System.DateTime = dt1.AddDays(3) in let dt5: Microsoft.FSharp.Core.int = dt1.get_Millisecond() in let dt6: Microsoft.FSharp.Core.byref<System.DateTime> = &dt2 in let dt7: System.TimeSpan = Operators.op_Subtraction<System.DateTime,System.DateTime,System.TimeSpan> (fun arg0_0 -> fun arg1_0 -> DateTime.op_Subtraction (arg0_0,arg1_0),dt6,dt4) in dt7 @ (142,7--142,10)";
"let testFunctionThatUsesWhileLoop(unitVar0) = let mutable x: Microsoft.FSharp.Core.int = 1 in (while Operators.op_LessThan<Microsoft.FSharp.Core.int> (x,100) do x <- Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x,1) done; x) @ (152,15--152,16)";
"let testFunctionThatUsesTryWith(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) with matchValue -> match (if matchValue :? System.ArgumentException then $0 else $1) targets ... @ (158,3--160,60)";
"let testFunctionThatUsesTryFinally(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) finally Console.WriteLine (\"8888\") @ (164,3--167,37)";
"member Console.WriteTwoLines.Static(unitVar0) = (Console.WriteLine (); Console.WriteLine ()) @ (170,36--170,90)";
"member DateTime.get_TwoMinute(x) (unitVar1) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x.get_Minute(),x.get_Minute()) @ (173,25--173,44)";
"let testFunctionThatUsesExtensionMembers(unitVar0) = (M.Console.WriteTwoLines.Static (()); let v: Microsoft.FSharp.Core.int = DateTime.get_Now ().DateTime.get_TwoMinute(()) in M.Console.WriteTwoLines.Static (())) @ (176,3--178,33)";
"let testFunctionThatUsesOptionMembers(unitVar0) = let x: Microsoft.FSharp.Core.int Microsoft.FSharp.Core.option = Some(3) in (x.get_IsSome() (),x.get_IsNone() ()) @ (181,7--181,8)";
"let testFunctionThatUsesOverAppliedFunction(unitVar0) = Operators.Identity<Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int> (fun x -> Operators.Identity<Microsoft.FSharp.Core.int> (x)) 3 @ (185,3--185,10)";
"let testFunctionThatUsesPatternMatchingOnLists(x) = match (if x.Isop_ColonColon then (if x.Tail.Isop_ColonColon then (if x.Tail.Tail.Isop_Nil then $2 else $3) else $1) else $0) targets ... @ (188,10--188,11)";
"let testFunctionThatUsesPatternMatchingOnOptions(x) = match (if x.IsSome then $1 else $0) targets ... @ (195,10--195,11)";
"let testFunctionThatUsesPatternMatchingOnOptions2(x) = match (if x.IsSome then $1 else $0) targets ... @ (200,10--200,11)";
"let testFunctionThatUsesConditionalOnOptions2(x) = (if x.get_IsSome() () then 1 else 2) @ (205,4--205,29)";
"let f(x) (y) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x,y) @ (207,12--207,15)";
"let g = let x: Microsoft.FSharp.Core.int = 1 in fun y -> M.f (x,y) @ (208,8--208,11)";
"let h = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),M.g () 2,3) @ (209,8--209,17)";
"type TestFuncProp";
"member .ctor(unitVar0) = (new Object(); ()) @ (211,5--211,17)";
"member get_Id(this) (unitVar1) = fun x -> x @ (212,21--212,31)";
"let wrong = Operators.op_Equality<Microsoft.FSharp.Core.int> (new TestFuncProp(()).get_Id(()) 0,0) @ (214,12--214,35)";
"let start(name) = (name,name) @ (217,4--217,14)";
"let last(name,values) = Operators.Identity<Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string> ((name,values)) @ (220,4--220,21)";
"let last2(name) = Operators.Identity<Microsoft.FSharp.Core.string> (name) @ (223,4--223,11)";
"let test7(s) = Operators.op_PipeRight<Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string,Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string> (M.start (s),fun tupledArg -> let name: Microsoft.FSharp.Core.string = tupledArg.Item0 in let values: Microsoft.FSharp.Core.string = tupledArg.Item1 in M.last (name,values)) @ (226,4--226,19)";
"let test8(unitVar0) = fun tupledArg -> let name: Microsoft.FSharp.Core.string = tupledArg.Item0 in let values: Microsoft.FSharp.Core.string = tupledArg.Item1 in M.last (name,values) @ (229,4--229,8)";
"let test9(s) = Operators.op_PipeRight<Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string,Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string> ((s,s),fun tupledArg -> let name: Microsoft.FSharp.Core.string = tupledArg.Item0 in let values: Microsoft.FSharp.Core.string = tupledArg.Item1 in M.last (name,values)) @ (232,4--232,17)";
"let test10(unitVar0) = fun name -> M.last2 (name) @ (235,4--235,9)";
"let test11(s) = Operators.op_PipeRight<Microsoft.FSharp.Core.string,Microsoft.FSharp.Core.string> (s,fun name -> M.last2 (name)) @ (238,4--238,14)";
"let badLoop = [email protected]<Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int>(()) @ (240,8--240,15)";
"type LetLambda";
"let f = ((); fun a -> fun b -> Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),a,b)) @ (246,8--247,24)";
"let letLambdaRes = Operators.op_PipeRight<(Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int) Microsoft.FSharp.Collections.list,Microsoft.FSharp.Core.int Microsoft.FSharp.Collections.list> (Cons((1,2),Empty()),let mapping: Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int = fun tupledArg -> let a: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b: Microsoft.FSharp.Core.int = tupledArg.Item1 in (LetLambda.f () a) b in fun list -> ListModule.Map<Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (mapping,list)) @ (249,19--249,71)";
"let anonRecd = {X = 1; Y = 2} @ (251,15--251,33)";
"let anonRecdGet = (M.anonRecd ().X,M.anonRecd ().Y) @ (252,19--252,41)"]
let expected2 =
["type N"; "type IntAbbrev"; "let bool2 = False @ (6,12--6,17)";
"let testHashChar(x) = Operators.Hash<Microsoft.FSharp.Core.char> (x) @ (8,28--8,34)";
"let testHashSByte(x) = Operators.Hash<Microsoft.FSharp.Core.sbyte> (x) @ (9,30--9,36)";
"let testHashInt16(x) = Operators.Hash<Microsoft.FSharp.Core.int16> (x) @ (10,30--10,36)";
"let testHashInt64(x) = Operators.Hash<Microsoft.FSharp.Core.int64> (x) @ (11,30--11,36)";
"let testHashUInt64(x) = Operators.Hash<Microsoft.FSharp.Core.uint64> (x) @ (12,32--12,38)";
"let testHashIntPtr(x) = Operators.Hash<Microsoft.FSharp.Core.nativeint> (x) @ (13,35--13,41)";
"let testHashUIntPtr(x) = Operators.Hash<Microsoft.FSharp.Core.unativeint> (x) @ (14,37--14,43)";
"let testHashString(x) = Operators.Hash<Microsoft.FSharp.Core.string> (x) @ (16,32--16,38)";
"let testTypeOf(x) = Operators.TypeOf<'T> () @ (17,24--17,30)";
"let mutableVar(x) = (if Operators.op_GreaterThan<Microsoft.FSharp.Core.int> (x,0) then let mutable acc: Microsoft.FSharp.Core.int = x in acc <- x else ()) @ (20,4--22,16)";
"let mutableConst(unitVar0) = let mutable acc: Microsoft.FSharp.Core.unit = () in acc <- () @ (25,16--25,19)";
"let testMutableVar = N.mutableVar (1) @ (28,21--28,33)";
"let testMutableConst = N.mutableConst (()) @ (29,23--29,38)"]
printfn "// unoptimized"
printfn "let expected =\n%A" (printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList)
printfn "let expected2 =\n%A" (printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList)
printDeclarations None (List.ofSeq file1.Declarations)
|> Seq.toList
|> Utils.filterHack
|> shouldPairwiseEqual (Utils.filterHack expected)
printDeclarations None (List.ofSeq file2.Declarations)
|> Seq.toList
|> Utils.filterHack
|> shouldPairwiseEqual (Utils.filterHack expected2)
()
[<Theory>]
[<InlineData(false)>]
[<InlineData(true)>]
let ``Test Optimized Declarations Project1`` useTransparentCompiler =
let cleanup, options = Project1.createOptionsWithArgs [ "--langversion:preview" ]
use _holder = cleanup
let exprChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler)
let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate
for e in wholeProjectResults.Diagnostics do
printfn "Project1 error: <<<%s>>>" e.Message
wholeProjectResults.Diagnostics.Length |> shouldEqual 3 // recursive value warning
wholeProjectResults.Diagnostics[0].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning
wholeProjectResults.Diagnostics[1].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning
wholeProjectResults.Diagnostics[2].Severity |> shouldEqual FSharpDiagnosticSeverity.Warning
wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles.Length |> shouldEqual 2
let file1 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[0]
let file2 = wholeProjectResults.GetOptimizedAssemblyContents().ImplementationFiles[1]
let expected =
["type M"; "type IntAbbrev"; "let boolEx1 = True @ (6,14--6,18)";
"let intEx1 = 1 @ (7,13--7,14)"; "let int64Ex1 = 1 @ (8,15--8,17)";
"let tupleEx1 = (1,1) @ (9,16--9,21)";
"let tupleEx2 = (1,1,1) @ (10,16--10,25)";
"let tupleEx3 = (1,1,1,1) @ (11,16--11,29)";
"let localExample = let y: Microsoft.FSharp.Core.int = 1 in let z: Microsoft.FSharp.Core.int = 1 in (y,z) @ (14,7--14,8)";
"let localGenericFunctionExample(unitVar0) = let y: Microsoft.FSharp.Core.int = 1 in let compiledAsLocalGenericFunction: 'a -> 'a = FUN ... -> fun x -> x in (compiledAsLocalGenericFunction<Microsoft.FSharp.Core.int> y,compiledAsLocalGenericFunction<Microsoft.FSharp.Core.float> 1) @ (19,7--19,8)";
"let funcEx1(x) = x @ (23,23--23,24)";
"let genericFuncEx1(x) = x @ (24,29--24,30)";
"let topPair1b = M.patternInput@25 ().Item1 @ (25,4--25,26)";
"let topPair1a = M.patternInput@25 ().Item0 @ (25,4--25,26)";
"let testILCall1 = new Object() @ (27,18--27,27)";
"let testILCall2 = Console.WriteLine (\"176\") @ (28,18--28,49)";
"let recValNeverUsedAtRuntime = [email protected]<Microsoft.FSharp.Core.int>(()) @ (31,8--31,32)";
"let recFuncIgnoresFirstArg(g) (v) = v @ (32,33--32,34)";
"let testFun4(unitVar0) = let rec ... in recValNeverUsedAtRuntime @ (36,4--39,28)";
"type ClassWithImplicitConstructor";
"member .ctor(compiledAsArg) = (new Object(); (this.compiledAsArg <- compiledAsArg; (this.compiledAsField <- 1; let compiledAsLocal: Microsoft.FSharp.Core.int = 1 in let compiledAsLocal2: Microsoft.FSharp.Core.int = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),compiledAsLocal,compiledAsLocal) in ()))) @ (41,5--41,33)";
"member .cctor(unitVar) = (compiledAsStaticField <- 1; let compiledAsStaticLocal: Microsoft.FSharp.Core.int = 1 in let compiledAsStaticLocal2: Microsoft.FSharp.Core.int = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),compiledAsStaticLocal,compiledAsStaticLocal) in ()) @ (49,11--49,40)";
"member M1(__) (unitVar1) = Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),__.compiledAsField,__.compiledAsGenericInstanceMethod<Microsoft.FSharp.Core.int>(__.compiledAsField)),__.compiledAsArg) @ (55,21--55,102)";
"member M2(__) (unitVar1) = __.compiledAsInstanceMethod(()) @ (56,21--56,47)";
"member SM1(unitVar0) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),compiledAsStaticField,ClassWithImplicitConstructor.compiledAsGenericStaticMethod<Microsoft.FSharp.Core.int> (compiledAsStaticField)) @ (57,26--57,101)";
"member SM2(unitVar0) = ClassWithImplicitConstructor.compiledAsStaticMethod (()) @ (58,26--58,50)";
"member TestCallinToString(this) (unitVar1) = this.ToString() @ (60,39--60,54)";
"type Error"; "let err = {Data0 = 3; Data1 = 4} @ (64,10--64,20)";
"let matchOnException(err) = match (if err :? M.Error then $0 else $1) targets ... @ (66,33--66,36)";
"let upwardForLoop(unitVar0) = let mutable a: Microsoft.FSharp.Core.int = 1 in (for-loop; a) @ (69,16--69,17)";
"let upwardForLoop2(unitVar0) = let mutable a: Microsoft.FSharp.Core.int = 1 in (for-loop; a) @ (74,16--74,17)";
"let downwardForLoop(unitVar0) = let mutable a: Microsoft.FSharp.Core.int = 1 in (for-loop; a) @ (79,16--79,17)";
"let quotationTest1(unitVar0) = quote(Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),1,1)) @ (83,24--83,35)";
"let quotationTest2(v) = quote(Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),ExtraTopLevelOperators.SpliceExpression<Microsoft.FSharp.Core.int> (v),1)) @ (84,24--84,36)";
"type RecdType"; "type UnionType";
"member get_IsCase1(this) (unitArg) = (if this.IsCase1 then True else False) @ (87,5--87,14)";
"member get_IsCase2(this) (unitArg) = (if this.IsCase2 then True else False) @ (87,5--87,14)";
"member get_IsCase3(this) (unitArg) = (if this.IsCase3 then True else False) @ (87,5--87,14)";
"type ClassWithEventsAndProperties";
"member .ctor(unitVar0) = (new Object(); (this.ev <- new FSharpEvent`1(()); ())) @ (89,5--89,33)";
"member .cctor(unitVar) = (sev <- new FSharpEvent`1(()); ()) @ (91,11--91,35)";
"member get_InstanceProperty(x) (unitVar1) = (x.ev.Trigger(1); 1) @ (92,32--92,48)";
"member get_StaticProperty(unitVar0) = (sev.Trigger(1); 1) @ (93,35--93,52)";
"member get_InstanceEvent(x) (unitVar1) = x.ev.get_Publish(()) @ (94,29--94,39)";
"member get_StaticEvent(x) (unitVar1) = sev.get_Publish(()) @ (95,27--95,38)";
"let c = new ClassWithEventsAndProperties(()) @ (97,8--97,38)";
"let v = M.c ().get_InstanceProperty(()) @ (98,8--98,26)";
"do Console.WriteLine (\"777\")";
"let functionWithSubmsumption(x) = IntrinsicFunctions.UnboxGeneric<Microsoft.FSharp.Core.string> (x) @ (102,40--102,52)";
"type MultiArgMethods";
"member .ctor(c,d) = (new Object(); ()) @ (105,5--105,20)";
"member Method(x) (a,b) = 1 @ (106,37--106,38)";
"member CurriedMethod(x) (a1,b1) (a2,b2) = 1 @ (107,63--107,64)";
"let testFunctionThatCallsMultiArgMethods(unitVar0) = let m: M.MultiArgMethods = new MultiArgMethods(3,4) in Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),m.Method(7,8),let a1: Microsoft.FSharp.Core.int = 9 in let b1: Microsoft.FSharp.Core.int = 10 in let a2: Microsoft.FSharp.Core.int = 11 in let b2: Microsoft.FSharp.Core.int = 12 in m.CurriedMethod(a1,b1,a2,b2)) @ (110,8--110,9)";
"let testFunctionThatUsesUnitsOfMeasure(x) (y) = Operators.op_Addition<Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>,Microsoft.FSharp.Core.float<'u>> (arg0_0,arg1_0),x,y) @ (122,70--122,75)";
"let testFunctionThatUsesAddressesAndByrefs(x) = let mutable w: Microsoft.FSharp.Core.int = 4 in let y1: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = x in let y2: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = &w in let arr: Microsoft.FSharp.Core.int Microsoft.FSharp.Core.array = [|3; 4|] in let r: Microsoft.FSharp.Core.int Microsoft.FSharp.Core.ref = Operators.Ref<Microsoft.FSharp.Core.int> (3) in let y3: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = [I_ldelema (NormalAddress, false, ILArrayShape [(Some 0, None)], !0)](arr,0) in let y4: Microsoft.FSharp.Core.byref<Microsoft.FSharp.Core.int> = &r.contents in let z: Microsoft.FSharp.Core.int = Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x,y1),y2),y3) in (w <- 3; (x <- 4; (y2 <- 4; (y3 <- 5; Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int32> (arg0_0,arg1_0),Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),z,x),y1),y2),y3),y4),IntrinsicFunctions.GetArray<Microsoft.FSharp.Core.int> (arr,0)),r.contents))))) @ (125,16--125,17)";
"let testFunctionThatUsesStructs1(dt) = dt.AddDays(3) @ (139,57--139,72)";
"let testFunctionThatUsesStructs2(unitVar0) = let dt1: System.DateTime = DateTime.get_Now () in let mutable dt2: System.DateTime = DateTime.get_Now () in let dt3: System.TimeSpan = DateTime.op_Subtraction (dt1,dt2) in let dt4: System.DateTime = dt1.AddDays(3) in let dt5: Microsoft.FSharp.Core.int = dt1.get_Millisecond() in let dt6: Microsoft.FSharp.Core.byref<System.DateTime> = &dt2 in let dt7: System.TimeSpan = DateTime.op_Subtraction (dt6,dt4) in dt7 @ (142,7--142,10)";
"let testFunctionThatUsesWhileLoop(unitVar0) = let mutable x: Microsoft.FSharp.Core.int = 1 in (while Operators.op_LessThan<Microsoft.FSharp.Core.int> (x,100) do x <- Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x,1) done; x) @ (152,15--152,16)";
"let testFunctionThatUsesTryWith(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) with matchValue -> match (if matchValue :? System.ArgumentException then $0 else $1) targets ... @ (158,3--160,60)";
"let testFunctionThatUsesTryFinally(unitVar0) = try M.testFunctionThatUsesWhileLoop (()) finally Console.WriteLine (\"8888\") @ (164,3--167,37)";
"member Console.WriteTwoLines.Static(unitVar0) = (Console.WriteLine (); Console.WriteLine ()) @ (170,36--170,90)";
"member DateTime.get_TwoMinute(x) (unitVar1) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x.get_Minute(),x.get_Minute()) @ (173,25--173,44)";
"let testFunctionThatUsesExtensionMembers(unitVar0) = (M.Console.WriteTwoLines.Static (()); let v: Microsoft.FSharp.Core.int = DateTime.get_Now ().DateTime.get_TwoMinute(()) in M.Console.WriteTwoLines.Static (())) @ (176,3--178,33)";
"let testFunctionThatUsesOptionMembers(unitVar0) = let x: Microsoft.FSharp.Core.int Microsoft.FSharp.Core.option = Some(3) in (x.get_IsSome() (),x.get_IsNone() ()) @ (181,7--181,8)";
"let testFunctionThatUsesOverAppliedFunction(unitVar0) = Operators.Identity<Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int> (fun x -> Operators.Identity<Microsoft.FSharp.Core.int> (x)) 3 @ (185,3--185,10)";
"let testFunctionThatUsesPatternMatchingOnLists(x) = match (if x.Isop_ColonColon then (if x.Tail.Isop_ColonColon then (if x.Tail.Tail.Isop_Nil then $2 else $3) else $1) else $0) targets ... @ (188,10--188,11)";
"let testFunctionThatUsesPatternMatchingOnOptions(x) = match (if x.IsSome then $1 else $0) targets ... @ (195,10--195,11)";
"let testFunctionThatUsesPatternMatchingOnOptions2(x) = match (if x.IsSome then $1 else $0) targets ... @ (200,10--200,11)";
"let testFunctionThatUsesConditionalOnOptions2(x) = (if x.get_IsSome() () then 1 else 2) @ (205,4--205,29)";
"let f(x) (y) = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),x,y) @ (207,12--207,15)";
"let g = let x: Microsoft.FSharp.Core.int = 1 in fun y -> M.f (x,y) @ (208,8--208,11)";
"let h = Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),M.g () 2,3) @ (209,8--209,17)";
"type TestFuncProp";
"member .ctor(unitVar0) = (new Object(); ()) @ (211,5--211,17)";
"member get_Id(this) (unitVar1) = fun x -> x @ (212,21--212,31)";
"let wrong = Operators.op_Equality<Microsoft.FSharp.Core.int> (new TestFuncProp(()).get_Id(()) 0,0) @ (214,12--214,35)";
"let start(name) = (name,name) @ (217,4--217,14)";
"let last(name,values) = Operators.Identity<Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string> ((name,values)) @ (220,4--220,21)";
"let last2(name) = Operators.Identity<Microsoft.FSharp.Core.string> (name) @ (223,4--223,11)";
"let test7(s) = let Pipe #1 input at line 226: Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string = M.start (s) in let name: Microsoft.FSharp.Core.string = Pipe #1 input at line 226.Item0 in let values: Microsoft.FSharp.Core.string = Pipe #1 input at line 226.Item1 in M.last (name,values) @ (226,4--226,19)";
"let test8(unitVar0) = fun tupledArg -> let name: Microsoft.FSharp.Core.string = tupledArg.Item0 in let values: Microsoft.FSharp.Core.string = tupledArg.Item1 in M.last (name,values) @ (229,4--229,8)";
"let test9(s) = let Pipe #1 input at line 232: Microsoft.FSharp.Core.string * Microsoft.FSharp.Core.string = (s,s) in let name: Microsoft.FSharp.Core.string = Pipe #1 input at line 232.Item0 in let values: Microsoft.FSharp.Core.string = Pipe #1 input at line 232.Item1 in M.last (name,values) @ (232,4--232,17)";
"let test10(unitVar0) = fun name -> M.last2 (name) @ (235,4--235,9)";
"let test11(s) = let Pipe #1 input at line 238: Microsoft.FSharp.Core.string = s in M.last2 (Pipe #1 input at line 238) @ (238,4--238,14)";
"let badLoop = [email protected]<Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int>(()) @ (240,8--240,15)";
"type LetLambda";
"let f = fun a -> fun b -> Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),a,b) @ (247,8--247,24)";
"let letLambdaRes = let Pipe #1 input at line 249: (Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int) Microsoft.FSharp.Collections.list = Cons((1,2),Empty()) in ListModule.Map<Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (fun tupledArg -> let a: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b: Microsoft.FSharp.Core.int = tupledArg.Item1 in (LetLambda.f () a) b,Pipe #1 input at line 249) @ (249,19--249,71)";
"let anonRecd = {X = 1; Y = 2} @ (251,15--251,33)";
"let anonRecdGet = (M.anonRecd ().X,M.anonRecd ().Y) @ (252,19--252,41)"]
let expected2 =
["type N"; "type IntAbbrev"; "let bool2 = False @ (6,12--6,17)";
"let testHashChar(x) = Operators.op_BitwiseOr<Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.BitwiseOrDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_LeftShift<Microsoft.FSharp.Core.char> (x,16),x) @ (8,28--8,34)";
"let testHashSByte(x) = Operators.op_ExclusiveOr<Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.ExclusiveOrDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.op_LeftShift<Microsoft.FSharp.Core.sbyte> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.LeftShiftDynamic<Microsoft.FSharp.Core.sbyte,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.sbyte> (arg0_0,arg1_0),x,8),x) @ (9,30--9,36)";
"let testHashInt16(x) = Operators.op_BitwiseOr<Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.BitwiseOrDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.ToUInt16<Microsoft.FSharp.Core.int16> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.int16,Microsoft.FSharp.Core.uint16> (arg0_0),x),Operators.op_LeftShift<Microsoft.FSharp.Core.int16> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.LeftShiftDynamic<Microsoft.FSharp.Core.int16,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int16> (arg0_0,arg1_0),x,16)) @ (10,30--10,36)";
"let testHashInt64(x) = Operators.op_ExclusiveOr<Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.ExclusiveOrDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.ToInt32<Microsoft.FSharp.Core.int64> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.int64,Microsoft.FSharp.Core.int32> (arg0_0),x),Operators.ToInt32<Microsoft.FSharp.Core.int> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int32> (arg0_0),Operators.op_RightShift<Microsoft.FSharp.Core.int64> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.RightShiftDynamic<Microsoft.FSharp.Core.int64,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.int64> (arg0_0,arg1_0),x,32))) @ (11,30--11,36)";
"let testHashUInt64(x) = Operators.op_ExclusiveOr<Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.ExclusiveOrDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.ToInt32<Microsoft.FSharp.Core.uint64> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.uint64,Microsoft.FSharp.Core.int32> (arg0_0),x),Operators.ToInt32<Microsoft.FSharp.Core.int> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int32> (arg0_0),Operators.op_RightShift<Microsoft.FSharp.Core.uint64> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.RightShiftDynamic<Microsoft.FSharp.Core.uint64,Microsoft.FSharp.Core.int32,Microsoft.FSharp.Core.uint64> (arg0_0,arg1_0),x,32))) @ (12,32--12,38)";
"let testHashIntPtr(x) = Operators.ToInt32<Microsoft.FSharp.Core.uint64> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.uint64,Microsoft.FSharp.Core.int32> (arg0_0),Operators.ToUInt64<Microsoft.FSharp.Core.nativeint> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.nativeint,Microsoft.FSharp.Core.uint64> (arg0_0),x)) @ (13,35--13,41)";
"let testHashUIntPtr(x) = Operators.op_BitwiseAnd<Microsoft.FSharp.Core.int> (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.BitwiseAndDynamic<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (arg0_0,arg1_0),Operators.ToInt32<Microsoft.FSharp.Core.uint64> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.uint64,Microsoft.FSharp.Core.int32> (arg0_0),Operators.ToUInt64<Microsoft.FSharp.Core.unativeint> (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic<Microsoft.FSharp.Core.unativeint,Microsoft.FSharp.Core.uint64> (arg0_0),x)),2147483647) @ (14,37--14,43)";
"let testHashString(x) = (if Operators.op_Equality<Microsoft.FSharp.Core.string> (x,dflt) then 0 else x.GetHashCode()) @ (16,32--16,38)";
"let testTypeOf(x) = Operators.TypeOf<'T> () @ (17,24--17,30)";
"let mutableVar(x) = (if Operators.op_GreaterThan<Microsoft.FSharp.Core.int> (x,0) then let mutable acc: Microsoft.FSharp.Core.int = x in acc <- x else ()) @ (20,4--22,16)";
"let mutableConst(unitVar0) = let mutable acc: Microsoft.FSharp.Core.unit = () in acc <- () @ (25,16--25,19)";
"let testMutableVar = let x: Microsoft.FSharp.Core.int = 1 in (if Operators.op_GreaterThan<Microsoft.FSharp.Core.int> (x,0) then let mutable acc: Microsoft.FSharp.Core.int = x in acc <- x else ()) @ (28,21--28,33)";
"let testMutableConst = let mutable acc: Microsoft.FSharp.Core.unit = () in acc <- () @ (29,23--29,38)"]
// printFSharpDecls "" file2.Declarations |> Seq.iter (printfn "%s")
printfn "// optimized"
printfn "let expected =\n%A" (printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList)
printfn "let expected2 =\n%A" (printDeclarations None (List.ofSeq file2.Declarations) |> Seq.toList)
printDeclarations None (List.ofSeq file1.Declarations)
|> Seq.toList
|> Utils.filterHack
|> shouldPairwiseEqual (Utils.filterHack expected)
printDeclarations None (List.ofSeq file2.Declarations)
|> Seq.toList
|> Utils.filterHack
|> shouldPairwiseEqual (Utils.filterHack expected2)