Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

assert

assert( 
g_expression 
[ t_formatString
[ g_arg1 ] … ] )
) 
=> nil

Description

Enables you to insert assertions into the SKILL code, either at the top-level or within a function. It evaluates the expression (g_expression) and returns nil if the expression value is non-nil. Otherwise, throws an error and returns the unevaluated expression.

Arguments

g_expression

A generic expression.

t_formatString

Characters to be printed verbatim, intermixed with format specifications prefixed by the % sign.

g_arg1

The arguments following the format string are printed according to their corresponding format specifications.

Value Returned

nil

Assertion is successful.

Examples

assert(1 == 1)
=> nil
assert( 1==2 )
=> *ERROR* ASSERT FAILED: (1 == 2)
assert( 1==2 “Assertion failed.” )
=> *ERROR* Assertion failed.
a = 1
b = 2
assert( a==b “Assertion failed. %d is not equal to %d” a b )
=> *ERROR* Assertion failed. 1 is not equal to 2.

Related Topics

Core Functions


Return to top
 ⠀
X