-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Round builder is ready #12
Open
viktoriia-fomina
wants to merge
2
commits into
master
Choose a base branch
from
Workflow1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,31 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30114.105 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "WorkflowRound", "WorkflowRound\WorkflowRound.fsproj", "{BE5C910B-3CC9-409D-8AD1-12327D6A27D2}" | ||
EndProject | ||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "WorkflowRoundTests", "WorkflowRoundTests\WorkflowRoundTests.fsproj", "{FBBDBE16-C1E7-481F-B57F-2C5CA2EB3159}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{BE5C910B-3CC9-409D-8AD1-12327D6A27D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BE5C910B-3CC9-409D-8AD1-12327D6A27D2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BE5C910B-3CC9-409D-8AD1-12327D6A27D2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BE5C910B-3CC9-409D-8AD1-12327D6A27D2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{FBBDBE16-C1E7-481F-B57F-2C5CA2EB3159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FBBDBE16-C1E7-481F-B57F-2C5CA2EB3159}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FBBDBE16-C1E7-481F-B57F-2C5CA2EB3159}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FBBDBE16-C1E7-481F-B57F-2C5CA2EB3159}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {83ED9AA1-D785-45F8-BE71-2D0864C18522} | ||
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,6 @@ | ||
| ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
|
||
0 // return an integer exit code |
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,10 @@ | ||
module Rounding | ||
|
||
open System | ||
|
||
/// Rounds float numbers result. | ||
type RoundBuilder(roundTo : int) = | ||
let round = roundTo | ||
member this.Bind(x : float, f) = | ||
f <| Math.Round(x, round) | ||
member this.Return(x : float) = Math.Round(x, round) |
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Rounding.fs" /> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
</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,29 @@ | ||
module WorkflowRoundTests | ||
|
||
open NUnit.Framework | ||
open Rounding | ||
open FsUnit | ||
|
||
let testCaseData1 = | ||
[ | ||
2.0, 12.0, 3.5, 3, 0.048 | ||
2.0, 12.0, 3.5, 2, 0.05 | ||
1.0, 1.0, 1.0, 1, 1.0 | ||
1.0, 3.0, 1.0, 1, 0.3 | ||
1.0, 3.0, 1.0, 2, 0.33 | ||
] |> List.map (fun (op1, op2, op3, roundTo, result) -> TestCaseData(op1, op2, op3, roundTo, result)) | ||
|
||
let rounding roundTo = new RoundBuilder(roundTo) | ||
|
||
let calcRound op1 op2 op3 round = | ||
rounding round { | ||
let! a = op1 / op2 | ||
let! b = op3 | ||
return a / b | ||
} | ||
|
||
[<Test>] | ||
[<TestCaseSource("testCaseData1")>] | ||
let ``Rounding works correctly tests`` op1 op2 op3 roundTo result = | ||
calcRound op1 op2 op3 roundTo |> should equal result | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нельзя сравнивать вещественные числа equal :) См. http://0.30000000000000004.com/. Используйте equalWithin. |
||
|
32 changes: 32 additions & 0 deletions
32
hw6/WorkflowRound/WorkflowRoundTests/WorkflowRoundTests.fsproj
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,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
<GenerateProgramFile>true</GenerateProgramFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FsUnit" Version="3.8.1" /> | ||
<PackageReference Include="nunit" Version="3.12.0" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="RoundingTests.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WorkflowRound\WorkflowRound.fsproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Update="FSharp.Core" Version="4.7.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это не нужно, roundTo "попадает в замыкание" объекта и вполне себе доступен всё время его жизни