Equal test
Learn how to check if a value is equal to another.
This test checks whether two values are equal, with the option to specify a comparison mode.
By default, this test uses the same equivalence rules as the equal operation, making them almost interchangeable, except for the order of evaluation. However, specifying a comparison mode makes the test behave differently.
Syntax
This test has the following syntax:
/*<value>*/ is equal to /*<reference>*/
When comparing a value to a literal, you can use the following shorthand syntax:
/*<value>*/ is /*<literal>*/
Both forms have the same semantics, but the shorthand syntax only works with literals and does not support specifying the comparison mode.
Always use the full syntax when comparing a value to a non-literal, such as a variable or expression. Using the shorthand form will result in a syntax error.
For inequality, you can use the following syntax:
/*<value>*/ is not equal to /*<reference>*/
You can optionally specify a comparison mode:
/*<value>*/ is equal to /*<reference>*/ /*<mode>*/
The following table describes the supported modes:
Mode | Description |
---|---|
ignoring case | Compare strings ignoring case. For example, "foo" is equal to "FOO" in this mode. |
ignoring time | Compare date-time values ignoring time. For example, 2025-05-08T00:00:00 is equal to 2025-05-08T23:59:59 in this mode. |
ignoring fraction | Compare numbers ignoring the decimal part. For example, 1.5 is equal to 1.9 in this mode. |
considering numbers | Compare values numerically, even if they are strings. For example, 1 is equal to "1.0" in this mode. |
By default, the comparison behaves exactly like the equal operation.
Parameters
These are the supported parameters:
Examples
Here is a basic example of how to check whether a value is equal to another value:
1 + 2 is equal to 3 // true
You can also use the shorthand syntax for literals. The following example is equivalent to the previous one:
1 + 2 is 3 // true
The shorthand syntax works only with literals, so the following example is invalid:
1 + 2 is result // 🚨 Invalid
You can specify a comparison mode to change the comparison behavior. For example, the following condition checks whether a string is equal to another, ignoring case:
"foo" is equal to "FOO" ignoring case // true
In the same way, you can check whether a date-time value is equal to another, ignoring time:
"2025-05-08" is equal to "2025-05-08T23:59:59" ignoring time // true