Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit05efc21

Browse files
committed
Support/fixes for building and running unit tests against all portable versions of FSharp.Core (changeset 1306102)
1 parent94ea6fb commit05efc21

File tree

12 files changed

+300
-63
lines changed

12 files changed

+300
-63
lines changed

‎src/FSharpSource.targets‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@
702702
'$(TargetFramework)' == 'portable78' or
703703
'$(TargetFramework)' == 'portable259')"/>
704704
<Error
705-
Text="TargetFramework '$(TargetFramework)' is only supported when building FSharp.Core.dll. All other components must be built with TargetFramework=net40"
706-
Condition="'$(AssemblyName)' != 'FSharp.Core' and '$(TargetFramework)' != 'net40'"/>
705+
Text="TargetFramework '$(TargetFramework)' is only supported when building FSharp.Core.dll and FSharp.Core.Unittests.dll. All other components must be built with TargetFramework=net40"
706+
Condition="'$(AssemblyName)' != 'FSharp.Core' and '$(AssemblyName)' != 'FSharp.Core.Unittests' and '$(TargetFramework)' != 'net40'"/>
707707

708708
</Target>
709709

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
<!-- Prevent compiler from inlining calls to FSharp.Core to improve code coverage accuracy-->
2020
<Optimize>false</Optimize>
2121
<Tailcalls>false</Tailcalls>
22-
</PropertyGroup>
22+
<TargetProfileCondition=" '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259'">netcore</TargetProfile>
23+
<!-- workaround for msbuild narrowing the assembly search paths when building portable libs-->
24+
<AssemblySearchPathsCondition="$(TargetFramework.Contains('portable'))">
25+
{CandidateAssemblyFiles};
26+
{TargetFrameworkDirectory};
27+
{Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx};
28+
</AssemblySearchPaths>
29+
</PropertyGroup>
2330
<PropertyGroup>
2431
<DefineConstantsCondition=" '$(TargetFramework)' == 'sl5'">$(DefineConstants);SILVERLIGHT</DefineConstants>
2532
<DefineConstants>$(DefineConstants);EXTENSIONTYPING</DefineConstants>
@@ -42,12 +49,17 @@
4249
<WarningLevel>3</WarningLevel>
4350
</PropertyGroup>
4451
<ItemGroup>
45-
<ReferenceInclude="nunit.framework"Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" />
52+
<!-- need full name and SpecificVersion = true in order to convince msbuild to allow this reference when targeting portable47-->
53+
<ReferenceInclude="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" >
54+
<SpecificVersion>true</SpecificVersion>
55+
</Reference>
4656
<ReferenceInclude="NUnitFramework"Condition="'$(TargetFramework)' == 'sl5' OR '$(TargetFramework)' == 'sl3-wp'" />
4757
<ProjectReferenceInclude="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
4858
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
4959
<Name>FSharp.Core</Name>
5060
</ProjectReference>
61+
</ItemGroup>
62+
<ItemGroupCondition="!$(TargetFramework.Contains('portable'))">
5163
<ReferenceInclude="mscorlib" />
5264
<ReferenceInclude="System" />
5365
<ReferenceInclude="System.Numerics"Condition="'$(TargetFramework)' == 'net40'" />
@@ -92,7 +104,7 @@
92104
<CompileInclude="FSharp.Core\Microsoft.FSharp.Quotations\FSharpQuotations.fs" />
93105
<CompileInclude="TypeForwarding.fs" />
94106
<CompileInclude="NUnitFrameworkShims.fs"Condition="'$(TargetFramework)' == 'sl3-wp'" />
95-
<CompileInclude="SurfaceArea.4.0.fs"/>
107+
<CompileInclude="SurfaceArea.4.0.fs"Condition="'$(TargetFramework)' == 'net40'"/>
96108
</ItemGroup>
97109
<ImportProject="$(FSharpSourcesRoot)\FSharpSource.targets" />
98110
</Project>

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type UseUnionsAsFlags() =
4545
[<Test>]
4646
memberthis.CanParseViaBCL()=
4747
letvalues= System.Enum.GetValues(typeof<FlagsUnion>)
48-
letfourFromString= System.Enum.Parse(typeof<FlagsUnion>,"Four"):?> FlagsUnion// downcast needed
48+
letfourFromString= System.Enum.Parse(typeof<FlagsUnion>,"Four",false):?> FlagsUnion// downcast needed
4949
Assert.AreEqual(fourFromString, FlagsUnion.Four)
5050

5151
[<Test>]

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ type AsyncModule() =
264264
:? InvalidOperationException as e when e.Message="EXPECTED"-> return()
265265
}
266266
Async.RunSynchronously(test)
267-
267+
268+
#if FSHARP_CORE_NETCORE_PORTABLE
269+
// nothing
270+
#else
268271
[<Test>]
269272
memberthis.``FromContinuationsCanTailCallCurrentThread``()=
270273
letcnt= ref0
@@ -285,6 +288,7 @@ type AsyncModule() =
285288
f5000|> Async.StartImmediate
286289
Assert.AreEqual(origTid,!finalTid)
287290
Assert.AreEqual(5000,!cnt)
291+
#endif
288292

289293
[<Test>]
290294
memberthis.``AwaitWaitHandle With Cancellation``()=
@@ -343,6 +347,9 @@ type AsyncModule() =
343347

344348
#if FSHARP_CORE_PORTABLE
345349
// nothing
350+
#else
351+
#if FSHARP_CORE_NETCORE_PORTABLE
352+
// nothing
346353
#else
347354
[<Test>]
348355
memberthis.``SleepContinuations``()=
@@ -371,13 +378,17 @@ type AsyncModule() =
371378
Assert.AreEqual(0,!okCount)
372379
Assert.AreEqual(0,!errCount)
373380
#endif
381+
#endif
374382

375383
#if FSHARP_CORE_PORTABLE
376384
// nothing
377385
#else
378386
#if FSHARP_CORE_2_0
379387
// nothing
380388
#else
389+
#if FSHARP_CORE_NETCORE_PORTABLE
390+
//nothing
391+
#else
381392
// we are on the desktop
382393
memberthis.RunExeAndExpectOutput(exeName,expected:string)=
383394
letcurDir=(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).LocalPath|> System.IO.Path.GetDirectoryName
@@ -457,5 +468,6 @@ AwaitWaitHandleAlreadySignaled1 [|("ok", false); ("unhandled", false)|]
457468
""")
458469
#endif
459470

471+
#endif
460472
#endif
461473
#endif

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs‎

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type AsyncType() =
9191
(fun _-> result:="Cancel"),
9292
cts.Token)
9393
cts.Cancel()
94+
Async.Sleep(1000)|> Async.RunSynchronously
9495
Assert.AreEqual("Cancel",!result)
9596
)
9697

@@ -125,7 +126,12 @@ type AsyncType() =
125126
memberthis.CreateTask()=
126127
lets="Hello tasks!"
127128
leta=async{return s}
128-
use t:Task<string>= Async.StartAsTask a
129+
#if FSHARP_CORE_NETCORE_PORTABLE
130+
lett:Task<string>=
131+
#else
132+
use t:Task<string>=
133+
#endif
134+
Async.StartAsTask a
129135
this.WaitASec t
130136
Assert.IsTrue(t.IsCompleted)
131137
Assert.AreEqual(s, t.Result)
@@ -134,7 +140,12 @@ type AsyncType() =
134140
memberthis.StartTask()=
135141
lets="Hello tasks!"
136142
leta=async{return s}
137-
use t= Async.StartAsTask a
143+
#if FSHARP_CORE_NETCORE_PORTABLE
144+
lett=
145+
#else
146+
use t=
147+
#endif
148+
Async.StartAsTask a
138149
this.WaitASec t
139150
Assert.IsTrue(t.IsCompleted)
140151
Assert.AreEqual(s, t.Result)
@@ -144,7 +155,12 @@ type AsyncType() =
144155
leta=async{
145156
do raise(Exception())
146157
}
147-
use t= Async.StartAsTask a
158+
#if FSHARP_CORE_NETCORE_PORTABLE
159+
lett=
160+
#else
161+
use t=
162+
#endif
163+
Async.StartAsTask a
148164
let mutableexceptionThrown=false
149165
try
150166
this.WaitASec t
@@ -158,7 +174,12 @@ type AsyncType() =
158174
leta=async{
159175
whiletruedo()
160176
}
161-
use t= Async.StartAsTask a
177+
#if FSHARP_CORE_NETCORE_PORTABLE
178+
lett=
179+
#else
180+
use t=
181+
#endif
182+
Async.StartAsTask a
162183
Async.CancelDefaultToken()
163184
let mutableexceptionThrown=false
164185
try
@@ -178,7 +199,12 @@ type AsyncType() =
178199
}
179200
letcts=new CancellationTokenSource()
180201
lettoken= cts.Token
181-
use t= Async.StartAsTask(a, cancellationToken=token)
202+
#if FSHARP_CORE_NETCORE_PORTABLE
203+
lett=
204+
#else
205+
use t=
206+
#endif
207+
Async.StartAsTask(a, cancellationToken=token)
182208
// printfn "%A" t.Status
183209
ewh.WaitOne()|> Assert.IsTrue
184210
cts.Cancel()
@@ -195,7 +221,12 @@ type AsyncType() =
195221
[<Test>]
196222
memberthis.TaskAsyncValue()=
197223
lets="Test"
198-
use t= Task.Factory.StartNew(Func<_>(fun()-> s))
224+
#if FSHARP_CORE_NETCORE_PORTABLE
225+
lett=
226+
#else
227+
use t=
228+
#endif
229+
Task.Factory.StartNew(Func<_>(fun()-> s))
199230
leta=async{
200231
let!s1= Async.AwaitTask(t)
201232
return s= s1
@@ -204,7 +235,12 @@ type AsyncType() =
204235

205236
[<Test>]
206237
memberthis.TaskAsyncValueException()=
207-
use t= Task.Factory.StartNew(Func<unit>(fun()-> raise<| Exception()))
238+
#if FSHARP_CORE_NETCORE_PORTABLE
239+
lett=
240+
#else
241+
use t=
242+
#endif
243+
Task.Factory.StartNew(Func<unit>(fun()-> raise<| Exception()))
208244
leta=async{
209245
try
210246
let!v= Async.AwaitTask(t)
@@ -218,7 +254,11 @@ type AsyncType() =
218254
use ewh=new ManualResetEvent(false)
219255
letcts=new CancellationTokenSource()
220256
lettoken= cts.Token
221-
use t:Task<unit>=
257+
#if FSHARP_CORE_NETCORE_PORTABLE
258+
lett:Task<unit>=
259+
#else
260+
use t:Task<unit>=
261+
#endif
222262
Task.Factory.StartNew(Func<unit>(fun()->whilenot token.IsCancellationRequesteddo()), token)
223263
letcancelled= reftrue
224264
leta=async{

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/LazyType.fs‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,84 +15,84 @@ type LazyType() =
1515
memberthis.Create()=
1616

1717
// int
18-
letintLazy= Lazy.Create(fun()->2)
18+
letintLazy= Lazy<_>.Create(fun()->2)
1919
Assert.AreEqual(intLazy.Value,2)
2020

2121
// string
22-
letstringLazy= Lazy.Create(fun()->"string")
22+
letstringLazy= Lazy<_>.Create(fun()->"string")
2323
Assert.AreEqual(stringLazy.Value,"string")
2424

2525
// null
26-
letnullLazy= Lazy.Create(fun()->())
26+
letnullLazy= Lazy<_>.Create(fun()->())
2727
Assert.AreEqual(nullLazy.Value,null)
2828

2929
[<Test>]
3030
memberthis.CreateFromValue()=
3131

3232
// int
33-
letintLazy= Lazy.CreateFromValue(2)
33+
letintLazy= Lazy<_>.CreateFromValue(2)
3434
Assert.AreEqual(intLazy.Value,2)
3535

3636
// string
37-
letstringLazy= Lazy.CreateFromValue("string")
37+
letstringLazy= Lazy<_>.CreateFromValue("string")
3838
Assert.AreEqual(stringLazy.Value,"string")
3939

4040
//null
41-
letnullLazy= Lazy.CreateFromValue(null)
41+
letnullLazy= Lazy<_>.CreateFromValue(null)
4242
Assert.AreEqual(nullLazy.Value,null)
4343

4444

4545
[<Test>]
4646
memberthis.Force()=
4747

4848
// int
49-
letintLazy= Lazy.CreateFromValue(2)
49+
letintLazy= Lazy<_>.CreateFromValue(2)
5050
letintForce= intLazy.Force()
5151
Assert.AreEqual(intForce,2)
5252

5353
// string
54-
letstringLazy= Lazy.CreateFromValue("string")
54+
letstringLazy= Lazy<_>.CreateFromValue("string")
5555
letstringForce= stringLazy.Force()
5656
Assert.AreEqual(stringForce,"string")
5757

5858
//null
59-
letnullLazy= Lazy.CreateFromValue(null)
59+
letnullLazy= Lazy<_>.CreateFromValue(null)
6060
letnullForce= nullLazy.Force()
6161
Assert.AreEqual(nullForce,null)
6262

6363
[<Test>]
6464
memberthis.Value()=
6565

6666
// int
67-
letintLazy= Lazy.CreateFromValue(2)
67+
letintLazy= Lazy<_>.CreateFromValue(2)
6868
Assert.AreEqual(intLazy.Value,2)
6969

7070
// string
71-
letstringLazy= Lazy.CreateFromValue("string")
71+
letstringLazy= Lazy<_>.CreateFromValue("string")
7272
Assert.AreEqual(stringLazy.Value,"string")
7373

7474
//null
75-
letnullLazy= Lazy.CreateFromValue(null)
75+
letnullLazy= Lazy<_>.CreateFromValue(null)
7676
Assert.AreEqual(nullLazy.Value,null)
7777

7878
[<Test>]
7979
memberthis.IsDelayed()=
8080

8181
// int
82-
letintLazy= Lazy.Create(fun()->1)
82+
letintLazy= Lazy<_>.Create(fun()->1)
8383
Assert.AreEqual(not intLazy.IsValueCreated,true)
8484
letresultIsDelayed= intLazy.Force()
8585
Assert.AreEqual(not intLazy.IsValueCreated,false)
8686

8787
// string
88-
letstringLazy= Lazy.Create(fun()->"string")
88+
letstringLazy= Lazy<_>.Create(fun()->"string")
8989
Assert.AreEqual(not stringLazy.IsValueCreated,true)
9090
letresultIsDelayed= stringLazy.Force()
9191
Assert.AreEqual(not stringLazy.IsValueCreated,false)
9292

9393

9494
//null
95-
letnullLazy= Lazy.Create(fun()->null)
95+
letnullLazy= Lazy<_>.Create(fun()->null)
9696
Assert.AreEqual(not nullLazy.IsValueCreated,true)
9797
letresultIsDelayed= nullLazy.Force()
9898
Assert.AreEqual(not nullLazy.IsValueCreated,false)
@@ -101,20 +101,20 @@ type LazyType() =
101101
memberthis.IsForced()=
102102

103103
// int
104-
letintLazy= Lazy.Create(fun()->1)
104+
letintLazy= Lazy<_>.Create(fun()->1)
105105
Assert.AreEqual( intLazy.IsValueCreated,false)
106106
letresultIsForced= intLazy.Force()
107107
Assert.AreEqual( intLazy.IsValueCreated,true)
108108

109109
// string
110-
letstringLazy= Lazy.Create(fun()->"string")
110+
letstringLazy= Lazy<_>.Create(fun()->"string")
111111
Assert.AreEqual( stringLazy.IsValueCreated,false)
112112
letresultIsForced= stringLazy.Force()
113113
Assert.AreEqual( stringLazy.IsValueCreated,true)
114114

115115

116116
//null
117-
letnullLazy= Lazy.Create(fun()->null)
117+
letnullLazy= Lazy<_>.Create(fun()->null)
118118
Assert.AreEqual( nullLazy.IsValueCreated,false)
119119
letresultIsForced= nullLazy.Force()
120120
Assert.AreEqual( nullLazy.IsValueCreated,true)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp