# Tests

> Built-in tests for use with is.

A test checks a value and returns `true` or `false`. Write it after `is`, or `is not` to flip the result.

```kiln
{% if items is not empty %}
```

## `defined`

True when a variable or property exists. It never raises a [strict mode](https://kilnlang.com/docs/language/strict-mode/) error, so it is the safe way to check for optional data.

page.kiln:

```kiln
{% if page.subtitle is defined %}{{ page.subtitle }}{% else %}No subtitle{% endif %}
```

Output:

```html
No subtitle
```

## `null`

True when the value is null or undefined.

page.kiln:

```kiln
{{ page.image is null ? "No image" : "Has image" }}
```

Output:

```html
No image
```

## `empty`

True when the value is [empty](https://kilnlang.com/docs/language/values/#empty-values): null, `false`, an empty string, array, hash, set or map. `0` is not empty.

page.kiln:

```kiln
{{ [] is empty }} {{ 0 is empty }}
```

Output:

```html
true false
```

## `even` and `odd`

True when the value is an even or odd whole number.

page.kiln:

```kiln
{% for n in 1..4 %}{{ n }} is {{ n is even ? "even" : "odd" }}. {% endfor %}
```

Output:

```html
1 is odd. 2 is even. 3 is odd. 4 is even.
```

## `iterable`

True for arrays, hashes, sets, maps and other values `for` can loop over. Strings are not iterable.

page.kiln:

```kiln
{{ [1, 2] is iterable }} {{ "abc" is iterable }}
```

Output:

```html
true false
```

## `divisible by`

True when the value is a multiple of the argument.

page.kiln:

```kiln
{% for n in 1..6 %}{{ n }}{% if n is divisible by(3) %} |{% endif %} {% endfor %}
```

Output:

```html
1 2 3 | 4 5 6 |
```
