Category:Jq/assert.jq: Difference between revisions

From Rosetta Code
Content added Content deleted
(move Category:jq-assert)
 
m (Category:jq)
 
Line 12: Line 12:
<pre>
<pre>
$ jq -nrc --arg assert debug -L. 'include "rc-assert"; assert(. == false; $__loc__)'
$ jq -nrc --arg assert debug -L. 'include "rc-assert"; assert(. == false; $__loc__)'

["DEBUG:","assertion violation @ <top-level>:1 => false"]
["DEBUG:","assertion violation @ <top-level>:1 => false"]
null
null
</pre>
</pre>

[[Category:jq]]

Latest revision as of 08:49, 27 August 2023

Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

assert.jq is a module which adds support for assertions to the jq programming language.

The following examples assume that the source code has been copied to a file called assert.jq located in the same directory as the importing script so the command line interpreter can find it.

$ jq -nrc --arg assert true -L . 'include "rc-assert"; assert(. == false; $__loc__)'
jq: error (at <unknown>): assertion violation @ <top-level>:1 => false
$ jq -nrc --arg assert debug -L. 'include "rc-assert"; assert(. == false; $__loc__)'
["DEBUG:","assertion violation @ <top-level>:1 => false"]
null

Pages in category "Jq/assert.jq"

This category contains only the following page.