An assertion is a statement in code that is a strict rule.
They prevent code from behaving in unexpected ways, by asserting that the code is acting in the way you intended.
This can catch a lot of bugs, because it can enforce correct usage of code.
For example, if your function does not allow null for an argument, that is something you can assert.
Then the user of your code knows that they’ve used your API incorrectly and can correct the issue.
An assertion calls Fiber.abort(), ending execution (unless handled higher up).
Assert that a two values are the same.
(mind that this uses a regular ==, which counts references with the same values as different and can be overridden)
Assert that a two values are the same, and display a message on abort.
(mind that this uses a regular ==, which counts references with the same values as different and can be overridden)
Assert.equal(account.name, player.name, "account and player should always have the same name")