[Dlang Episode 97] D Language - assert
Вставка
- Опубліковано 3 чер 2024
- ►Full DLang Series Playlist: • D Language (DLang) Pro...
►Find full courses on: courses.mshah.io/
►Join as member to get perks: / @mikeshah
►Lesson Description: In this lesson I show you how to use assert expressions. 'asserts' are a key tool for testing the correctness of your program. However, asserts are really tools for developers as a 'contract' to ensure that during development time, things that most always be true are indeed true. We should use asserts liberally to test our programs, then we can use 'release' and '-check=assert=off' to remove asserts when deploying to clients. As a best practice, asserts should not contain state changes, but only test a true or false condition of the state of a program at a given time. We'll later look at how asserts and 'static asserts' at compile-time can also be used. As always, share your interesting use cases with the community in the discussion below!
►Please like and subscribe to help the channel!
►UA-cam Channel: / mikeshah
►Join our free community: courses.mshah.io/communities/... - Наука та технологія
Happy episode 100! Time to 'assert' this is the best episode ever, until episode 101 comes out.
Then, we can do 'D a Day 101 Days' and we can all sing!
Indeed! With Ali's lecture, and the two teasers this would be the 100th episode! Perhaps for lesson 100, we'll have to do something special :)
@@MikeShah That is a surprise for longevity since that means you basically been doing this for just about/over two years, huh?
I think I propose something fun for a special.
I actually used the c import once and I forgot lol. It was the printf function, I thought D was more 'c like'.
Maybe you can do an episode on the standard C libs wrapped? Especially since I am also trying to get Raylib to work for a GUI app.
Assertions are null operations in non-debug builds. Instead, enforce from std exception can be used.
Yes, we're going to talk about enforce soon :)
D'asserts?! .. yum yum!!!!
🍰
asserts are run-time based; but they are used during the development phase. Thus, there is static assert for compile-time based checks; isn't it?
Correct!
great video sir .
one request of starting DSA series pls
Cheers! And noted :)
Do you or other D devs use the language in some CI/CD environment, for testing, profiling, etc.?
As the sole purpose of the language?
D has testing built-in which can be triggered in a CI/CD environment. There are third-party testing libraries too for other styles of writing tests
@@aberba say you have a project, written in D (for a Jenkins or SonarQube env.) …
@@bsdooby sure, I don't think it should be an issue in any other language.
@@bsdooby I've used things like Github Actions with D no problem (github recognizes D as well). Tools like dscanner can be integrated into the pipeline as well. Soon I'll talk about some more of the features in dlang like 'unittest' 'coverage' 'profiler' etc. that you can use with tools like Jenkins
@@MikeShah COOL 😎 As always: looking forward for these clips!