{"size": 1846, "ext": "scrbl", "max_stars_repo_path": "scribblings/assertions.scrbl", "max_stars_repo_name": "jessealama/riposte", "max_stars_repo_stars_event_min_datetime": "2018-11-08T19:12:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-11T16:09:15.000Z", "max_issues_repo_path": "scribblings/assertions.scrbl", "max_issues_repo_name": "jessealama/riposte", "max_issues_repo_issues_event_min_datetime": "2018-10-25T08:57:28.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-12T12:38:06.000Z", "max_forks_repo_path": "scribblings/assertions.scrbl", "max_forks_repo_name": "jessealama/riposte", "max_forks_repo_forks_event_min_datetime": "2018-11-15T08:33:59.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-05T21:07:15.000Z"}
{"max_stars_count": 37, "max_issues_count": 12, "max_forks_count": 5, "avg_line_length": 17.580952381, "max_line_length": 239, "alphanum_fraction": 0.7210184182}
#lang scribble/manual

@title{Assertions}

Assertions are checks that succeed or fail. When executing an assertion, Riposte will see whether what's being asserted is true. If it's true, it moves on to the next thing (command, assertion, etc.). If the check fails, Riposte bails out.

There are a few different kinds of assertions:

@itemlist[

@item{equations}
@item{disequations}
@item{inequalities}
@item{type checks}

]

@section{Equations and inequalities}

Write an equation by writing two expressions separated by @tt{=}.

Write a disequation by writing @tt{!=}

@section{Type checks}

You can use @tt{is} and the JSON type keywords to assert that a value has a certain type. The types are:

@itemlist[

@item[null]

@item{number}

@item{integer}

@item{boolean}

@item{string}

@item{array}

@item{object}

]

You can use these words as-is. Thus:

@codeblock[#:keep-lang-line? #f #:line-numbers #f]|{
#lang riposte
$foo is an integer
}|

is an assertion that succeeds provided that the value held by @tt{$foo} is indeed an integer.

@section{Negation}

You can assert that a value does not have a certain type by using @tt{not}. Thus:

@codeblock[#:keep-lang-line? #f #:line-numbers #f]|{
#lang riposte
$bar is not an array
}|

works provided that @tt{$bar} is not an array.

@section{Adjectives}

One can tweak checks with adjectives. The set of adjectives available depends on the type.

Use @tt{non} to say that a value does not meet a certain adjective.

@subsection{Numeric adjectives}

@itemlist[

@item{@tt{positive} / @tt{non positive}}

@item{@tt{negative} / @@tt{non negative}}

]

@subsection{String adjectives}

@itemlist[

@item{@tt{empty} / @tt{non empty}}

]

@subsection{Array adjectives}

@itemlist[

@item{@tt{empty} / @tt{non empty}}

]

@subsection{Object adjectives}

@itemlist[

@item{@tt{empty} / @tt{non empty}}

]
