-
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
Homework7 #7
Homework7 #7
Conversation
Homework7/Lazy/Library.fs
Outdated
System.Threading.Interlocked.CompareExchange(&value, Some(Error ex), None) | ||
|> ignore | ||
|
||
raise ex |
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.
нужно точно так же паттерн-матчить, а не игнорировать результат с выбросом исключения, поскольку может произойти ситуация, когда успешный поток записал значение, а неуспешный не успел записать эксепшен -- получим два разных результата
Homework7/Lazy.Tests/Tests.fs
Outdated
let object = obj () | ||
let supplier () = object |
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.
supplier возвращает ссылку на один и тот же объект, а должен на разные
|
||
let mutable counter = 0 | ||
|
||
let lazyConstructors = |
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.
нужен ещё один тест, который внутри Supplier будет вызывать Interlocked.Increment &counter, чтобы проверить, что supplier у lock-реализации в многопоточной среде вызывается 1 раз
ну и с эксепшенами в многопоточной среде
return html | ||
with ex -> | ||
printfn "Failed to download %s: %s" url ex.Message | ||
return "" |
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.
можно было вернуть None/Result
link, Some/None length
open FsUnit | ||
open NUnit.Framework | ||
|
||
[<Test>] |
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.
нужны тесты, которые проверят, что в случае исключения при загрузке одной из страниц, для другой спешно выполнится подсчет размера
let mock = Mock<HttClient>()
mock.Setup(fun client -> client.GetStringAsync("hwproj.ru"))
.ReturnsAsync("<html>нормальная ссылка / битая ссылка</html>");
downloadPages "hwproj.ru" mock.Object
No description provided.