Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #329 from fsgit/update1
Browse files Browse the repository at this point in the history
Integrate visualfsharp latest
  • Loading branch information
fsgit committed Sep 3, 2014
2 parents 20a9d20 + 8c86772 commit 1d3e209
Show file tree
Hide file tree
Showing 31 changed files with 632 additions and 234 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -101,3 +101,5 @@ build.ok
*.vserr

*.userprefs
extras
ossreadme*.txt
7 changes: 4 additions & 3 deletions src/FSharpSource.targets
Expand Up @@ -277,8 +277,8 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do
<AssemblySearchPaths Condition="Exists('$(MSBuildExtensionsPath32)\..\xbuild-frameworks\.NETPortable\v4.5\System.Runtime.dll')">$(MSBuildExtensionsPath32)\..\xbuild-frameworks\.NETPortable\v4.5</AssemblySearchPaths>
<OtherFlags>$(OtherFlags) --targetprofile:netcore</OtherFlags>
</PropertyGroup>
<!-- Target Portable -->

<!-- Target Portable Profile 78 -->
<PropertyGroup Condition="'$(TargetFramework)'=='portable78'">
<TargetFrameworkOutputDirectory>$(TargetFramework)</TargetFrameworkOutputDirectory>
<DefineConstants>$(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE</DefineConstants>
Expand Down Expand Up @@ -318,6 +318,7 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do
<OtherFlags>$(OtherFlags) --targetprofile:netcore</OtherFlags>
</PropertyGroup>

<!-- Target Portable Profile 259 -->
<PropertyGroup Condition="'$(TargetFramework)'=='portable259'">
<TargetFrameworkOutputDirectory>$(TargetFramework)</TargetFrameworkOutputDirectory>
<DefineConstants>$(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE</DefineConstants>
Expand Down Expand Up @@ -863,7 +864,7 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do
<Target Name="ValidateConfiguration">
<Error
Text="Configuration '$(Configuration)' is not one of the supported configurations: Debug, Release, Proto"
Condition="'$(Configuration)'!='Release' and '$(Configuration)'!='Debug' and '$(Configuration)'!='Proto'"/>
Condition="'$(Configuration)'!='Release' and '$(Configuration)'!='Debug' and '$(Configuration)'!='VSRelease' and '$(Configuration)'!='VSDebug' and '$(Configuration)'!='Proto'"/>
</Target>

<Import Project="$(LkgPath)\..\2.0\FSharp.SRGen.targets" />
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/FSComp.txt
Expand Up @@ -1142,7 +1142,7 @@ lexIndentOffForML,"Consider using a file with extension '.ml' or '.mli' instead"
fscTooManyErrors,"Exiting - too many errors"
2001,docfileNoXmlSuffix,"The documentation file has no .xml suffix"
2002,fscNoImplementationFiles,"No implementation files specified"
2003,fscBadAssemblyVersion,"An AssemblyVersionAttribute specified version '%s', but this value is invalid and has been ignored"
2003,fscBadAssemblyVersion,"An %s specified version '%s', but this value is invalid and has been ignored"
2004,fscTwoResourceManifests,"Conflicting options specified: 'win32manifest' and 'win32res'. Only one of these can be used."
2005,fscQuotationLiteralsStaticLinking,"The code in assembly '%s' makes uses of quotation literals. Static linking may not include components that make use of quotation literals."
2006,fscQuotationLiteralsStaticLinking0,"Code in this assembly makes uses of quotation literals. Static linking may not include components that make use of quotation literals."
Expand Down
16 changes: 14 additions & 2 deletions src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
Expand Up @@ -18,6 +18,13 @@
<!-- Prevent compiler from inlining calls to FSharp.Core to improve code coverage accuracy -->
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<TargetProfile Condition=" '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' ">netcore</TargetProfile>
<!-- workaround for msbuild narrowing the assembly search paths when building portable libs -->
<AssemblySearchPaths Condition=" '$(TargetFramework)' == 'portable47' or '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' ">
{CandidateAssemblyFiles};
{TargetFrameworkDirectory};
{Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx};
</AssemblySearchPaths>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition=" '$(TargetFramework)' == 'sl5' OR '$(TargetFramework)' == 'sl5-compiler' ">$(DefineConstants);SILVERLIGHT</DefineConstants>
Expand All @@ -42,14 +49,19 @@
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" />
<!-- need full name and SpecificVersion = true in order to convince msbuild to allow this reference when targeting portable47 -->
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" >
<SpecificVersion>true</SpecificVersion>
</Reference>
<Reference Include="NUnitFramework" Condition="'$(TargetFramework)' == 'sl5' OR '$(TargetFramework)' == 'sl3-wp'" />
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
<Name>FSharp.Core</Name>
</ProjectReference>
<Reference Include="nunit.framework" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl5-compiler' AND '$(TargetFramework)' != 'wp7'" />
<Reference Include="NUnitFramework" Condition="'$(TargetFramework)' == 'sl5' OR '$(TargetFramework)' == 'wp7' OR '$(TargetFramework)' == 'sl5-compiler'" />
</ItemGroup>
<ItemGroup Condition="!('$(TargetFramework)' == 'portable47' or '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' )">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Numerics" Condition="'$(TargetFramework)' == 'net40'" />
Expand Down Expand Up @@ -101,7 +113,7 @@
<Compile Include="FSharp.Core\PrimTypes.fs" />
<Compile Include="TypeForwarding.fs" />
<Compile Include="NUnitFrameworkShims.fs" Condition="'$(TargetFramework)' == 'sl3-wp'" />
<!-- <Compile Include="SurfaceArea.4.0.fs"/> -->
<!-- <Compile Include="SurfaceArea.4.0.fs" Condition="'$(TargetFramework)' == 'net40'"/> -->
</ItemGroup>
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
</Project>
Expand Up @@ -45,7 +45,7 @@ type UseUnionsAsFlags() =
[<Test>]
member this.CanParseViaBCL() =
let values = System.Enum.GetValues(typeof<FlagsUnion>)
let fourFromString = System.Enum.Parse(typeof<FlagsUnion>, "Four") :?> FlagsUnion // downcast needed
let fourFromString = System.Enum.Parse(typeof<FlagsUnion>, "Four", false) :?> FlagsUnion // downcast needed
Assert.AreEqual(fourFromString, FlagsUnion.Four)

[<Test>]
Expand Down
Expand Up @@ -264,7 +264,10 @@ type AsyncModule() =
:? InvalidOperationException as e when e.Message = "EXPECTED" -> return ()
}
Async.RunSynchronously(test)


#if FSHARP_CORE_NETCORE_PORTABLE
// nothing
#else
[<Test>]
member this.``FromContinuationsCanTailCallCurrentThread``() =
let cnt = ref 0
Expand All @@ -285,6 +288,7 @@ type AsyncModule() =
f 5000 |> Async.StartImmediate
Assert.AreEqual(origTid, !finalTid)
Assert.AreEqual(5000, !cnt)
#endif

[<Test>]
member this.``AwaitWaitHandle With Cancellation``() =
Expand Down Expand Up @@ -343,6 +347,9 @@ type AsyncModule() =

#if FSHARP_CORE_PORTABLE
// nothing
#else
#if FSHARP_CORE_NETCORE_PORTABLE
// nothing
#else
[<Test>]
member this.``SleepContinuations``() =
Expand Down Expand Up @@ -371,13 +378,17 @@ type AsyncModule() =
Assert.AreEqual(0, !okCount)
Assert.AreEqual(0, !errCount)
#endif
#endif

#if FSHARP_CORE_PORTABLE
// nothing
#else
#if FSHARP_CORE_2_0
// nothing
#else
#if FSHARP_CORE_NETCORE_PORTABLE
//nothing
#else
// we are on the desktop
member this.RunExeAndExpectOutput(exeName, expected:string) =
let curDir = (new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).LocalPath |> System.IO.Path.GetDirectoryName
Expand Down Expand Up @@ -455,5 +466,6 @@ AwaitWaitHandleAlreadySignaled0 [|("ok", true); ("caught:boom", true)|]
AwaitWaitHandleAlreadySignaled1 [|("ok", false); ("unhandled", false)|]
""" )

#endif
#endif
#endif
Expand Up @@ -91,6 +91,7 @@ type AsyncType() =
(fun _ -> result := "Cancel"),
cts.Token)
cts.Cancel()
Async.Sleep(1000) |> Async.RunSynchronously
Assert.AreEqual("Cancel", !result)
)

Expand Down Expand Up @@ -125,7 +126,12 @@ type AsyncType() =
member this.CreateTask () =
let s = "Hello tasks!"
let a = async { return s }
use t : Task<string> = Async.StartAsTask a
#if FSHARP_CORE_NETCORE_PORTABLE
let t : Task<string> =
#else
use t : Task<string> =
#endif
Async.StartAsTask a
this.WaitASec t
Assert.IsTrue (t.IsCompleted)
Assert.AreEqual(s, t.Result)
Expand All @@ -134,7 +140,12 @@ type AsyncType() =
member this.StartTask () =
let s = "Hello tasks!"
let a = async { return s }
use t = Async.StartAsTask a
#if FSHARP_CORE_NETCORE_PORTABLE
let t =
#else
use t =
#endif
Async.StartAsTask a
this.WaitASec t
Assert.IsTrue (t.IsCompleted)
Assert.AreEqual(s, t.Result)
Expand All @@ -144,7 +155,12 @@ type AsyncType() =
let a = async {
do raise (Exception ())
}
use t = Async.StartAsTask a
#if FSHARP_CORE_NETCORE_PORTABLE
let t =
#else
use t =
#endif
Async.StartAsTask a
let mutable exceptionThrown = false
try
this.WaitASec t
Expand All @@ -158,7 +174,12 @@ type AsyncType() =
let a = async {
while true do ()
}
use t = Async.StartAsTask a
#if FSHARP_CORE_NETCORE_PORTABLE
let t =
#else
use t =
#endif
Async.StartAsTask a
Async.CancelDefaultToken ()
let mutable exceptionThrown = false
try
Expand All @@ -178,7 +199,12 @@ type AsyncType() =
}
let cts = new CancellationTokenSource()
let token = cts.Token
use t = Async.StartAsTask(a, cancellationToken=token)
#if FSHARP_CORE_NETCORE_PORTABLE
let t =
#else
use t =
#endif
Async.StartAsTask(a, cancellationToken=token)
// printfn "%A" t.Status
ewh.WaitOne() |> Assert.IsTrue
cts.Cancel()
Expand All @@ -195,7 +221,12 @@ type AsyncType() =
[<Test>]
member this.TaskAsyncValue () =
let s = "Test"
use t = Task.Factory.StartNew(Func<_>(fun () -> s))
#if FSHARP_CORE_NETCORE_PORTABLE
let t =
#else
use t =
#endif
Task.Factory.StartNew(Func<_>(fun () -> s))
let a = async {
let! s1 = Async.AwaitTask(t)
return s = s1
Expand All @@ -204,7 +235,12 @@ type AsyncType() =

[<Test>]
member this.TaskAsyncValueException () =
use t = Task.Factory.StartNew(Func<unit>(fun () -> raise <| Exception()))
#if FSHARP_CORE_NETCORE_PORTABLE
let t =
#else
use t =
#endif
Task.Factory.StartNew(Func<unit>(fun () -> raise <| Exception()))
let a = async {
try
let! v = Async.AwaitTask(t)
Expand All @@ -218,7 +254,11 @@ type AsyncType() =
use ewh = new ManualResetEvent(false)
let cts = new CancellationTokenSource()
let token = cts.Token
use t : Task<unit>=
#if FSHARP_CORE_NETCORE_PORTABLE
let t : Task<unit>=
#else
use t : Task<unit>=
#endif
Task.Factory.StartNew(Func<unit>(fun () -> while not token.IsCancellationRequested do ()), token)
let cancelled = ref true
let a = async {
Expand Down
Expand Up @@ -15,84 +15,84 @@ type LazyType() =
member this.Create() =

// int
let intLazy = Lazy.Create(fun () -> 2)
let intLazy = Lazy<_>.Create(fun () -> 2)
Assert.AreEqual(intLazy.Value, 2)

// string
let stringLazy = Lazy.Create(fun () -> "string")
let stringLazy = Lazy<_>.Create(fun () -> "string")
Assert.AreEqual(stringLazy.Value, "string")

// null
let nullLazy = Lazy.Create(fun () -> ())
let nullLazy = Lazy<_>.Create(fun () -> ())
Assert.AreEqual(nullLazy.Value, null)

[<Test>]
member this.CreateFromValue() =

// int
let intLazy = Lazy.CreateFromValue( 2)
let intLazy = Lazy<_>.CreateFromValue( 2)
Assert.AreEqual(intLazy.Value,2)

// string
let stringLazy = Lazy.CreateFromValue( "string")
let stringLazy = Lazy<_>.CreateFromValue( "string")
Assert.AreEqual(stringLazy.Value,"string")

//null
let nullLazy = Lazy.CreateFromValue(null)
let nullLazy = Lazy<_>.CreateFromValue(null)
Assert.AreEqual(nullLazy.Value,null)


[<Test>]
member this.Force() =

// int
let intLazy = Lazy.CreateFromValue( 2)
let intLazy = Lazy<_>.CreateFromValue( 2)
let intForce = intLazy.Force()
Assert.AreEqual(intForce,2)

// string
let stringLazy = Lazy.CreateFromValue( "string")
let stringLazy = Lazy<_>.CreateFromValue( "string")
let stringForce = stringLazy.Force()
Assert.AreEqual(stringForce,"string")

//null
let nullLazy = Lazy.CreateFromValue(null)
let nullLazy = Lazy<_>.CreateFromValue(null)
let nullForce = nullLazy.Force()
Assert.AreEqual(nullForce,null)

[<Test>]
member this.Value() =

// int
let intLazy = Lazy.CreateFromValue( 2)
let intLazy = Lazy<_>.CreateFromValue( 2)
Assert.AreEqual(intLazy.Value,2)

// string
let stringLazy = Lazy.CreateFromValue( "string")
let stringLazy = Lazy<_>.CreateFromValue( "string")
Assert.AreEqual(stringLazy.Value,"string")

//null
let nullLazy = Lazy.CreateFromValue(null)
let nullLazy = Lazy<_>.CreateFromValue(null)
Assert.AreEqual(nullLazy.Value,null)

[<Test>]
member this.IsDelayed() =

// int
let intLazy = Lazy.Create( fun () -> 1)
let intLazy = Lazy<_>.Create( fun () -> 1)
Assert.AreEqual(not intLazy.IsValueCreated,true)
let resultIsDelayed = intLazy.Force()
Assert.AreEqual(not intLazy.IsValueCreated,false)

// string
let stringLazy = Lazy.Create( fun () -> "string")
let stringLazy = Lazy<_>.Create( fun () -> "string")
Assert.AreEqual(not stringLazy.IsValueCreated,true)
let resultIsDelayed = stringLazy.Force()
Assert.AreEqual(not stringLazy.IsValueCreated,false)


//null
let nullLazy = Lazy.Create(fun () -> null)
let nullLazy = Lazy<_>.Create(fun () -> null)
Assert.AreEqual(not nullLazy.IsValueCreated,true)
let resultIsDelayed = nullLazy.Force()
Assert.AreEqual(not nullLazy.IsValueCreated,false)
Expand All @@ -101,20 +101,20 @@ type LazyType() =
member this.IsForced() =

// int
let intLazy = Lazy.Create( fun () -> 1)
let intLazy = Lazy<_>.Create( fun () -> 1)
Assert.AreEqual( intLazy.IsValueCreated,false)
let resultIsForced = intLazy.Force()
Assert.AreEqual( intLazy.IsValueCreated,true)

// string
let stringLazy = Lazy.Create( fun () -> "string")
let stringLazy = Lazy<_>.Create( fun () -> "string")
Assert.AreEqual( stringLazy.IsValueCreated,false)
let resultIsForced = stringLazy.Force()
Assert.AreEqual( stringLazy.IsValueCreated,true)


//null
let nullLazy = Lazy.Create(fun () -> null)
let nullLazy = Lazy<_>.Create(fun () -> null)
Assert.AreEqual( nullLazy.IsValueCreated,false)
let resultIsForced = nullLazy.Force()
Assert.AreEqual( nullLazy.IsValueCreated,true)
Expand Down

0 comments on commit 1d3e209

Please sign in to comment.