Skip to content

Hw2#2

Open
prfms wants to merge 3 commits intomasterfrom
hw2
Open

Hw2#2
prfms wants to merge 3 commits intomasterfrom
hw2

Conversation

@prfms
Copy link
Copy Markdown
Owner

@prfms prfms commented Mar 21, 2024

No description provided.

Comment on lines +1 to +13
module Homework2.Test.EvenNumCountTest.fs
open NUnit.Framework
open FsCheck
open EvenNumCount
let eqMapAndFilter (ls:list<int>) = countEvenNumMap ls = countEvenNumFilter ls
let eqMapAndFold (ls:list<int>) = countEvenNumMap ls = countEvenNumFold ls
let eqFoldAndFilter (ls:list<int>) = countEvenNumFold ls = countEvenNumFilter ls
[<Test>]
let ``Equality of EvenNumCountMap and EvenNumCountFilter`` () = Check.Quick eqMapAndFilter
[<Test>]
let ``Equality of EvenNumCountMap and EvenNumCountFold`` () = Check.Quick eqMapAndFold
[<Test>]
let ``Equality of EvenNumCountFold and EvenNumCountFilter`` () = Check.Quick eqFoldAndFilter No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

можно было бы написать один тест, в котором проверялась бы эквивалентность всех трех. Так же нужен отдельный текст, который проверит просто корректность какой-либо функции. Иначе может оказаться, что функции эквивалентно некорректны.

Comment on lines +3 to +8
type treeExpression =
| Number of float
| Add of treeExpression * treeExpression
| Multiply of treeExpression * treeExpression
| Subtract of treeExpression * treeExpression
| Divide of treeExpression * treeExpression
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно сделать BinaryOperation, который бы принимал оператор и операнды

@@ -0,0 +1,16 @@
module Homework2.Test.TreeEvaluateTest
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

конечно, лучше покрывать тестами все операции, которые добавили

module PrimeNumbers
let isPrime n =
let rec check i =
i > n / 2 || (n % i <> 0 && check (i + 1))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

можно считать даже до корня из n

open FsUnit

[<Test>]
let ``Check first 10 prime numbers`` () =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тогда уже было бы неплохо проверить, что если передать вместо n другое число, то простые числа будут считаться от него

| "/" -> try
evaluateTree left / evaluateTree right
with
| :? System.DivideByZeroException -> "Division by zero"; infinity
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

я бы не стал ловить тут исключения, а оставил как есть. Пусть вызывающий код разбирается с эксепшеном

@@ -5,12 +5,12 @@ open FsUnit

[<Test>]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

было бы неплохо иметь тест, где левое поддерево так же составное

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants