Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,5 @@ ASALocalRun/
#This is mine and this is now
.bin/
.obj/
.Properties/
.Properties/
/semester4/SecondHomework
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: Visual Studio 2017
image: Visual Studio 2019

before_build:
- nuget restore semester2/6.1/HW6T2.sln
- nuget restore semester4/TestAttempt4/TestAttempt.sln

build:
project: semester2/2.3/2.3.sln
project: semester4/TestAttempt4/TestAttempt.sln
1 change: 1 addition & 0 deletions semester4/TestAttempt4/QueueTests/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Program = let [<EntryPoint>] main _ = 0
25 changes: 25 additions & 0 deletions semester4/TestAttempt4/QueueTests/QueueTests.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<ItemGroup>
<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="UnitTest1.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TestAttempt\TestAttempt.fsproj" />
</ItemGroup>

</Project>
29 changes: 29 additions & 0 deletions semester4/TestAttempt4/QueueTests/UnitTest1.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module ThirdTimeTests

open NUnit.Framework
open Queue
open FsUnit

let mutable queue = new Queue<string>()

[<SetUp>]
let Setup () = queue <- new Queue<string>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще, это обычные функции, в F# они пишутся со строчной


[<Test>]
let EmptyTest () =
Assert.True(queue.IsEmpty)

[<Test>]
let OneElementTest () =
queue.Enqueue "hello"
Assert.False(queue.IsEmpty)

[<Test>]
let SimpleTest() =
queue.Enqueue "1"
queue.Enqueue "2"
Assert.AreEqual("1", queue.Dequeue())
Assert.AreEqual("2", queue.Dequeue())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FsUbit же, зачем Assert.AreEqual


[<Test>]
let ExceptionTest () = Assert.Throws<System.IndexOutOfRangeException>((fun () -> queue.Dequeue() |>ignore)) |> ignore
31 changes: 31 additions & 0 deletions semester4/TestAttempt4/TestAttempt.sln
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.29926.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestAttempt", "TestAttempt\TestAttempt.fsproj", "{C613B135-69E3-42CC-BD94-E13A5715ECD8}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "QueueTests", "QueueTests\QueueTests.fsproj", "{B8C0D5E7-9DA4-453F-AA60-9EDB6F779CC9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C613B135-69E3-42CC-BD94-E13A5715ECD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C613B135-69E3-42CC-BD94-E13A5715ECD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C613B135-69E3-42CC-BD94-E13A5715ECD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C613B135-69E3-42CC-BD94-E13A5715ECD8}.Release|Any CPU.Build.0 = Release|Any CPU
{B8C0D5E7-9DA4-453F-AA60-9EDB6F779CC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8C0D5E7-9DA4-453F-AA60-9EDB6F779CC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8C0D5E7-9DA4-453F-AA60-9EDB6F779CC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8C0D5E7-9DA4-453F-AA60-9EDB6F779CC9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AA23B06E-C86F-4BBC-A63E-374C252C6C87}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions semester4/TestAttempt4/TestAttempt/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
printfn "Hello World from F#!"
0 // return an integer exit code
24 changes: 24 additions & 0 deletions semester4/TestAttempt4/TestAttempt/Queue.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Queue

///Простая очередь
type Queue<'a>() =
let mutable list = []

///Добавить в элемент
member this.Enqueue (value : 'a) =
let reversed = List.rev list
list <- List.rev (value :: reversed)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну, так можно, но можно было просто сконкатенировать в хвост. Работало бы вдвое быстрее :)


///Получить первый в очереди элемент
member this.Dequeue() =
match list.Length with
| 0 -> raise (System.IndexOutOfRangeException("Queue is empty!"))
| _ -> let head = list.Head
list <- list.Tail
head

///Узнать количество элементов в очереди
member this.Length() = list.Length

///Узнать является ли очередь пустой
member this.IsEmpty = list.IsEmpty
17 changes: 17 additions & 0 deletions semester4/TestAttempt4/TestAttempt/TestAttempt.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Queue.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsUnit" Version="3.8.1" />
</ItemGroup>

</Project>