asserts.warning
Check that a command emits the expected warning.
📝Syntax
asserts.warning(command, expectedWarning)
asserts.warning(command, expectedMessage, expectedIdentifier)
[res, msg] = asserts.warning(command, expectedWarning)
📥Input Arguments
Parameter Description
command Command string evaluated in the current context.
expectedWarning Expected warning message substring or warning identifier.
expectedMessage Expected warning message.
expectedIdentifier Expected warning identifier.
📤Output Arguments
Parameter Description
res true if the assertion passes, false otherwise.
msg assertion failure message, empty on success.
📄Description

The assertion passes when the command emits a matching warning.

The two-argument form accepts either the warning message text or the warning identifier.

💡Examples
Expected warning text
asserts.warning('warning(''Nelson:asserts:example'', ''expected warning'');', 'expected warning');
Capture a missing warning
[res, msg] = asserts.warning('1 + 1', 'expected warning');
🔗See Also
asserts.warningFree
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub