summaryrefslogtreecommitdiff
path: root/doc/tests/test.md
blob: c338561492cc8d8d7c966f77453db10594002a02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Test.fnl

**Table of contents**

- [`deftest`](#deftest)
- [`testing`](#testing)
- [`assert-eq`](#assert-eq)
- [`assert-ne`](#assert-ne)
- [`assert-is`](#assert-is)
- [`assert-not`](#assert-not)

## `deftest`
Function signature:

```
(deftest name ...)
```

Simple way of grouping tests.

## `testing`
Function signature:

```
(testing description ...)
```

Print test description and run it.

## `assert-eq`
Function signature:

```
(assert-eq expr1 expr2 msg)
```

Like `assert`, except compares results of two expressions on equality.
Generates formatted message if `msg` is not set to other message.

### Example
Compare two expressions:

``` fennel
>> (assert-eq 1 (+1 1))
runtime error: equality assertion failed
  Left: 1
  Right: 3
```

Deep compare values:

``` fennel
>> (assert-eq [1 {[2 3] [4 5 6]}] [1 {[2 3] [4 5]}])
runtime error: equality assertion failed
  Left: [1 {
    [2 3] [4 5 6]
  }]
  Right: [1 {
    [2 3] [4 5]
  }]
```

## `assert-ne`
Function signature:

```
(assert-ne expr1 expr2 msg)
```

Assert for unequality.  Same as [`assert-eq`](#assert-eq).

## `assert-is`
Function signature:

```
(assert-is expr msg)
```

Assert for truth. Same as inbuilt `assert`, except generates more
  verbose message if `msg` is not set.

``` fennel
>> (assert-is (= 1 2 3))
runtime error: assertion failed for (= 1 2 3)
```

## `assert-not`
Function signature:

```
(assert-not expr msg)
```

Assert for not truth. Works the same as [`assert-is`](#assert-is).


<!-- Generated with Fenneldoc 0.0.6
     https://gitlab.com/andreyorst/fenneldoc -->