forked from featuresnap/BowlingKataFSharp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 490a782
Showing
12 changed files
with
11,205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BowlingKataLib", "BowlingKataLib\BowlingKataLib.fsproj", "{AC6D3F19-C0FF-4623-8191-EC3683E2B48B}" | ||
EndProject | ||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BowlingKataTests", "BowlingKataTests\BowlingKataTests.fsproj", "{2621C5C6-04B7-4891-A28D-96FD4536E4F7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AC6D3F19-C0FF-4623-8191-EC3683E2B48B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AC6D3F19-C0FF-4623-8191-EC3683E2B48B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AC6D3F19-C0FF-4623-8191-EC3683E2B48B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AC6D3F19-C0FF-4623-8191-EC3683E2B48B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2621C5C6-04B7-4891-A28D-96FD4536E4F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2621C5C6-04B7-4891-A28D-96FD4536E4F7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2621C5C6-04B7-4891-A28D-96FD4536E4F7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2621C5C6-04B7-4891-A28D-96FD4536E4F7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{ac6d3f19-c0ff-4623-8191-ec3683e2b48b}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>BowlingKataLib</RootNamespace> | ||
<AssemblyName>BowlingKataLib</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<Name>BowlingKataLib</Name> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<Tailcalls>false</Tailcalls> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<DocumentationFile>bin\Debug\BowlingKataLib.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<Tailcalls>true</Tailcalls> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<DocumentationFile>bin\Release\BowlingKataLib.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="FSharp.Core" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Numerics" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="BowlingLib.fs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module BowlingLib | ||
|
||
let addUp throws = Seq.sum throws | ||
|
||
let scoreThrows (throws: #seq<int>) = | ||
addUp throws | ||
|
||
let scoreCurrentFrame throws = | ||
match throws with | ||
|a::b::tl when (a = 10) -> | ||
let c = List.head tl | ||
((a+b+c), b::tl) | ||
|a::b::tl when (a + b = 10) -> | ||
let c = List.head tl | ||
((a+b+c), tl) | ||
|a::b::tl -> | ||
((a+b), tl) | ||
|a::tl -> (a, []) | ||
|[] -> (0, []) | ||
|
||
let rec scoreGameUtil currentScore throws frameNum= | ||
match (frameNum, throws) with | ||
|(_,[]) -> currentScore | ||
|(10,_) -> currentScore | ||
|_ -> | ||
let (currentFrame, remainingThrows) = scoreCurrentFrame throws | ||
scoreGameUtil (currentScore + currentFrame) remainingThrows (frameNum + 1) | ||
|
||
let scoreGame throws = scoreGameUtil 0 throws 0 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{2621c5c6-04b7-4891-a28d-96fd4536e4f7}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>BowlingKataTests</RootNamespace> | ||
<AssemblyName>BowlingKataTests</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<Name>BowlingKataTests</Name> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<Tailcalls>false</Tailcalls> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<DocumentationFile>bin\Debug\BowlingKataTests.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<Tailcalls>true</Tailcalls> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<DocumentationFile>bin\Release\BowlingKataTests.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<Compile Include="BowlingTests.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="FSharp.Core" /> | ||
<Reference Include="nunit.framework"> | ||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Numerics" /> | ||
<ProjectReference Include="..\BowlingKataLib\BowlingKataLib.fsproj"> | ||
<Name>BowlingKataLib</Name> | ||
<Project>{ac6d3f19-c0ff-4623-8191-ec3683e2b48b}</Project> | ||
<Private>True</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
namespace BowlingTests | ||
|
||
open BowlingLib | ||
open NUnit.Framework | ||
|
||
[<TestFixture>] | ||
module public BowlingTests = | ||
|
||
[<Test>] | ||
let trueIsTrue() = | ||
Assert.AreEqual(true, true) | ||
|
||
[<Test>] | ||
let scoreNoThrowsIsZero() = | ||
let score = scoreThrows [] | ||
Assert.AreEqual(0,score) | ||
|
||
[<Test>] | ||
let scoreOneIsOne () = | ||
let score = scoreThrows [1] | ||
Assert.AreEqual(1,score) | ||
|
||
[<Test>] | ||
let scoreTenIsTen () = | ||
let score = scoreThrows [1;9] | ||
Assert.AreEqual(10,score) | ||
|
||
[<Test>] | ||
let scoreSpareInCurrentFrameIncludesTenPlusOneMoreThrow() = | ||
let (score, _) = scoreCurrentFrame [1;9;5] | ||
Assert.AreEqual(15,score) | ||
|
||
[<Test>] | ||
let scoreStrikeInCurrentFrameIncludesTenPlusOneMoreThrow() = | ||
let (score, _) = scoreCurrentFrame [10;9;5] | ||
Assert.AreEqual(24,score) | ||
[<Test>] | ||
let scoreThreeStrikesInARowGives30ForCurrentFrame() = | ||
let (score, _) = scoreCurrentFrame [10;10;10] | ||
Assert.AreEqual(30,score) | ||
|
||
[<Test>] | ||
let scoreNonSparingFrameGivesRemainderOfInputLessFirstTwoBalls() = | ||
let (score, remainingBalls) = scoreCurrentFrame [1;1;8] | ||
Assert.AreEqual(8, List.head remainingBalls) | ||
|
||
[<Test>] | ||
let scoreSparingFrameGivesRemainderOfInputLessFirstTwoBalls() = | ||
let (score, remainingBalls) = scoreCurrentFrame [1;9;8] | ||
Assert.AreEqual(8, List.head remainingBalls) | ||
|
||
[<Test>] | ||
let scoreStrikingFrameGivesRemainderOfInputLessFirstBall() = | ||
let (score, remainingBalls) = scoreCurrentFrame [10;9;8] | ||
Assert.AreEqual(9, List.head remainingBalls) | ||
|
||
[<Test>] | ||
let perfectGameEqual300() = | ||
let score = scoreGame [10;10;10;10;10;10;10;10;10;10;10;10] | ||
Assert.AreEqual(300, score) | ||
|
||
[<Test>] | ||
let allSparesOf9And1WithLastBallOf9Scores190() = | ||
let score = | ||
scoreGame | ||
[for i in 1..10 do | ||
yield 9; yield 1; | ||
yield 9] | ||
|
||
Assert.AreEqual(190,score) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit" version="2.6.2" targetFramework="net40" /> | ||
</packages> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata> | ||
<id>NUnit</id> | ||
<version>2.6.2</version> | ||
<title>NUnit</title> | ||
<authors>Charlie Poole</authors> | ||
<owners>Charlie Poole</owners> | ||
<licenseUrl>http://nunit.org/nuget/license.html</licenseUrl> | ||
<projectUrl>http://nunit.org/</projectUrl> | ||
<iconUrl>http://nunit.org/nuget/nunit_32x32.png</iconUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. | ||
|
||
Version 2.6 is the seventh major release of this well-known and well-tested programming tool. | ||
|
||
This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner.</description> | ||
<summary>NUnit is a unit-testing framework for all .Net languages with a strong TDD focus.</summary> | ||
<releaseNotes>Version 2.6 is the seventh major release of NUnit. | ||
|
||
Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. | ||
|
||
The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package.</releaseNotes> | ||
<language>en-US</language> | ||
<tags>test testing tdd framework fluent assert theory plugin addin</tags> | ||
</metadata> | ||
</package> |
Binary file not shown.
Oops, something went wrong.