-
Notifications
You must be signed in to change notification settings - Fork 0
Workflows #73
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
Open
vologin-dmitry
wants to merge
2
commits into
master
Choose a base branch
from
Workflows
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
Workflows #73
Changes from all commits
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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,17 @@ | ||
| image: Visual Studio 2017 | ||
| image: Visual Studio 2019 | ||
|
|
||
| init: | ||
| - git config --global core.autocrlf true | ||
|
|
||
| environment: | ||
| matrix: | ||
| - solution: Semester4/Workflows/Workflows.sln | ||
|
|
||
| before_build: | ||
| - nuget restore semester2/6.1/HW6T2.sln | ||
| - nuget restore %solution% | ||
|
|
||
| build: | ||
| project: semester2/2.3/2.3.sln | ||
| project: $(solution) | ||
|
|
||
| test_script: | ||
| - dotnet test %solution% |
This file contains hidden or 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 @@ | ||
| module Program = let [<EntryPoint>] main _ = 0 |
This file contains hidden or 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,68 @@ | ||
| module Workflows.Tests | ||
|
|
||
| open NUnit.Framework | ||
| open FsUnit | ||
| open RoundWorkflow | ||
|
|
||
|
|
||
|
|
||
| [<Test>] | ||
| let ``zero accuracy test`` () = | ||
| let workflow = RoundResultBuilder(0) | ||
| workflow { | ||
| let! a = 1.0 * 1.5 | ||
| let! b = 1.5 * 5.0 | ||
| let! c = b / a | ||
| return c | ||
| } |> should equal 4 | ||
|
|
||
| [<Test>] | ||
| let ``one digit accuracy test `` () = | ||
| let workflow = RoundResultBuilder(1) | ||
| workflow { | ||
| let! a = 2.5 * 5.0 | ||
| return a | ||
| } |> should equal 12.5 | ||
|
|
||
| [<Test>] | ||
| let ``two digit accuracy test`` () = | ||
| let workflow = RoundResultBuilder(2) | ||
| workflow { | ||
| let! a = 1.5 * 1.5 | ||
| let! b = 1.1 * 1.4 | ||
| let! c = a / b | ||
| return c | ||
| } |> should equal 1.46 | ||
|
|
||
| [<Test>] | ||
| let ``three digits accuracy test`` () = | ||
| let workflow = RoundResultBuilder(3) | ||
| workflow { | ||
| let! a = 1.5 * 1.5 | ||
| let! b = 1.1 * 1.4 | ||
| let! c = 1.25 * 2.54 | ||
| let! d = 32.3421 / 7.1224 | ||
| let! e = a + c * (b / d) | ||
| return e | ||
| } |> should (equalWithin 0.0001) 3.327 | ||
|
|
||
| [<Test>] | ||
| let ``four digits accuracy test`` () = | ||
| let workflow = RoundResultBuilder(4) | ||
| workflow { | ||
| let! a = 1.111 * 1.5 | ||
| let! b = 1.1 / 2.345 | ||
| let! c = 1.25 + 2.54 | ||
| let! d = 32.3421 / 7.1224 | ||
| let! e = a * c - (b / d) | ||
| return e | ||
| } |> should (equalWithin 0.00001) 6.2127 | ||
|
|
||
| [<Test>] | ||
| let ``example test`` () = | ||
| let workflow = RoundResultBuilder(3) | ||
| workflow { | ||
| let! a = 2.0 / 12.0 | ||
| let! b = 3.5 | ||
| return a / b | ||
| } |> should (equalWithin 0.0001) 0.048 | ||
72 changes: 72 additions & 0 deletions
72
semester4/Workflows/Workflows.Tests/StringWorkflowTests.fs
This file contains hidden or 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,72 @@ | ||
| module StringWorkflowTests | ||
|
|
||
| open NUnit.Framework | ||
| open FsUnit | ||
| open StringWorkflow | ||
|
|
||
| let workflow = StringBuilder() | ||
|
|
||
| [<Test>] | ||
| let ``simple plus test`` () = | ||
| workflow { | ||
| let! a = "5" | ||
| let! b = "2" | ||
| let c = a + b | ||
| return c | ||
| } |> should equal (Some(7)) | ||
|
|
||
| [<Test>] | ||
| let ``simple multiply test`` ()= | ||
| workflow { | ||
| let! a = "3" | ||
| let! b = "15" | ||
| let c = b * a | ||
| return c | ||
| } |> should equal (Some(45)) | ||
|
|
||
| [<Test>] | ||
| let ``simple test`` () = | ||
| workflow { | ||
| let! a = "3" | ||
| let! b = "15" | ||
| let! c = "2" | ||
| let d = c * b | ||
| let e = d / a | ||
| return e | ||
| } |> should equal (Some(10)) | ||
|
|
||
| [<Test>] | ||
| let ``simple subtraction test`` () = | ||
| workflow { | ||
| let! a = "3" | ||
| let! b = "15" | ||
| let c = b - a | ||
| return c | ||
| } |> should equal (Some(12)) | ||
|
|
||
| [<Test>] | ||
| let ``simple division test`` () = | ||
| workflow { | ||
| let! a = "3" | ||
| let! b = "15" | ||
| let c = b / a | ||
| return c | ||
| } |> should equal (Some(5)) | ||
|
|
||
| [<Test>] | ||
| let ``one word test`` () = | ||
| workflow { | ||
| let! a = "3" | ||
| let! b = "isword" | ||
| let c = a + b | ||
| return c | ||
| } |> should equal None | ||
|
|
||
| [<Test>] | ||
| let ``two words test`` () = | ||
| workflow { | ||
| let! a = "mmhmhmh" | ||
| let! b = "isword" | ||
| let c = a / b | ||
| return c | ||
| } |> should equal None |
27 changes: 27 additions & 0 deletions
27
semester4/Workflows/Workflows.Tests/Workflows.Tests.fsproj
This file contains hidden or 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 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
|
|
||
| <IsPackable>false</IsPackable> | ||
| <GenerateProgramFile>false</GenerateProgramFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="FsUnit" Version="4.0.1" /> | ||
| <PackageReference Include="nunit" Version="3.12.0" /> | ||
| <PackageReference Include="NUnit3TestAdapter" Version="3.15.1" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="RoundWorkflowTest.fs" /> | ||
| <Compile Include="StringWorkflowTests.fs" /> | ||
| <Compile Include="Program.fs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Workflows\Workflows.fsproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or 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,22 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Workflows", "Workflows\Workflows.fsproj", "{5AF0A1D8-0BFE-4046-B410-F7D147EF368B}" | ||
| EndProject | ||
| Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Workflows.Tests", "Workflows.Tests\Workflows.Tests.fsproj", "{D70FC128-7397-4ABC-9E14-69BFC7C044CA}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {5AF0A1D8-0BFE-4046-B410-F7D147EF368B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {5AF0A1D8-0BFE-4046-B410-F7D147EF368B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {5AF0A1D8-0BFE-4046-B410-F7D147EF368B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {5AF0A1D8-0BFE-4046-B410-F7D147EF368B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {D70FC128-7397-4ABC-9E14-69BFC7C044CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {D70FC128-7397-4ABC-9E14-69BFC7C044CA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {D70FC128-7397-4ABC-9E14-69BFC7C044CA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {D70FC128-7397-4ABC-9E14-69BFC7C044CA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or 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 RoundWorkflow | ||
|
|
||
| open System | ||
|
|
||
| /// Workflow witch calculates expression and rounding its result | ||
| type RoundResultBuilder(accuracy : int) = | ||
| member this.Bind(x : float, f) = | ||
| Math.Round(x, accuracy) |> f | ||
| member this.Return(x : float) = | ||
| Math.Round(x, accuracy) |
This file contains hidden or 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,12 @@ | ||
| module StringWorkflow | ||
|
|
||
| open System | ||
|
|
||
| /// Workflow witch calculates expression with string numbers | ||
| type StringBuilder() = | ||
| member this.Bind(x : string, f) = | ||
| match Int32.TryParse(x) with | ||
| | true, number -> number |> f | ||
| | _ -> None | ||
| member this.Return(x) = | ||
| Some(x) |
This file contains hidden or 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,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="RoundWorkflow.fs" /> | ||
| <Compile Include="StringWorkflow.fs" /> | ||
| </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.
Ниже equalWithin, а тут почему-то вещественные числа точно сравниваются