[
  {
    "path": ".travis.yml",
    "content": "language: bash\nbefore_install:\n  - ./script/install-bats.sh\n  - git clone --depth 1 https://github.com/ztombol/bats-support ../bats-support\nbefore_script:\n  - export PATH=\"${HOME}/.local/bin:${PATH}\"\nscript:\n  - bats test\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Change Log\n\nAll notable changes to this project will be documented in this file.\nThis project adheres to [Semantic Versioning](http://semver.org/).\n\n\n## [0.3.0] - 2016-03-22\n\n### Removed\n\n- Move `fail()` to `bats-support`\n\n\n## [0.2.0] - 2016-03-11\n\n### Added\n\n- `refute()` to complement `assert()`\n- `npm` support\n\n### Fixed\n\n- Not consuming the `--` when stopping option parsing in\n  `assert_output`, `refute_output`, `assert_line` and `refute_line`\n\n\n## 0.1.0 - 2016-02-16\n\n### Added\n\n- Reporting arbitrary failures with `fail()`\n- Generic assertions with `assert()` and `assert_equal()`\n- Testing exit status with `assert_success()` and `assert_failure()`\n- Testing output with `assert_output()` and `refute_output()`\n- Testing individual lines with `assert_line()` and `refute_line()`\n\n\n[0.3.0]: https://github.com/ztombol/bats-assert/compare/v0.2.0...v0.3.0\n[0.2.0]: https://github.com/ztombol/bats-assert/compare/v0.1.0...v0.2.0\n"
  },
  {
    "path": "LICENSE",
    "content": "CC0 1.0 Universal\n\nStatement of Purpose\n\nThe laws of most jurisdictions throughout the world automatically confer\nexclusive Copyright and Related Rights (defined below) upon the creator and\nsubsequent owner(s) (each and all, an \"owner\") of an original work of\nauthorship and/or a database (each, a \"Work\").\n\nCertain owners wish to permanently relinquish those rights to a Work for the\npurpose of contributing to a commons of creative, cultural and scientific\nworks (\"Commons\") that the public can reliably and without fear of later\nclaims of infringement build upon, modify, incorporate in other works, reuse\nand redistribute as freely as possible in any form whatsoever and for any\npurposes, including without limitation commercial purposes. These owners may\ncontribute to the Commons to promote the ideal of a free culture and the\nfurther production of creative, cultural and scientific works, or to gain\nreputation or greater distribution for their Work in part through the use and\nefforts of others.\n\nFor these and/or other purposes and motivations, and without any expectation\nof additional consideration or compensation, the person associating CC0 with a\nWork (the \"Affirmer\"), to the extent that he or she is an owner of Copyright\nand Related Rights in the Work, voluntarily elects to apply CC0 to the Work\nand publicly distribute the Work under its terms, with knowledge of his or her\nCopyright and Related Rights in the Work and the meaning and intended legal\neffect of CC0 on those rights.\n\n1. Copyright and Related Rights. A Work made available under CC0 may be\nprotected by copyright and related or neighboring rights (\"Copyright and\nRelated Rights\"). Copyright and Related Rights include, but are not limited\nto, the following:\n\n  i. the right to reproduce, adapt, distribute, perform, display, communicate,\n  and translate a Work;\n\n  ii. moral rights retained by the original author(s) and/or performer(s);\n\n  iii. publicity and privacy rights pertaining to a person's image or likeness\n  depicted in a Work;\n\n  iv. rights protecting against unfair competition in regards to a Work,\n  subject to the limitations in paragraph 4(a), below;\n\n  v. rights protecting the extraction, dissemination, use and reuse of data in\n  a Work;\n\n  vi. database rights (such as those arising under Directive 96/9/EC of the\n  European Parliament and of the Council of 11 March 1996 on the legal\n  protection of databases, and under any national implementation thereof,\n  including any amended or successor version of such directive); and\n\n  vii. other similar, equivalent or corresponding rights throughout the world\n  based on applicable law or treaty, and any national implementations thereof.\n\n2. Waiver. To the greatest extent permitted by, but not in contravention of,\napplicable law, Affirmer hereby overtly, fully, permanently, irrevocably and\nunconditionally waives, abandons, and surrenders all of Affirmer's Copyright\nand Related Rights and associated claims and causes of action, whether now\nknown or unknown (including existing as well as future claims and causes of\naction), in the Work (i) in all territories worldwide, (ii) for the maximum\nduration provided by applicable law or treaty (including future time\nextensions), (iii) in any current or future medium and for any number of\ncopies, and (iv) for any purpose whatsoever, including without limitation\ncommercial, advertising or promotional purposes (the \"Waiver\"). Affirmer makes\nthe Waiver for the benefit of each member of the public at large and to the\ndetriment of Affirmer's heirs and successors, fully intending that such Waiver\nshall not be subject to revocation, rescission, cancellation, termination, or\nany other legal or equitable action to disrupt the quiet enjoyment of the Work\nby the public as contemplated by Affirmer's express Statement of Purpose.\n\n3. Public License Fallback. Should any part of the Waiver for any reason be\njudged legally invalid or ineffective under applicable law, then the Waiver\nshall be preserved to the maximum extent permitted taking into account\nAffirmer's express Statement of Purpose. In addition, to the extent the Waiver\nis so judged Affirmer hereby grants to each affected person a royalty-free,\nnon transferable, non sublicensable, non exclusive, irrevocable and\nunconditional license to exercise Affirmer's Copyright and Related Rights in\nthe Work (i) in all territories worldwide, (ii) for the maximum duration\nprovided by applicable law or treaty (including future time extensions), (iii)\nin any current or future medium and for any number of copies, and (iv) for any\npurpose whatsoever, including without limitation commercial, advertising or\npromotional purposes (the \"License\"). The License shall be deemed effective as\nof the date CC0 was applied by Affirmer to the Work. Should any part of the\nLicense for any reason be judged legally invalid or ineffective under\napplicable law, such partial invalidity or ineffectiveness shall not\ninvalidate the remainder of the License, and in such case Affirmer hereby\naffirms that he or she will not (i) exercise any of his or her remaining\nCopyright and Related Rights in the Work or (ii) assert any associated claims\nand causes of action with respect to the Work, in either case contrary to\nAffirmer's express Statement of Purpose.\n\n4. Limitations and Disclaimers.\n\n  a. No trademark or patent rights held by Affirmer are waived, abandoned,\n  surrendered, licensed or otherwise affected by this document.\n\n  b. Affirmer offers the Work as-is and makes no representations or warranties\n  of any kind concerning the Work, express, implied, statutory or otherwise,\n  including without limitation warranties of title, merchantability, fitness\n  for a particular purpose, non infringement, or the absence of latent or\n  other defects, accuracy, or the present or absence of errors, whether or not\n  discoverable, all to the greatest extent permissible under applicable law.\n\n  c. Affirmer disclaims responsibility for clearing rights of other persons\n  that may apply to the Work or any use thereof, including without limitation\n  any person's Copyright and Related Rights in the Work. Further, Affirmer\n  disclaims responsibility for obtaining any necessary consents, permissions\n  or other rights required for any use of the Work.\n\n  d. Affirmer understands and acknowledges that Creative Commons is not a\n  party to this document and has no duty or obligation with respect to this\n  CC0 or use of the Work.\n\nFor more information, please see\n<http://creativecommons.org/publicdomain/zero/1.0/>\n"
  },
  {
    "path": "README.md",
    "content": "# bats-assert\n\n[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/ztombol/bats-assert/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/ztombol/bats-assert.svg)](https://github.com/ztombol/bats-assert/releases/latest)\n[![Build Status](https://travis-ci.org/ztombol/bats-assert.svg?branch=master)](https://travis-ci.org/ztombol/bats-assert)\n\n`bats-assert` is a helper library providing common assertions for\n[Bats][bats].\n\nAssertions are functions that perform a test and output relevant\ninformation on failure to help debugging. They return 1 on failure and 0\notherwise. Output, [formatted][bats-support-output] for readability, is\nsent to the standard error to make assertions usable outside of `@test`\nblocks too.\n\nAssertions testing exit code and output operate on the results of the\nmost recent invocation of `run`.\n\nDependencies:\n- [`bats-support`][bats-support] (formerly `bats-core`) - output\n  formatting\n\nSee the [shared documentation][bats-docs] to learn how to install and\nload this library.\n\n\n## Usage\n\n### `assert`\n\nFail if the given expression evaluates to false.\n\n***Note:*** *The expression must be a simple command. [Compound\ncommands][bash-comp-cmd], such as `[[`, can be used only when executed\nwith `bash -c`.*\n\n```bash\n@test 'assert()' {\n  touch '/var/log/test.log'\n  assert [ -e '/var/log/test.log' ]\n}\n```\n\nOn failure, the failed expression is displayed.\n\n```\n-- assertion failed --\nexpression : [ -e /var/log/test.log ]\n--\n```\n\n\n### `refute`\n\nFail if the given expression evaluates to true.\n\n***Note:*** *The expression must be a simple command. [Compound\ncommands][bash-comp-cmd], such as `[[`, can be used only when executed\nwith `bash -c`.*\n\n```bash\n@test 'refute()' {\n  rm -f '/var/log/test.log'\n  refute [ -e '/var/log/test.log' ]\n}\n```\n\nOn failure, the successful expression is displayed.\n\n```\n-- assertion succeeded, but it was expected to fail --\nexpression : [ -e /var/log/test.log ]\n--\n```\n\n\n### `assert_equal`\n\nFail if the two parameters, actual and expected value respectively, do\nnot equal.\n\n```bash\n@test 'assert_equal()' {\n  assert_equal 'have' 'want'\n}\n```\n\nOn failure, the expected and actual values are displayed.\n\n```\n-- values do not equal --\nexpected : want\nactual   : have\n--\n```\n\nIf either value is longer than one line both are displayed in\n*multi-line* format.\n\n\n### `assert_success`\n\nFail if `$status` is not 0.\n\n```bash\n@test 'assert_success() status only' {\n  run bash -c \"echo 'Error!'; exit 1\"\n  assert_success\n}\n```\n\nOn failure, `$status` and `$output` are displayed.\n\n```\n-- command failed --\nstatus : 1\noutput : Error!\n--\n```\n\nIf `$output` is longer than one line, it is displayed in *multi-line*\nformat.\n\n\n### `assert_failure`\n\nFail if `$status` is 0.\n\n```bash\n@test 'assert_failure() status only' {\n  run echo 'Success!'\n  assert_failure\n}\n```\n\nOn failure, `$output` is displayed.\n\n```\n-- command succeeded, but it was expected to fail --\noutput : Success!\n--\n```\n\nIf `$output` is longer than one line, it is displayed in *multi-line*\nformat.\n\n#### Expected status\n\nWhen one parameter is specified, fail if `$status` does not equal the\nexpected status specified by the parameter.\n\n```bash\n@test 'assert_failure() with expected status' {\n  run bash -c \"echo 'Error!'; exit 1\"\n  assert_failure 2\n}\n```\n\nOn failure, the expected and actual status, and `$output` are displayed.\n\n```\n-- command failed as expected, but status differs --\nexpected : 2\nactual   : 1\noutput   : Error!\n--\n```\n\nIf `$output` is longer than one line, it is displayed in *multi-line*\nformat.\n\n\n### `assert_output`\n\nThis function helps to verify that a command or function produces the\ncorrect output by checking that the specified expected output matches\nthe actual output. Matching can be literal (default), partial or regular\nexpression. This function is the logical complement of `refute_output`.\n\n#### Literal matching\n\nBy default, literal matching is performed. The assertion fails if\n`$output` does not equal the expected output.\n\n```bash\n@test 'assert_output()' {\n  run echo 'have'\n  assert_output 'want'\n}\n```\n\nThe expected output can be specified with a heredoc or standard input as well.\n\n```bash\n@test 'assert_output() with pipe' {\n  run echo 'have'\n  echo 'want' | assert_output\n}\n```\n\nOn failure, the expected and actual output are displayed.\n\n```\n-- output differs --\nexpected : want\nactual   : have\n--\n```\n\nIf either value is longer than one line both are displayed in\n*multi-line* format.\n\n#### Partial matching\n\nPartial matching can be enabled with the `--partial` option (`-p` for\nshort). When used, the assertion fails if the expected *substring* is\nnot found in `$output`.\n\n```bash\n@test 'assert_output() partial matching' {\n  run echo 'ERROR: no such file or directory'\n  assert_output --partial 'SUCCESS'\n}\n```\n\nOn failure, the substring and the output are displayed.\n\n```\n-- output does not contain substring --\nsubstring : SUCCESS\noutput    : ERROR: no such file or directory\n--\n```\n\nThis option and regular expression matching (`--regexp` or `-e`) are\nmutually exclusive. An error is displayed when used simultaneously.\n\n#### Regular expression matching\n\nRegular expression matching can be enabled with the `--regexp` option\n(`-e` for short). When used, the assertion fails if the *extended\nregular expression* does not match `$output`.\n\n*Note: The anchors `^` and `$` bind to the beginning and the end of the\nentire output (not individual lines), respectively.*\n\n```bash\n@test 'assert_output() regular expression matching' {\n  run echo 'Foobar 0.1.0'\n  assert_output --regexp '^Foobar v[0-9]+\\.[0-9]+\\.[0-9]$'\n}\n```\n\nOn failure, the regular expression and the output are displayed.\n\n```\n-- regular expression does not match output --\nregexp : ^Foobar v[0-9]+\\.[0-9]+\\.[0-9]$\noutput : Foobar 0.1.0\n--\n```\n\nAn error is displayed if the specified extended regular expression is\ninvalid.\n\nThis option and partial matching (`--partial` or `-p`) are mutually\nexclusive. An error is displayed when used simultaneously.\n\n\n### `refute_output`\n\nThis function helps to verify that a command or function produces the\ncorrect output by checking that the specified unexpected output does not\nmatch the actual output. Matching can be literal (default), partial or\nregular expression. This function is the logical complement of\n`assert_output`.\n\n#### Literal matching\n\nBy default, literal matching is performed. The assertion fails if\n`$output` equals the unexpected output.\n\n```bash\n@test 'refute_output()' {\n  run echo 'want'\n  refute_output 'want'\n}\n```\n\n-The unexpected output can be specified with a heredoc or standard input as well.\n\n```bash\n@test 'refute_output() with pipe' {\n  run echo 'want'\n  echo 'want' | refute_output\n}\n```\n\nOn failure, the output is displayed.\n\n```\n-- output equals, but it was expected to differ --\noutput : want\n--\n```\n\nIf output is longer than one line it is displayed in *multi-line*\nformat.\n\n#### Partial matching\n\nPartial matching can be enabled with the `--partial` option (`-p` for\nshort). When used, the assertion fails if the unexpected *substring* is\nfound in `$output`.\n\n```bash\n@test 'refute_output() partial matching' {\n  run echo 'ERROR: no such file or directory'\n  refute_output --partial 'ERROR'\n}\n```\n\nOn failure, the substring and the output are displayed.\n\n```\n-- output should not contain substring --\nsubstring : ERROR\noutput    : ERROR: no such file or directory\n--\n```\n\nThis option and regular expression matching (`--regexp` or `-e`) are\nmutually exclusive. An error is displayed when used simultaneously.\n\n#### Regular expression matching\n\nRegular expression matching can be enabled with the `--regexp` option\n(`-e` for short). When used, the assertion fails if the *extended\nregular expression* matches `$output`.\n\n*Note: The anchors `^` and `$` bind to the beginning and the end of the\nentire output (not individual lines), respectively.*\n\n```bash\n@test 'refute_output() regular expression matching' {\n  run echo 'Foobar v0.1.0'\n  refute_output --regexp '^Foobar v[0-9]+\\.[0-9]+\\.[0-9]$'\n}\n```\n\nOn failure, the regular expression and the output are displayed.\n\n```\n-- regular expression should not match output --\nregexp : ^Foobar v[0-9]+\\.[0-9]+\\.[0-9]$\noutput : Foobar v0.1.0\n--\n```\n\nAn error is displayed if the specified extended regular expression is\ninvalid.\n\nThis option and partial matching (`--partial` or `-p`) are mutually\nexclusive. An error is displayed when used simultaneously.\n\n\n### `assert_line`\n\nSimilarly to `assert_output`, this function helps to verify that a\ncommand or function produces the correct output. It checks that the\nexpected line appears in the output (default) or in a specific line of\nit. Matching can be literal (default), partial or regular expression.\nThis function is the logical complement of `refute_line`.\n\n***Warning:*** *Due to a [bug in Bats][bats-93], empty lines are\ndiscarded from `${lines[@]}`, causing line indices to change and\npreventing testing for empty lines.*\n\n[bats-93]: https://github.com/sstephenson/bats/pull/93\n\n#### Looking for a line in the output\n\nBy default, the entire output is searched for the expected line. The\nassertion fails if the expected line is not found in `${lines[@]}`.\n\n```bash\n@test 'assert_line() looking for line' {\n  run echo $'have-0\\nhave-1\\nhave-2'\n  assert_line 'want'\n}\n```\n\nOn failure, the expected line and the output are displayed.\n\n***Warning:*** *The output displayed does not contain empty lines. See\nthe Warning above for more.*\n\n```\n-- output does not contain line --\nline : want\noutput (3 lines):\n  have-0\n  have-1\n  have-2\n--\n```\n\nIf output is not longer than one line, it is displayed in *two-column*\nformat.\n\n#### Matching a specific line\n\nWhen the `--index <idx>` option is used (`-n <idx>` for short) , the\nexpected line is matched only against the line identified by the given\nindex. The assertion fails if the expected line does not equal\n`${lines[<idx>]}`.\n\n```bash\n@test 'assert_line() specific line' {\n  run echo $'have-0\\nhave-1\\nhave-2'\n  assert_line --index 1 'want-1'\n}\n```\n\nOn failure, the index and the compared lines are displayed.\n\n```\n-- line differs --\nindex    : 1\nexpected : want-1\nactual   : have-1\n--\n```\n\n#### Partial matching\n\nPartial matching can be enabled with the `--partial` option (`-p` for\nshort). When used, a match fails if the expected *substring* is not\nfound in the matched line.\n\n```bash\n@test 'assert_line() partial matching' {\n  run echo $'have 1\\nhave 2\\nhave 3'\n  assert_line --partial 'want'\n}\n```\n\nOn failure, the same details are displayed as for literal matching,\nexcept that the substring replaces the expected line.\n\n```\n-- no output line contains substring --\nsubstring : want\noutput (3 lines):\n  have 1\n  have 2\n  have 3\n--\n```\n\nThis option and regular expression matching (`--regexp` or `-e`) are\nmutually exclusive. An error is displayed when used simultaneously.\n\n#### Regular expression matching\n\nRegular expression matching can be enabled with the `--regexp` option\n(`-e` for short). When used, a match fails if the *extended regular\nexpression* does not match the line being tested.\n\n*Note: As expected, the anchors `^` and `$` bind to the beginning and\nthe end of the matched line, respectively.*\n\n```bash\n@test 'assert_line() regular expression matching' {\n  run echo $'have-0\\nhave-1\\nhave-2'\n  assert_line --index 1 --regexp '^want-[0-9]$'\n}\n```\n\nOn failure, the same details are displayed as for literal matching,\nexcept that the regular expression replaces the expected line.\n\n```\n-- regular expression does not match line --\nindex  : 1\nregexp : ^want-[0-9]$\nline   : have-1\n--\n```\n\nAn error is displayed if the specified extended regular expression is\ninvalid.\n\nThis option and partial matching (`--partial` or `-p`) are mutually\nexclusive. An error is displayed when used simultaneously.\n\n\n### `refute_line`\n\nSimilarly to `refute_output`, this function helps to verify that a\ncommand or function produces the correct output. It checks that the\nunexpected line does not appear in the output (default) or in a specific\nline of it. Matching can be literal (default), partial or regular\nexpression. This function is the logical complement of `assert_line`.\n\n***Warning:*** *Due to a [bug in Bats][bats-93], empty lines are\ndiscarded from `${lines[@]}`, causing line indices to change and\npreventing testing for empty lines.*\n\n[bats-93]: https://github.com/sstephenson/bats/pull/93\n\n#### Looking for a line in the output\n\nBy default, the entire output is searched for the unexpected line. The\nassertion fails if the unexpected line is found in `${lines[@]}`.\n\n```bash\n@test 'refute_line() looking for line' {\n  run echo $'have-0\\nwant\\nhave-2'\n  refute_line 'want'\n}\n```\n\nOn failure, the unexpected line, the index of its first match and the\noutput with the matching line highlighted are displayed.\n\n***Warning:*** *The output displayed does not contain empty lines. See\nthe Warning above for more.*\n\n```\n-- line should not be in output --\nline  : want\nindex : 1\noutput (3 lines):\n  have-0\n> want\n  have-2\n--\n```\n\nIf output is not longer than one line, it is displayed in *two-column*\nformat.\n\n#### Matching a specific line\n\nWhen the `--index <idx>` option is used (`-n <idx>` for short) , the\nunexpected line is matched only against the line identified by the given\nindex. The assertion fails if the unexpected line equals\n`${lines[<idx>]}`.\n\n```bash\n@test 'refute_line() specific line' {\n  run echo $'have-0\\nwant-1\\nhave-2'\n  refute_line --index 1 'want-1'\n}\n```\n\nOn failure, the index and the unexpected line are displayed.\n\n```\n-- line should differ --\nindex : 1\nline  : want-1\n--\n```\n\n#### Partial matching\n\nPartial matching can be enabled with the `--partial` option (`-p` for\nshort). When used, a match fails if the unexpected *substring* is found\nin the matched line.\n\n```bash\n@test 'refute_line() partial matching' {\n  run echo $'have 1\\nwant 2\\nhave 3'\n  refute_line --partial 'want'\n}\n```\n\nOn failure, in addition to the details of literal matching, the\nsubstring is also displayed. When used with `--index <idx>` the\nsubstring replaces the unexpected line.\n\n```\n-- no line should contain substring --\nsubstring : want\nindex     : 1\noutput (3 lines):\n  have 1\n> want 2\n  have 3\n--\n```\n\nThis option and regular expression matching (`--regexp` or `-e`) are\nmutually exclusive. An error is displayed when used simultaneously.\n\n#### Regular expression matching\n\nRegular expression matching can be enabled with the `--regexp` option\n(`-e` for short). When used, a match fails if the *extended regular\nexpression* matches the line being tested.\n\n*Note: As expected, the anchors `^` and `$` bind to the beginning and\nthe end of the matched line, respectively.*\n\n```bash\n@test 'refute_line() regular expression matching' {\n  run echo $'Foobar v0.1.0\\nRelease date: 2015-11-29'\n  refute_line --index 0 --regexp '^Foobar v[0-9]+\\.[0-9]+\\.[0-9]$'\n}\n```\n\nOn failure, in addition to the details of literal matching, the regular\nexpression is also displayed. When used with `--index <idx>` the regular\nexpression replaces the unexpected line.\n\n```\n-- regular expression should not match line --\nindex  : 0\nregexp : ^Foobar v[0-9]+\\.[0-9]+\\.[0-9]$\nline   : Foobar v0.1.0\n--\n```\n\nAn error is displayed if the specified extended regular expression is\ninvalid.\n\nThis option and partial matching (`--partial` or `-p`) are mutually\nexclusive. An error is displayed when used simultaneously.\n\n\n## Options\n\nFor functions that have options, `--` disables option parsing for the\nremaining arguments to allow using arguments identical to one of the\nallowed options.\n\n```bash\nassert_output -- '-p'\n```\n\nSpecifying `--` as an argument is similarly simple.\n\n```bash\nrefute_line -- '--'\n```\n\n\n<!-- REFERENCES -->\n\n[bats]: https://github.com/sstephenson/bats\n[bats-support-output]: https://github.com/ztombol/bats-support#output-formatting\n[bats-support]: https://github.com/ztombol/bats-support\n[bats-docs]: https://github.com/ztombol/bats-docs\n[bash-comp-cmd]: https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands\n"
  },
  {
    "path": "load.bash",
    "content": "source \"$(dirname \"${BASH_SOURCE[0]}\")/src/assert.bash\"\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"bats-assert\",\n  \"version\": \"0.3.0\",\n  \"private\": true,\n  \"peerDependencies\": {\n    \"bats-support\": \"git+https://github.com/ztombol/bats-support.git#v0.2.0\"\n  }\n}\n"
  },
  {
    "path": "script/install-bats.sh",
    "content": "#!/bin/sh\nset -o errexit\nset -o xtrace\n\ngit clone --depth 1 https://github.com/sstephenson/bats\ncd bats && ./install.sh \"${HOME}/.local\" && cd .. && rm -rf bats\n"
  },
  {
    "path": "src/assert.bash",
    "content": "#\n# bats-assert - Common assertions for Bats\n#\n# Written in 2016 by Zoltan Tombol <zoltan dot tombol at gmail dot com>\n#\n# To the extent possible under law, the author(s) have dedicated all\n# copyright and related and neighboring rights to this software to the\n# public domain worldwide. This software is distributed without any\n# warranty.\n#\n# You should have received a copy of the CC0 Public Domain Dedication\n# along with this software. If not, see\n# <http://creativecommons.org/publicdomain/zero/1.0/>.\n#\n\n#\n# assert.bash\n# -----------\n#\n# Assertions are functions that perform a test and output relevant\n# information on failure to help debugging. They return 1 on failure\n# and 0 otherwise.\n#\n# All output is formatted for readability using the functions of\n# `output.bash' and sent to the standard error.\n#\n\n# Fail and display the expression if it evaluates to false.\n#\n# NOTE: The expression must be a simple command. Compound commands, such\n#       as `[[', can be used only when executed with `bash -c'.\n#\n# Globals:\n#   none\n# Arguments:\n#   $1 - expression\n# Returns:\n#   0 - expression evaluates to TRUE\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\nassert() {\n  if ! \"$@\"; then\n    batslib_print_kv_single 10 'expression' \"$*\" \\\n      | batslib_decorate 'assertion failed' \\\n      | fail\n  fi\n}\n\n# Fail and display the expression if it evaluates to true.\n#\n# NOTE: The expression must be a simple command. Compound commands, such\n#       as `[[', can be used only when executed with `bash -c'.\n#\n# Globals:\n#   none\n# Arguments:\n#   $1 - expression\n# Returns:\n#   0 - expression evaluates to FALSE\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\nrefute() {\n  if \"$@\"; then\n    batslib_print_kv_single 10 'expression' \"$*\" \\\n      | batslib_decorate 'assertion succeeded, but it was expected to fail' \\\n      | fail\n  fi\n}\n\n# Fail and display details if the expected and actual values do not\n# equal. Details include both values.\n#\n# Globals:\n#   none\n# Arguments:\n#   $1 - actual value\n#   $2 - expected value\n# Returns:\n#   0 - values equal\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\nassert_equal() {\n  if [[ $1 != \"$2\" ]]; then\n    batslib_print_kv_single_or_multi 8 \\\n        'expected' \"$2\" \\\n        'actual'   \"$1\" \\\n      | batslib_decorate 'values do not equal' \\\n      | fail\n  fi\n}\n\n# Fail and display details if `$status' is not 0. Details include\n# `$status' and `$output'.\n#\n# Globals:\n#   status\n#   output\n# Arguments:\n#   none\n# Returns:\n#   0 - `$status' is 0\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\nassert_success() {\n  if (( status != 0 )); then\n    { local -ir width=6\n      batslib_print_kv_single \"$width\" 'status' \"$status\"\n      batslib_print_kv_single_or_multi \"$width\" 'output' \"$output\"\n    } | batslib_decorate 'command failed' \\\n      | fail\n  fi\n}\n\n# Fail and display details if `$status' is 0. Details include `$output'.\n#\n# Optionally, when the expected status is specified, fail when it does\n# not equal `$status'. In this case, details include the expected and\n# actual status, and `$output'.\n#\n# Globals:\n#   status\n#   output\n# Arguments:\n#   $1 - [opt] expected status\n# Returns:\n#   0 - `$status' is not 0, or\n#       `$status' equals the expected status\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\nassert_failure() {\n  (( $# > 0 )) && local -r expected=\"$1\"\n  if (( status == 0 )); then\n    batslib_print_kv_single_or_multi 6 'output' \"$output\" \\\n      | batslib_decorate 'command succeeded, but it was expected to fail' \\\n      | fail\n  elif (( $# > 0 )) && (( status != expected )); then\n    { local -ir width=8\n      batslib_print_kv_single \"$width\" \\\n          'expected' \"$expected\" \\\n          'actual'   \"$status\"\n      batslib_print_kv_single_or_multi \"$width\" \\\n          'output' \"$output\"\n    } | batslib_decorate 'command failed as expected, but status differs' \\\n      | fail\n  fi\n}\n\n# Fail and display details if `$output' does not match the expected\n# output. The expected output can be specified either by the first\n# parameter or on the standard input.\n#\n# By default, literal matching is performed. The assertion fails if the\n# expected output does not equal `$output'. Details include both values.\n#\n# Option `--partial' enables partial matching. The assertion fails if\n# the expected substring cannot be found in `$output'.\n#\n# Option `--regexp' enables regular expression matching. The assertion\n# fails if the extended regular expression does not match `$output'. An\n# invalid regular expression causes an error to be displayed.\n#\n# It is an error to use partial and regular expression matching\n# simultaneously.\n#\n# Globals:\n#   output\n# Options:\n#   -p, --partial - partial matching\n#   -e, --regexp - extended regular expression matching\n# Arguments:\n#   $1 - [=STDIN] expected output\n# Returns:\n#   0 - expected matches the actual output\n#   1 - otherwise\n# Inputs:\n#   STDIN - [=$1] expected output\n# Outputs:\n#   STDERR - details, on failure\n#            error message, on error\nassert_output() {\n  local -i is_mode_partial=0\n  local -i is_mode_regexp=0\n\n  # Handle options.\n  while (( $# > 0 )); do\n    case \"$1\" in\n      -p|--partial) is_mode_partial=1; shift ;;\n      -e|--regexp) is_mode_regexp=1; shift ;;\n      --) shift; break ;;\n      *) break ;;\n    esac\n  done\n\n  if (( is_mode_partial )) && (( is_mode_regexp )); then\n    echo \"\\`--partial' and \\`--regexp' are mutually exclusive\" \\\n      | batslib_decorate 'ERROR: assert_output' \\\n      | fail\n    return $?\n  fi\n\n  # Arguments.\n  local expected\n  (( $# == 0 )) && expected=\"$(cat -)\" || expected=\"$1\"\n\n  # Matching.\n  if (( is_mode_regexp )); then\n    if [[ '' =~ $expected ]] || (( $? == 2 )); then\n      echo \"Invalid extended regular expression: \\`$expected'\" \\\n        | batslib_decorate 'ERROR: assert_output' \\\n        | fail\n      return $?\n    fi\n    if ! [[ $output =~ $expected ]]; then\n      batslib_print_kv_single_or_multi 6 \\\n          'regexp'  \"$expected\" \\\n          'output' \"$output\" \\\n        | batslib_decorate 'regular expression does not match output' \\\n        | fail\n    fi\n  elif (( is_mode_partial )); then\n    if [[ $output != *\"$expected\"* ]]; then\n      batslib_print_kv_single_or_multi 9 \\\n          'substring' \"$expected\" \\\n          'output'    \"$output\" \\\n        | batslib_decorate 'output does not contain substring' \\\n        | fail\n    fi\n  else\n    if [[ $output != \"$expected\" ]]; then\n      batslib_print_kv_single_or_multi 8 \\\n          'expected' \"$expected\" \\\n          'actual'   \"$output\" \\\n        | batslib_decorate 'output differs' \\\n        | fail\n    fi\n  fi\n}\n\n# Fail and display details if `$output' matches the unexpected output.\n# The unexpected output can be specified either by the first parameter\n# or on the standard input.\n#\n# By default, literal matching is performed. The assertion fails if the\n# unexpected output equals `$output'. Details include `$output'.\n#\n# Option `--partial' enables partial matching. The assertion fails if\n# the unexpected substring is found in `$output'. The unexpected\n# substring is added to details.\n#\n# Option `--regexp' enables regular expression matching. The assertion\n# fails if the extended regular expression does matches `$output'. The\n# regular expression is added to details. An invalid regular expression\n# causes an error to be displayed.\n#\n# It is an error to use partial and regular expression matching\n# simultaneously.\n#\n# Globals:\n#   output\n# Options:\n#   -p, --partial - partial matching\n#   -e, --regexp - extended regular expression matching\n# Arguments:\n#   $1 - [=STDIN] unexpected output\n# Returns:\n#   0 - unexpected matches the actual output\n#   1 - otherwise\n# Inputs:\n#   STDIN - [=$1] unexpected output\n# Outputs:\n#   STDERR - details, on failure\n#            error message, on error\nrefute_output() {\n  local -i is_mode_partial=0\n  local -i is_mode_regexp=0\n\n  # Handle options.\n  while (( $# > 0 )); do\n    case \"$1\" in\n      -p|--partial) is_mode_partial=1; shift ;;\n      -e|--regexp) is_mode_regexp=1; shift ;;\n      --) shift; break ;;\n      *) break ;;\n    esac\n  done\n\n  if (( is_mode_partial )) && (( is_mode_regexp )); then\n    echo \"\\`--partial' and \\`--regexp' are mutually exclusive\" \\\n      | batslib_decorate 'ERROR: refute_output' \\\n      | fail\n    return $?\n  fi\n\n  # Arguments.\n  local unexpected\n  (( $# == 0 )) && unexpected=\"$(cat -)\" || unexpected=\"$1\"\n\n  if (( is_mode_regexp == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then\n    echo \"Invalid extended regular expression: \\`$unexpected'\" \\\n      | batslib_decorate 'ERROR: refute_output' \\\n      | fail\n    return $?\n  fi\n\n  # Matching.\n  if (( is_mode_regexp )); then\n    if [[ $output =~ $unexpected ]] || (( $? == 0 )); then\n      batslib_print_kv_single_or_multi 6 \\\n          'regexp'  \"$unexpected\" \\\n          'output' \"$output\" \\\n        | batslib_decorate 'regular expression should not match output' \\\n        | fail\n    fi\n  elif (( is_mode_partial )); then\n    if [[ $output == *\"$unexpected\"* ]]; then\n      batslib_print_kv_single_or_multi 9 \\\n          'substring' \"$unexpected\" \\\n          'output'    \"$output\" \\\n        | batslib_decorate 'output should not contain substring' \\\n        | fail\n    fi\n  else\n    if [[ $output == \"$unexpected\" ]]; then\n      batslib_print_kv_single_or_multi 6 \\\n          'output' \"$output\" \\\n        | batslib_decorate 'output equals, but it was expected to differ' \\\n        | fail\n    fi\n  fi\n}\n\n# Fail and display details if the expected line is not found in the\n# output (default) or in a specific line of it.\n#\n# By default, the entire output is searched for the expected line. The\n# expected line is matched against every element of `${lines[@]}'. If no\n# match is found, the assertion fails. Details include the expected line\n# and `${lines[@]}'.\n#\n# When `--index <idx>' is specified, only the <idx>-th line is matched.\n# If the expected line does not match `${lines[<idx>]}', the assertion\n# fails. Details include <idx> and the compared lines.\n#\n# By default, literal matching is performed. A literal match fails if\n# the expected string does not equal the matched string.\n#\n# Option `--partial' enables partial matching. A partial match fails if\n# the expected substring is not found in the target string.\n#\n# Option `--regexp' enables regular expression matching. A regular\n# expression match fails if the extended regular expression does not\n# match the target string. An invalid regular expression causes an error\n# to be displayed.\n#\n# It is an error to use partial and regular expression matching\n# simultaneously.\n#\n# Mandatory arguments to long options are mandatory for short options\n# too.\n#\n# Globals:\n#   output\n#   lines\n# Options:\n#   -n, --index <idx> - match the <idx>-th line\n#   -p, --partial - partial matching\n#   -e, --regexp - extended regular expression matching\n# Arguments:\n#   $1 - expected line\n# Returns:\n#   0 - match found\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\n#            error message, on error\n# FIXME(ztombol): Display `${lines[@]}' instead of `$output'!\nassert_line() {\n  local -i is_match_line=0\n  local -i is_mode_partial=0\n  local -i is_mode_regexp=0\n\n  # Handle options.\n  while (( $# > 0 )); do\n    case \"$1\" in\n      -n|--index)\n        if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then\n          echo \"\\`--index' requires an integer argument: \\`$2'\" \\\n            | batslib_decorate 'ERROR: assert_line' \\\n            | fail\n          return $?\n        fi\n        is_match_line=1\n        local -ri idx=\"$2\"\n        shift 2\n        ;;\n      -p|--partial) is_mode_partial=1; shift ;;\n      -e|--regexp) is_mode_regexp=1; shift ;;\n      --) shift; break ;;\n      *) break ;;\n    esac\n  done\n\n  if (( is_mode_partial )) && (( is_mode_regexp )); then\n    echo \"\\`--partial' and \\`--regexp' are mutually exclusive\" \\\n      | batslib_decorate 'ERROR: assert_line' \\\n      | fail\n    return $?\n  fi\n\n  # Arguments.\n  local -r expected=\"$1\"\n\n  if (( is_mode_regexp == 1 )) && [[ '' =~ $expected ]] || (( $? == 2 )); then\n    echo \"Invalid extended regular expression: \\`$expected'\" \\\n      | batslib_decorate 'ERROR: assert_line' \\\n      | fail\n    return $?\n  fi\n\n  # Matching.\n  if (( is_match_line )); then\n    # Specific line.\n    if (( is_mode_regexp )); then\n      if ! [[ ${lines[$idx]} =~ $expected ]]; then\n        batslib_print_kv_single 6 \\\n            'index' \"$idx\" \\\n            'regexp' \"$expected\" \\\n            'line'  \"${lines[$idx]}\" \\\n          | batslib_decorate 'regular expression does not match line' \\\n          | fail\n      fi\n    elif (( is_mode_partial )); then\n      if [[ ${lines[$idx]} != *\"$expected\"* ]]; then\n        batslib_print_kv_single 9 \\\n            'index'     \"$idx\" \\\n            'substring' \"$expected\" \\\n            'line'      \"${lines[$idx]}\" \\\n          | batslib_decorate 'line does not contain substring' \\\n          | fail\n      fi\n    else\n      if [[ ${lines[$idx]} != \"$expected\" ]]; then\n        batslib_print_kv_single 8 \\\n            'index'    \"$idx\" \\\n            'expected' \"$expected\" \\\n            'actual'   \"${lines[$idx]}\" \\\n          | batslib_decorate 'line differs' \\\n          | fail\n      fi\n    fi\n  else\n    # Contained in output.\n    if (( is_mode_regexp )); then\n      local -i idx\n      for (( idx = 0; idx < ${#lines[@]}; ++idx )); do\n        [[ ${lines[$idx]} =~ $expected ]] && return 0\n      done\n      { local -ar single=(\n          'regexp'  \"$expected\"\n        )\n        local -ar may_be_multi=(\n          'output' \"$output\"\n        )\n        local -ir width=\"$( batslib_get_max_single_line_key_width \\\n                              \"${single[@]}\" \"${may_be_multi[@]}\" )\"\n        batslib_print_kv_single \"$width\" \"${single[@]}\"\n        batslib_print_kv_single_or_multi \"$width\" \"${may_be_multi[@]}\"\n      } | batslib_decorate 'no output line matches regular expression' \\\n        | fail\n    elif (( is_mode_partial )); then\n      local -i idx\n      for (( idx = 0; idx < ${#lines[@]}; ++idx )); do\n        [[ ${lines[$idx]} == *\"$expected\"* ]] && return 0\n      done\n      { local -ar single=(\n          'substring' \"$expected\"\n        )\n        local -ar may_be_multi=(\n          'output'    \"$output\"\n        )\n        local -ir width=\"$( batslib_get_max_single_line_key_width \\\n                              \"${single[@]}\" \"${may_be_multi[@]}\" )\"\n        batslib_print_kv_single \"$width\" \"${single[@]}\"\n        batslib_print_kv_single_or_multi \"$width\" \"${may_be_multi[@]}\"\n      } | batslib_decorate 'no output line contains substring' \\\n        | fail\n    else\n      local -i idx\n      for (( idx = 0; idx < ${#lines[@]}; ++idx )); do\n        [[ ${lines[$idx]} == \"$expected\" ]] && return 0\n      done\n      { local -ar single=(\n          'line'   \"$expected\"\n        )\n        local -ar may_be_multi=(\n          'output' \"$output\"\n        )\n        local -ir width=\"$( batslib_get_max_single_line_key_width \\\n                            \"${single[@]}\" \"${may_be_multi[@]}\" )\"\n        batslib_print_kv_single \"$width\" \"${single[@]}\"\n        batslib_print_kv_single_or_multi \"$width\" \"${may_be_multi[@]}\"\n      } | batslib_decorate 'output does not contain line' \\\n        | fail\n    fi\n  fi\n}\n\n# Fail and display details if the unexpected line is found in the output\n# (default) or in a specific line of it.\n#\n# By default, the entire output is searched for the unexpected line. The\n# unexpected line is matched against every element of `${lines[@]}'. If\n# a match is found, the assertion fails. Details include the unexpected\n# line, the index of the first match and `${lines[@]}' with the matching\n# line highlighted if `${lines[@]}' is longer than one line.\n#\n# When `--index <idx>' is specified, only the <idx>-th line is matched.\n# If the unexpected line matches `${lines[<idx>]}', the assertion fails.\n# Details include <idx> and the unexpected line.\n#\n# By default, literal matching is performed. A literal match fails if\n# the unexpected string does not equal the matched string.\n#\n# Option `--partial' enables partial matching. A partial match fails if\n# the unexpected substring is found in the target string. When used with\n# `--index <idx>', the unexpected substring is also displayed on\n# failure.\n#\n# Option `--regexp' enables regular expression matching. A regular\n# expression match fails if the extended regular expression matches the\n# target string. When used with `--index <idx>', the regular expression\n# is also displayed on failure. An invalid regular expression causes an\n# error to be displayed.\n#\n# It is an error to use partial and regular expression matching\n# simultaneously.\n#\n# Mandatory arguments to long options are mandatory for short options\n# too.\n#\n# Globals:\n#   output\n#   lines\n# Options:\n#   -n, --index <idx> - match the <idx>-th line\n#   -p, --partial - partial matching\n#   -e, --regexp - extended regular expression matching\n# Arguments:\n#   $1 - unexpected line\n# Returns:\n#   0 - match not found\n#   1 - otherwise\n# Outputs:\n#   STDERR - details, on failure\n#            error message, on error\n# FIXME(ztombol): Display `${lines[@]}' instead of `$output'!\nrefute_line() {\n  local -i is_match_line=0\n  local -i is_mode_partial=0\n  local -i is_mode_regexp=0\n\n  # Handle options.\n  while (( $# > 0 )); do\n    case \"$1\" in\n      -n|--index)\n        if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then\n          echo \"\\`--index' requires an integer argument: \\`$2'\" \\\n            | batslib_decorate 'ERROR: refute_line' \\\n            | fail\n          return $?\n        fi\n        is_match_line=1\n        local -ri idx=\"$2\"\n        shift 2\n        ;;\n      -p|--partial) is_mode_partial=1; shift ;;\n      -e|--regexp) is_mode_regexp=1; shift ;;\n      --) shift; break ;;\n      *) break ;;\n    esac\n  done\n\n  if (( is_mode_partial )) && (( is_mode_regexp )); then\n    echo \"\\`--partial' and \\`--regexp' are mutually exclusive\" \\\n      | batslib_decorate 'ERROR: refute_line' \\\n      | fail\n    return $?\n  fi\n\n  # Arguments.\n  local -r unexpected=\"$1\"\n\n  if (( is_mode_regexp == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then\n    echo \"Invalid extended regular expression: \\`$unexpected'\" \\\n      | batslib_decorate 'ERROR: refute_line' \\\n      | fail\n    return $?\n  fi\n\n  # Matching.\n  if (( is_match_line )); then\n    # Specific line.\n    if (( is_mode_regexp )); then\n      if [[ ${lines[$idx]} =~ $unexpected ]] || (( $? == 0 )); then\n        batslib_print_kv_single 6 \\\n            'index' \"$idx\" \\\n            'regexp' \"$unexpected\" \\\n            'line'  \"${lines[$idx]}\" \\\n          | batslib_decorate 'regular expression should not match line' \\\n          | fail\n      fi\n    elif (( is_mode_partial )); then\n      if [[ ${lines[$idx]} == *\"$unexpected\"* ]]; then\n        batslib_print_kv_single 9 \\\n            'index'     \"$idx\" \\\n            'substring' \"$unexpected\" \\\n            'line'      \"${lines[$idx]}\" \\\n          | batslib_decorate 'line should not contain substring' \\\n          | fail\n      fi\n    else\n      if [[ ${lines[$idx]} == \"$unexpected\" ]]; then\n        batslib_print_kv_single 5 \\\n            'index' \"$idx\" \\\n            'line'  \"${lines[$idx]}\" \\\n          | batslib_decorate 'line should differ' \\\n          | fail\n      fi\n    fi\n  else\n    # Line contained in output.\n    if (( is_mode_regexp )); then\n      local -i idx\n      for (( idx = 0; idx < ${#lines[@]}; ++idx )); do\n        if [[ ${lines[$idx]} =~ $unexpected ]]; then\n          { local -ar single=(\n              'regexp'  \"$unexpected\"\n              'index'  \"$idx\"\n            )\n            local -a may_be_multi=(\n              'output' \"$output\"\n            )\n            local -ir width=\"$( batslib_get_max_single_line_key_width \\\n                                \"${single[@]}\" \"${may_be_multi[@]}\" )\"\n            batslib_print_kv_single \"$width\" \"${single[@]}\"\n            if batslib_is_single_line \"${may_be_multi[1]}\"; then\n              batslib_print_kv_single \"$width\" \"${may_be_multi[@]}\"\n            else\n              may_be_multi[1]=\"$( printf '%s' \"${may_be_multi[1]}\" \\\n                                    | batslib_prefix \\\n                                    | batslib_mark '>' \"$idx\" )\"\n              batslib_print_kv_multi \"${may_be_multi[@]}\"\n            fi\n          } | batslib_decorate 'no line should match the regular expression' \\\n            | fail\n          return $?\n        fi\n      done\n    elif (( is_mode_partial )); then\n      local -i idx\n      for (( idx = 0; idx < ${#lines[@]}; ++idx )); do\n        if [[ ${lines[$idx]} == *\"$unexpected\"* ]]; then\n          { local -ar single=(\n              'substring' \"$unexpected\"\n              'index'     \"$idx\"\n            )\n            local -a may_be_multi=(\n              'output'    \"$output\"\n            )\n            local -ir width=\"$( batslib_get_max_single_line_key_width \\\n                                \"${single[@]}\" \"${may_be_multi[@]}\" )\"\n            batslib_print_kv_single \"$width\" \"${single[@]}\"\n            if batslib_is_single_line \"${may_be_multi[1]}\"; then\n              batslib_print_kv_single \"$width\" \"${may_be_multi[@]}\"\n            else\n              may_be_multi[1]=\"$( printf '%s' \"${may_be_multi[1]}\" \\\n                                    | batslib_prefix \\\n                                    | batslib_mark '>' \"$idx\" )\"\n              batslib_print_kv_multi \"${may_be_multi[@]}\"\n            fi\n          } | batslib_decorate 'no line should contain substring' \\\n            | fail\n          return $?\n        fi\n      done\n    else\n      local -i idx\n      for (( idx = 0; idx < ${#lines[@]}; ++idx )); do\n        if [[ ${lines[$idx]} == \"$unexpected\" ]]; then\n          { local -ar single=(\n              'line'   \"$unexpected\"\n              'index'  \"$idx\"\n            )\n            local -a may_be_multi=(\n              'output' \"$output\"\n            )\n            local -ir width=\"$( batslib_get_max_single_line_key_width \\\n                                \"${single[@]}\" \"${may_be_multi[@]}\" )\"\n            batslib_print_kv_single \"$width\" \"${single[@]}\"\n            if batslib_is_single_line \"${may_be_multi[1]}\"; then\n              batslib_print_kv_single \"$width\" \"${may_be_multi[@]}\"\n            else\n              may_be_multi[1]=\"$( printf '%s' \"${may_be_multi[1]}\" \\\n                                    | batslib_prefix \\\n                                    | batslib_mark '>' \"$idx\" )\"\n              batslib_print_kv_multi \"${may_be_multi[@]}\"\n            fi\n          } | batslib_decorate 'line should not be in output' \\\n            | fail\n          return $?\n        fi\n      done\n    fi\n  fi\n}\n"
  },
  {
    "path": "test/50-assert-11-assert.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n@test 'assert() <expression>: returns 0 if <expression> evaluates to TRUE' {\n  run assert true\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert() <expression>: returns 1 and displays <expression> if it evaluates to FALSE' {\n  run assert false\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- assertion failed --' ]\n  [ \"${lines[1]}\" == 'expression : false' ]\n  [ \"${lines[2]}\" == '--' ]\n}\n"
  },
  {
    "path": "test/50-assert-12-assert_equal.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n@test 'assert_equal() <actual> <expected>: returns 0 if <actual> equals <expected>' {\n  run assert_equal 'a' 'a'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_equal() <actual> <expected>: returns 1 and displays details if <actual> does not equal <expected>' {\n  run assert_equal 'a' 'b'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- values do not equal --' ]\n  [ \"${lines[1]}\" == 'expected : b' ]\n  [ \"${lines[2]}\" == 'actual   : a' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n@test 'assert_equal() <actual> <expected>: displays details in multi-line format if <actual> is longer than one line' {\n  run assert_equal $'a 0\\na 1' 'b'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- values do not equal --' ]\n  [ \"${lines[1]}\" == 'expected (1 lines):' ]\n  [ \"${lines[2]}\" == '  b' ]\n  [ \"${lines[3]}\" == 'actual (2 lines):' ]\n  [ \"${lines[4]}\" == '  a 0' ]\n  [ \"${lines[5]}\" == '  a 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n@test 'assert_equal() <actual> <expected>: displays details in multi-line format if <expected> is longer than one line' {\n  run assert_equal 'a' $'b 0\\nb 1'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- values do not equal --' ]\n  [ \"${lines[1]}\" == 'expected (2 lines):' ]\n  [ \"${lines[2]}\" == '  b 0' ]\n  [ \"${lines[3]}\" == '  b 1' ]\n  [ \"${lines[4]}\" == 'actual (1 lines):' ]\n  [ \"${lines[5]}\" == '  a' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n@test 'assert_equal() <actual> <expected>: performs literal matching' {\n  run assert_equal 'a' '*'\n  [ \"$status\" -eq 1 ]\n}\n"
  },
  {
    "path": "test/50-assert-13-assert_success.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n@test \"assert_success(): returns 0 if \\`\\$status' is 0\" {\n  run true\n  run assert_success\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_success(): returns 1 and displays details if \\`\\$status' is not 0\" {\n  run bash -c 'echo \"a\"\n               exit 1'\n  run assert_success\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- command failed --' ]\n  [ \"${lines[1]}\" == 'status : 1' ]\n  [ \"${lines[2]}\" == 'output : a' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n@test \"assert_success(): displays \\`\\$output' in multi-line format if it is longer than one line\" {\n  run bash -c 'printf \"a 0\\na 1\"\n               exit 1'\n  run assert_success\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 6 ]\n  [ \"${lines[0]}\" == '-- command failed --' ]\n  [ \"${lines[1]}\" == 'status : 1' ]\n  [ \"${lines[2]}\" == 'output (2 lines):' ]\n  [ \"${lines[3]}\" == '  a 0' ]\n  [ \"${lines[4]}\" == '  a 1' ]\n  [ \"${lines[5]}\" == '--' ]\n}\n"
  },
  {
    "path": "test/50-assert-14-assert_failure.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n@test \"assert_failure(): returns 0 if \\`\\$status' is not 0\" {\n  run false\n  run assert_failure\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_failure(): returns 1 and displays details if \\`\\$status' is 0\" {\n  run bash -c 'echo \"a\"\n               exit 0'\n  run assert_failure\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- command succeeded, but it was expected to fail --' ]\n  [ \"${lines[1]}\" == 'output : a' ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test \"assert_failure(): displays \\`\\$output' in multi-line format if it is longer then one line\" {\n  run bash -c 'printf \"a 0\\na 1\"\n               exit 0'\n  run assert_failure\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- command succeeded, but it was expected to fail --' ]\n  [ \"${lines[1]}\" == 'output (2 lines):' ]\n  [ \"${lines[2]}\" == '  a 0' ]\n  [ \"${lines[3]}\" == '  a 1' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n@test \"assert_failure() <status>: returns 0 if \\`\\$status' equals <status>\" {\n  run bash -c 'exit 1'\n  run assert_failure 1\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_failure() <status>: returns 1 and displays details if \\`\\$status' does not equal <status>\" {\n  run bash -c 'echo \"a\"\n               exit 1'\n  run assert_failure 2\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- command failed as expected, but status differs --' ]\n  [ \"${lines[1]}\" == 'expected : 2' ]\n  [ \"${lines[2]}\" == 'actual   : 1' ]\n  [ \"${lines[3]}\" == 'output   : a' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n@test \"assert_failure() <status>: displays \\`\\$output' in multi-line format if it is longer then one line\" {\n  run bash -c 'printf \"a 0\\na 1\"\n               exit 1'\n  run assert_failure 2\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- command failed as expected, but status differs --' ]\n  [ \"${lines[1]}\" == 'expected : 2' ]\n  [ \"${lines[2]}\" == 'actual   : 1' ]\n  [ \"${lines[3]}\" == 'output (2 lines):' ]\n  [ \"${lines[4]}\" == '  a 0' ]\n  [ \"${lines[5]}\" == '  a 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n"
  },
  {
    "path": "test/50-assert-15-assert_output.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n\n#\n# Literal matching\n#\n\n# Correctness\n@test \"assert_output() <expected>: returns 0 if <expected> equals \\`\\$output'\" {\n  run echo 'a'\n  run assert_output 'a'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_output() <expected>: returns 1 and displays details if <expected> does not equal \\`\\$output'\" {\n  run echo 'b'\n  run assert_output 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- output differs --' ]\n  [ \"${lines[1]}\" == 'expected : a' ]\n  [ \"${lines[2]}\" == 'actual   : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n@test 'assert_output(): reads <expected> from STDIN' {\n  run echo 'a'\n  run assert_output <<STDIN\na\nSTDIN\necho \"$output\"\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n# Output formatting\n@test \"assert_output() <expected>: displays details in multi-line format if \\`\\$output' is longer than one line\" {\n  run printf 'b 0\\nb 1'\n  run assert_output 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- output differs --' ]\n  [ \"${lines[1]}\" == 'expected (1 lines):' ]\n  [ \"${lines[2]}\" == '  a' ]\n  [ \"${lines[3]}\" == 'actual (2 lines):' ]\n  [ \"${lines[4]}\" == '  b 0' ]\n  [ \"${lines[5]}\" == '  b 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n@test 'assert_output() <expected>: displays details in multi-line format if <expected> is longer than one line' {\n  run echo 'b'\n  run assert_output $'a 0\\na 1'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- output differs --' ]\n  [ \"${lines[1]}\" == 'expected (2 lines):' ]\n  [ \"${lines[2]}\" == '  a 0' ]\n  [ \"${lines[3]}\" == '  a 1' ]\n  [ \"${lines[4]}\" == 'actual (1 lines):' ]\n  [ \"${lines[5]}\" == '  b' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n# Options\n@test 'assert_output() <expected>: performs literal matching by default' {\n  run echo 'a'\n  run assert_output '*'\n  [ \"$status\" -eq 1 ]\n}\n\n\n#\n# Partial matching: `-p' and `--partial'\n#\n\n# Options\ntest_p_partial () {\n  run echo 'abc'\n  run assert_output \"$1\" 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_output() -p <partial>: enables partial matching' {\n  test_p_partial -p\n}\n\n@test 'assert_output() --partial <partial>: enables partial matching' {\n  test_p_partial --partial\n}\n\n# Correctness\n@test \"assert_output() --partial <partial>: returns 0 if <partial> is a substring in \\`\\$output'\" {\n  run printf 'a\\nb\\nc'\n  run assert_output --partial 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_output() --partial <partial>: returns 1 and displays details if <partial> is not a substring in \\`\\$output'\" {\n  run echo 'b'\n  run assert_output --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- output does not contain substring --' ]\n  [ \"${lines[1]}\" == 'substring : a' ]\n  [ \"${lines[2]}\" == 'output    : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test \"assert_output() --partial <partial>: displays details in multi-line format if \\`\\$output' is longer than one line\" {\n  run printf 'b 0\\nb 1'\n  run assert_output --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- output does not contain substring --' ]\n  [ \"${lines[1]}\" == 'substring (1 lines):' ]\n  [ \"${lines[2]}\" == '  a' ]\n  [ \"${lines[3]}\" == 'output (2 lines):' ]\n  [ \"${lines[4]}\" == '  b 0' ]\n  [ \"${lines[5]}\" == '  b 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n@test 'assert_output() --partial <partial>: displays details in multi-line format if <partial> is longer than one line' {\n  run echo 'b'\n  run assert_output --partial $'a 0\\na 1'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- output does not contain substring --' ]\n  [ \"${lines[1]}\" == 'substring (2 lines):' ]\n  [ \"${lines[2]}\" == '  a 0' ]\n  [ \"${lines[3]}\" == '  a 1' ]\n  [ \"${lines[4]}\" == 'output (1 lines):' ]\n  [ \"${lines[5]}\" == '  b' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n\n#\n# Regular expression matching: `-e' and `--regexp'\n#\n\n# Options\ntest_r_regexp () {\n  run echo 'abc'\n  run assert_output \"$1\" '^a'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_output() -e <regexp>: enables regular expression matching' {\n  test_r_regexp -e\n}\n\n@test 'assert_output() --regexp <regexp>: enables regular expression matching' {\n  test_r_regexp --regexp\n}\n\n# Correctness\n@test \"assert_output() --regexp <regexp>: returns 0 if <regexp> matches \\`\\$output'\" {\n  run printf 'a\\nb\\nc'\n  run assert_output --regexp '.*b.*'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_output() --regexp <regexp>: returns 1 and displays details if <regexp> does not match \\`\\$output'\" {\n  run echo 'b'\n  run assert_output --regexp '.*a.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- regular expression does not match output --' ]\n  [ \"${lines[1]}\" == 'regexp : .*a.*' ]\n  [ \"${lines[2]}\" == 'output : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test \"assert_output() --regexp <regexp>: displays details in multi-line format if \\`\\$output' is longer than one line\" {\n  run printf 'b 0\\nb 1'\n  run assert_output --regexp '.*a.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- regular expression does not match output --' ]\n  [ \"${lines[1]}\" == 'regexp (1 lines):' ]\n  [ \"${lines[2]}\" == '  .*a.*' ]\n  [ \"${lines[3]}\" == 'output (2 lines):' ]\n  [ \"${lines[4]}\" == '  b 0' ]\n  [ \"${lines[5]}\" == '  b 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n@test 'assert_output() --regexp <regexp>: displays details in multi-line format if <regexp> is longer than one line' {\n  run echo 'b'\n  run assert_output --regexp $'.*a\\nb.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- regular expression does not match output --' ]\n  [ \"${lines[1]}\" == 'regexp (2 lines):' ]\n  [ \"${lines[2]}\" == '  .*a' ]\n  [ \"${lines[3]}\" == '  b.*' ]\n  [ \"${lines[4]}\" == 'output (1 lines):' ]\n  [ \"${lines[5]}\" == '  b' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n# Error handling\n@test 'assert_output() --regexp <regexp>: returns 1 and displays an error message if <regexp> is not a valid extended regular expression' {\n  run assert_output --regexp '[.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: assert_output --' ]\n  [ \"${lines[1]}\" == \"Invalid extended regular expression: \\`[.*'\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n\n#\n# Common\n#\n\n@test \"assert_output(): \\`--partial' and \\`--regexp' are mutually exclusive\" {\n  run assert_output --partial --regexp\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: assert_output --' ]\n  [ \"${lines[1]}\" == \"\\`--partial' and \\`--regexp' are mutually exclusive\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test \"assert_output(): \\`--' stops parsing options\" {\n  run echo '-p'\n  run assert_output -- '-p'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n"
  },
  {
    "path": "test/50-assert-16-refute_output.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n\n#\n# Literal matching\n#\n\n# Correctness\n@test \"refute_output() <unexpected>: returns 0 if <unexpected> does not equal \\`\\$output'\" {\n  run echo 'b'\n  run refute_output 'a'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_output() <unexpected>: returns 1 and displays details if <unexpected> equals \\`\\$output'\" {\n  run echo 'a'\n  run refute_output 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- output equals, but it was expected to differ --' ]\n  [ \"${lines[1]}\" == 'output : a' ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test 'refute_output(): reads <unexpected> from STDIN' {\n  run echo 'a'\n  run refute_output <<INPUT\nb\nINPUT\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n# Output formatting\n@test 'refute_output() <unexpected>: displays details in multi-line format if necessary' {\n  run printf 'a 0\\na 1'\n  run refute_output $'a 0\\na 1'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- output equals, but it was expected to differ --' ]\n  [ \"${lines[1]}\" == 'output (2 lines):' ]\n  [ \"${lines[2]}\" == '  a 0' ]\n  [ \"${lines[3]}\" == '  a 1' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n# Options\n@test 'refute_output() <unexpected>: performs literal matching by default' {\n  run echo 'a'\n  run refute_output '*'\n  [ \"$status\" -eq 0 ]\n}\n\n\n#\n# Partial matching: `-p' and `--partial'\n#\n\n# Options\ntest_p_partial () {\n  run echo 'abc'\n  run refute_output \"$1\" 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_output() -p <partial>: enables partial matching' {\n  test_p_partial -p\n}\n\n@test 'refute_output() --partial <partial>: enables partial matching' {\n  test_p_partial --partial\n}\n\n# Correctness\n@test \"refute_output() --partial <partial>: returns 0 if <partial> is not a substring in \\`\\$output'\" {\n  run printf 'a\\nb\\nc'\n  run refute_output --partial 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_output() --partial <partial>: returns 1 and displays details if <partial> is a substring in \\`\\$output'\" {\n  run echo 'a'\n  run refute_output --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- output should not contain substring --' ]\n  [ \"${lines[1]}\" == 'substring : a' ]\n  [ \"${lines[2]}\" == 'output    : a' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test 'refute_output() --partial <partial>: displays details in multi-line format if necessary' {\n  run printf 'a 0\\na 1'\n  run refute_output --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- output should not contain substring --' ]\n  [ \"${lines[1]}\" == 'substring (1 lines):' ]\n  [ \"${lines[2]}\" == '  a' ]\n  [ \"${lines[3]}\" == 'output (2 lines):' ]\n  [ \"${lines[4]}\" == '  a 0' ]\n  [ \"${lines[5]}\" == '  a 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n\n#\n# Regular expression matching: `-e' and `--regexp'\n#\n\n# Options\ntest_r_regexp () {\n  run echo 'abc'\n  run refute_output \"$1\" '^d'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_output() -e <regexp>: enables regular expression matching' {\n  test_r_regexp -e\n}\n\n@test 'refute_output() --regexp <regexp>: enables regular expression matching' {\n  test_r_regexp --regexp\n}\n\n# Correctness\n@test \"refute_output() --regexp <regexp>: returns 0 if <regexp> does not match \\`\\$output'\" {\n  run printf 'a\\nb\\nc'\n  run refute_output --regexp '.*d.*'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_output() --regexp <regexp>: returns 1 and displays details if <regexp> matches \\`\\$output'\" {\n  run echo 'a'\n  run refute_output --regexp '.*a.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- regular expression should not match output --' ]\n  [ \"${lines[1]}\" == 'regexp : .*a.*' ]\n  [ \"${lines[2]}\" == 'output : a' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test 'refute_output() --regexp <regexp>: displays details in multi-line format if necessary' {\n  run printf 'a 0\\na 1'\n  run refute_output --regexp '.*a.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 7 ]\n  [ \"${lines[0]}\" == '-- regular expression should not match output --' ]\n  [ \"${lines[1]}\" == 'regexp (1 lines):' ]\n  [ \"${lines[2]}\" == '  .*a.*' ]\n  [ \"${lines[3]}\" == 'output (2 lines):' ]\n  [ \"${lines[4]}\" == '  a 0' ]\n  [ \"${lines[5]}\" == '  a 1' ]\n  [ \"${lines[6]}\" == '--' ]\n}\n\n# Error handling\n@test 'refute_output() --regexp <regexp>: returns 1 and displays an error message if <regexp> is not a valid extended regular expression' {\n  run refute_output --regexp '[.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: refute_output --' ]\n  [ \"${lines[1]}\" == \"Invalid extended regular expression: \\`[.*'\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n\n#\n# Common\n#\n\n@test \"refute_output(): \\`--partial' and \\`--regexp' are mutually exclusive\" {\n  run refute_output --partial --regexp\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: refute_output --' ]\n  [ \"${lines[1]}\" == \"\\`--partial' and \\`--regexp' are mutually exclusive\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test \"refute_output(): \\`--' stops parsing options\" {\n  run echo '--'\n  run refute_output -- '-p'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n"
  },
  {
    "path": "test/50-assert-17-assert_line.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n\n###############################################################################\n# Containing a line\n###############################################################################\n\n#\n# Literal matching\n#\n\n# Correctness\n@test \"assert_line() <expected>: returns 0 if <expected> is a line in \\`\\${lines[@]}'\" {\n  run printf 'a\\nb\\nc'\n  run assert_line 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_line() <expected>: returns 1 and displays details if <expected> is not a line in \\`\\${lines[@]}'\" {\n  run echo 'b'\n  run assert_line 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- output does not contain line --' ]\n  [ \"${lines[1]}\" == 'line   : a' ]\n  [ \"${lines[2]}\" == 'output : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test \"assert_line() <expected>: displays \\`\\$output' in multi-line format if it is longer than one line\" {\n  run printf 'b 0\\nb 1'\n  run assert_line 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 6 ]\n  [ \"${lines[0]}\" == '-- output does not contain line --' ]\n  [ \"${lines[1]}\" == 'line : a' ]\n  [ \"${lines[2]}\" == 'output (2 lines):' ]\n  [ \"${lines[3]}\" == '  b 0' ]\n  [ \"${lines[4]}\" == '  b 1' ]\n  [ \"${lines[5]}\" == '--' ]\n}\n\n# Options\n@test 'assert_line() <expected>: performs literal matching by default' {\n  run echo 'a'\n  run assert_line '*'\n  [ \"$status\" -eq 1 ]\n}\n\n\n#\n# Partial matching: `-p' and `--partial'\n#\n\n# Options\ntest_p_partial () {\n  run printf 'a\\n_b_\\nc'\n  run assert_line \"$1\" 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_line() -p <partial>: enables partial matching' {\n  test_p_partial -p\n}\n\n@test 'assert_line() --partial <partial>: enables partial matching' {\n  test_p_partial --partial\n}\n\n# Correctness\n@test \"assert_line() --partial <partial>: returns 0 if <partial> is a substring in any line in \\`\\${lines[@]}'\" {\n  run printf 'a\\n_b_\\nc'\n  run assert_line --partial 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_line() --partial <partial>: returns 1 and displays details if <partial> is not a substring in any lines in \\`\\${lines[@]}'\" {\n  run echo 'b'\n  run assert_line --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- no output line contains substring --' ]\n  [ \"${lines[1]}\" == 'substring : a' ]\n  [ \"${lines[2]}\" == 'output    : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test \"assert_line() --partial <partial>: displays \\`\\$output' in multi-line format if it is longer than one line\" {\n  run printf 'b 0\\nb 1'\n  run assert_line --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 6 ]\n  [ \"${lines[0]}\" == '-- no output line contains substring --' ]\n  [ \"${lines[1]}\" == 'substring : a' ]\n  [ \"${lines[2]}\" == 'output (2 lines):' ]\n  [ \"${lines[3]}\" == '  b 0' ]\n  [ \"${lines[4]}\" == '  b 1' ]\n  [ \"${lines[5]}\" == '--' ]\n}\n\n\n#\n# Regular expression matching: `-e' and `--regexp'\n#\n\n# Options\ntest_r_regexp () {\n  run printf 'a\\n_b_\\nc'\n  run assert_line \"$1\" '^.b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_line() -e <regexp>: enables regular expression matching' {\n  test_r_regexp -e\n}\n\n@test 'assert_line() --regexp <regexp>: enables regular expression matching' {\n  test_r_regexp --regexp\n}\n\n# Correctness\n@test \"assert_line() --regexp <regexp>: returns 0 if <regexp> matches any line in \\`\\${lines[@]}'\" {\n  run printf 'a\\n_b_\\nc'\n  run assert_line --regexp '^.b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_line() --regexp <regexp>: returns 1 and displays details if <regexp> does not match any lines in \\`\\${lines[@]}'\" {\n  run echo 'b'\n  run assert_line --regexp '^.a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- no output line matches regular expression --' ]\n  [ \"${lines[1]}\" == 'regexp : ^.a' ]\n  [ \"${lines[2]}\" == 'output : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Output formatting\n@test \"assert_line() --regexp <regexp>: displays \\`\\$output' in multi-line format if longer than one line\" {\n  run printf 'b 0\\nb 1'\n  run assert_line --regexp '^.a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 6 ]\n  [ \"${lines[0]}\" == '-- no output line matches regular expression --' ]\n  [ \"${lines[1]}\" == 'regexp : ^.a' ]\n  [ \"${lines[2]}\" == 'output (2 lines):' ]\n  [ \"${lines[3]}\" == '  b 0' ]\n  [ \"${lines[4]}\" == '  b 1' ]\n  [ \"${lines[5]}\" == '--' ]\n}\n\n\n###############################################################################\n# Matching single line: `-n' and `--index'\n###############################################################################\n\n# Options\ntest_n_index () {\n  run printf 'a\\nb\\nc'\n  run assert_line \"$1\" 1 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_line() -n <idx> <expected>: matches against the <idx>-th line only' {\n  test_n_index -n\n}\n\n@test 'assert_line() --index <idx> <expected>: matches against the <idx>-th line only' {\n  test_n_index --index\n}\n\n@test 'assert_line() --index <idx>: returns 1 and displays an error message if <idx> is not an integer' {\n  run assert_line --index 1a\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: assert_line --' ]\n  [ \"${lines[1]}\" == \"\\`--index' requires an integer argument: \\`1a'\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n\n#\n# Literal matching\n#\n\n# Correctness\n@test \"assert_line() --index <idx> <expected>: returns 0 if <expected> equals \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nb\\nc'\n  run assert_line --index 1 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_line() --index <idx> <expected>: returns 1 and displays details if <expected> does not equal \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nb\\nc'\n  run assert_line --index 1 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- line differs --' ]\n  [ \"${lines[1]}\" == 'index    : 1' ]\n  [ \"${lines[2]}\" == 'expected : a' ]\n  [ \"${lines[3]}\" == 'actual   : b' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n# Options\n@test 'assert_line() --index <idx> <expected>: performs literal matching by default' {\n  run printf 'a\\nb\\nc'\n  run assert_line --index 1 '*'\n  [ \"$status\" -eq 1 ]\n}\n\n\n#\n# Partial matching: `-p' and `--partial'\n#\n\n# Options\ntest_index_p_partial () {\n  run printf 'a\\n_b_\\nc'\n  run assert_line --index 1 \"$1\" 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_line() --index <idx> -p <partial>: enables partial matching' {\n  test_index_p_partial -p\n}\n\n@test 'assert_line() --index <idx> --partial <partial>: enables partial matching' {\n  test_index_p_partial --partial\n}\n\n# Correctness\n@test \"assert_line() --index <idx> --partial <partial>: returns 0 if <partial> is a substring in \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\n_b_\\nc'\n  run assert_line --index 1 --partial 'b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_line() --index <idx> --partial <partial>: returns 1 and displays details if <partial> is not a substring in \\`\\${lines[<idx>]}'\" {\n  run printf 'b 0\\nb 1'\n  run assert_line --index 1 --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- line does not contain substring --' ]\n  [ \"${lines[1]}\" == 'index     : 1' ]\n  [ \"${lines[2]}\" == 'substring : a' ]\n  [ \"${lines[3]}\" == 'line      : b 1' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n\n#\n# Regular expression matching: `-e' and `--regexp'\n#\n\n# Options\ntest_index_r_regexp () {\n  run printf 'a\\n_b_\\nc'\n  run assert_line --index 1 \"$1\" '^.b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'assert_line() --index <idx> -e <regexp>: enables regular expression matching' {\n  test_index_r_regexp -e\n}\n\n@test 'assert_line() --index <idx> --regexp <regexp>: enables regular expression matching' {\n  test_index_r_regexp --regexp\n}\n\n# Correctness\n@test \"assert_line() --index <idx> --regexp <regexp>: returns 0 if <regexp> matches \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\n_b_\\nc'\n  run assert_line --index 1 --regexp '^.b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"assert_line() --index <idx> --regexp <regexp>: returns 1 and displays details if <regexp> does not match \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nb\\nc'\n  run assert_line --index 1 --regexp '^.a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- regular expression does not match line --' ]\n  [ \"${lines[1]}\" == 'index  : 1' ]\n  [ \"${lines[2]}\" == 'regexp : ^.a' ]\n  [ \"${lines[3]}\" == 'line   : b' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n\n###############################################################################\n# Common\n###############################################################################\n\n@test \"assert_line(): \\`--partial' and \\`--regexp' are mutually exclusive\" {\n  run assert_line --partial --regexp\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: assert_line --' ]\n  [ \"${lines[1]}\" == \"\\`--partial' and \\`--regexp' are mutually exclusive\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test 'assert_line() --regexp <regexp>: returns 1 and displays an error message if <regexp> is not a valid extended regular expression' {\n  run assert_line --regexp '[.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: assert_line --' ]\n  [ \"${lines[1]}\" == \"Invalid extended regular expression: \\`[.*'\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test \"assert_line(): \\`--' stops parsing options\" {\n  run printf 'a\\n-p\\nc'\n  run assert_line -- '-p'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n"
  },
  {
    "path": "test/50-assert-18-refute_line.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n\n###############################################################################\n# Containing a line\n###############################################################################\n\n#\n# Literal matching\n#\n\n# Correctness\n@test \"refute_line() <unexpected>: returns 0 if <unexpected> is not a line in \\`\\${lines[@]}'\" {\n  run printf 'a\\nb\\nc'\n  run refute_line 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_line() <unexpected>: returns 1 and displays details if <unexpected> is not a line in \\`\\${lines[@]}'\" {\n  run echo 'a'\n  run refute_line 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- line should not be in output --' ]\n  [ \"${lines[1]}\" == 'line   : a' ]\n  [ \"${lines[2]}\" == 'index  : 0' ]\n  [ \"${lines[3]}\" == 'output : a' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n# Output formatting\n@test \"refute_line() <unexpected>: displays \\`\\$output' in multi-line format if it is longer than one line\" {\n  run printf 'a 0\\na 1\\na 2'\n  run refute_line 'a 1'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 8 ]\n  [ \"${lines[0]}\" == '-- line should not be in output --' ]\n  [ \"${lines[1]}\" == 'line  : a 1' ]\n  [ \"${lines[2]}\" == 'index : 1' ]\n  [ \"${lines[3]}\" == 'output (3 lines):' ]\n  [ \"${lines[4]}\" == '  a 0' ]\n  [ \"${lines[5]}\" == '> a 1' ]\n  [ \"${lines[6]}\" == '  a 2' ]\n  [ \"${lines[7]}\" == '--' ]\n}\n\n# Options\n@test 'refute_line() <unexpected>: performs literal matching by default' {\n  run echo 'a'\n  run refute_line '*'\n  [ \"$status\" -eq 0 ]\n}\n\n\n#\n# Partial matching: `-p' and `--partial'\n#\n\n# Options\ntest_p_partial () {\n  run printf 'a\\nb\\nc'\n  run refute_line \"$1\" 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_line() -p <partial>: enables partial matching' {\n  test_p_partial -p\n}\n\n@test 'refute_line() --partial <partial>: enables partial matching' {\n  test_p_partial --partial\n}\n\n# Correctness\n@test \"refute_line() --partial <partial>: returns 0 if <partial> is not a substring in any line in \\`\\${lines[@]}'\" {\n  run printf 'a\\nb\\nc'\n  run refute_line --partial 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_line() --partial <partial>: returns 1 and displays details if <partial> is a substring in any line in \\`\\${lines[@]}'\" {\n  run echo 'a'\n  run refute_line --partial 'a'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- no line should contain substring --' ]\n  [ \"${lines[1]}\" == 'substring : a' ]\n  [ \"${lines[2]}\" == 'index     : 0' ]\n  [ \"${lines[3]}\" == 'output    : a' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n# Output formatting\n@test \"refute_line() --partial <partial>: displays \\`\\$output' in multi-line format if it is longer than one line\" {\n  run printf 'a\\nabc\\nc'\n  run refute_line --partial 'b'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 8 ]\n  [ \"${lines[0]}\" == '-- no line should contain substring --' ]\n  [ \"${lines[1]}\" == 'substring : b' ]\n  [ \"${lines[2]}\" == 'index     : 1' ]\n  [ \"${lines[3]}\" == 'output (3 lines):' ]\n  [ \"${lines[4]}\" == '  a' ]\n  [ \"${lines[5]}\" == '> abc' ]\n  [ \"${lines[6]}\" == '  c' ]\n  [ \"${lines[7]}\" == '--' ]\n}\n\n\n#\n# Regular expression matching: `-e' and `--regexp'\n#\n\n# Options\ntest_r_regexp () {\n  run printf 'a\\nb\\nc'\n  run refute_line \"$1\" '^.d'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_line() -e <regexp>: enables regular expression matching' {\n  test_r_regexp -e\n}\n\n@test 'refute_line() --regexp <regexp>: enables regular expression matching' {\n  test_r_regexp --regexp\n}\n\n# Correctness\n@test \"refute_line() --regexp <regexp>: returns 0 if <regexp> does not match any line in \\`\\${lines[@]}'\" {\n  run printf 'a\\nb\\nc'\n  run refute_line --regexp '.*d.*'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_line() --regexp <regexp>: returns 1 and displays details if <regexp> matches any lines in \\`\\${lines[@]}'\" {\n  run echo 'a'\n  run refute_line --regexp '.*a.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- no line should match the regular expression --' ]\n  [ \"${lines[1]}\" == 'regexp : .*a.*' ]\n  [ \"${lines[2]}\" == 'index  : 0' ]\n  [ \"${lines[3]}\" == 'output : a' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n# Output formatting\n@test \"refute_line() --regexp <regexp>: displays \\`\\$output' in multi-line format if longer than one line\" {\n  run printf 'a\\nabc\\nc'\n  run refute_line --regexp '.*b.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 8 ]\n  [ \"${lines[0]}\" == '-- no line should match the regular expression --' ]\n  [ \"${lines[1]}\" == 'regexp : .*b.*' ]\n  [ \"${lines[2]}\" == 'index  : 1' ]\n  [ \"${lines[3]}\" == 'output (3 lines):' ]\n  [ \"${lines[4]}\" == '  a' ]\n  [ \"${lines[5]}\" == '> abc' ]\n  [ \"${lines[6]}\" == '  c' ]\n  [ \"${lines[7]}\" == '--' ]\n}\n\n\n###############################################################################\n# Matching single line: `-n' and `--index'\n###############################################################################\n\n# Options\ntest_n_index () {\n  run printf 'a\\nb\\nc'\n  run refute_line \"$1\" 1 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_line() -n <idx> <expected>: matches against the <idx>-th line only' {\n  test_n_index -n\n}\n\n@test 'refute_line() --index <idx> <expected>: matches against the <idx>-th line only' {\n  test_n_index --index\n}\n\n@test 'refute_line() --index <idx>: returns 1 and displays an error message if <idx> is not an integer' {\n  run refute_line --index 1a\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: refute_line --' ]\n  [ \"${lines[1]}\" == \"\\`--index' requires an integer argument: \\`1a'\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n\n#\n# Literal matching\n#\n\n# Correctness\n@test \"refute_line() --index <idx> <unexpected>: returns 0 if <unexpected> does not equal \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nb\\nc'\n  run refute_line --index 1 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_line() --index <idx> <unexpected>: returns 1 and displays details if <unexpected> equals \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nb\\nc'\n  run refute_line --index 1 'b'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 4 ]\n  [ \"${lines[0]}\" == '-- line should differ --' ]\n  [ \"${lines[1]}\" == 'index : 1' ]\n  [ \"${lines[2]}\" == 'line  : b' ]\n  [ \"${lines[3]}\" == '--' ]\n}\n\n# Options\n@test 'refute_line() --index <idx> <unexpected>: performs literal matching by default' {\n  run printf 'a\\nb\\nc'\n  run refute_line --index 1 '*'\n  [ \"$status\" -eq 0 ]\n}\n\n\n#\n# Partial matching: `-p' and `--partial'\n#\n\n# Options\ntest_index_p_partial () {\n  run printf 'a\\nb\\nc'\n  run refute_line --index 1 \"$1\" 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_line() --index <idx> -p <partial>: enables partial matching' {\n  test_index_p_partial -p\n}\n\n@test 'refute_line() --index <idx> --partial <partial>: enables partial matching' {\n  test_index_p_partial --partial\n}\n\n# Correctness\n@test \"refute_line() --index <idx> --partial <partial>: returns 0 if <partial> is not a substring in \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nabc\\nc'\n  run refute_line --index 1 --partial 'd'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_line() --index <idx> --partial <partial>: returns 1 and displays details if <partial> is a substring in \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nabc\\nc'\n  run refute_line --index 1 --partial 'b'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- line should not contain substring --' ]\n  [ \"${lines[1]}\" == 'index     : 1' ]\n  [ \"${lines[2]}\" == 'substring : b' ]\n  [ \"${lines[3]}\" == 'line      : abc' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n\n#\n# Regular expression matching: `-e' and `--regexp'\n#\n\n# Options\ntest_index_r_regexp () {\n  run printf 'a\\nb\\nc'\n  run refute_line --index 1 \"$1\" '^.b'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute_line() --index <idx> -e <regexp>: enables regular expression matching' {\n  test_index_r_regexp -e\n}\n\n@test 'refute_line() --index <idx> --regexp <regexp>: enables regular expression matching' {\n  test_index_r_regexp --regexp\n}\n\n# Correctness\n@test \"refute_line() --index <idx> --regexp <regexp>: returns 0 if <regexp> does not match \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nabc\\nc'\n  run refute_line --index 1 --regexp '.*d.*'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test \"refute_line() --index <idx> --regexp <regexp>: returns 1 and displays details if <regexp> matches \\`\\${lines[<idx>]}'\" {\n  run printf 'a\\nabc\\nc'\n  run refute_line --index 1 --regexp '.*b.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 5 ]\n  [ \"${lines[0]}\" == '-- regular expression should not match line --' ]\n  [ \"${lines[1]}\" == 'index  : 1' ]\n  [ \"${lines[2]}\" == 'regexp : .*b.*' ]\n  [ \"${lines[3]}\" == 'line   : abc' ]\n  [ \"${lines[4]}\" == '--' ]\n}\n\n\n###############################################################################\n# Common\n###############################################################################\n\n@test \"refute_line(): \\`--partial' and \\`--regexp' are mutually exclusive\" {\n  run refute_line --partial --regexp\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: refute_line --' ]\n  [ \"${lines[1]}\" == \"\\`--partial' and \\`--regexp' are mutually exclusive\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test 'refute_line() --regexp <regexp>: returns 1 and displays an error message if <regexp> is not a valid extended regular expression' {\n  run refute_line --regexp '[.*'\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- ERROR: refute_line --' ]\n  [ \"${lines[1]}\" == \"Invalid extended regular expression: \\`[.*'\" ]\n  [ \"${lines[2]}\" == '--' ]\n}\n\n@test \"refute_line(): \\`--' stops parsing options\" {\n  run printf 'a\\n--\\nc'\n  run refute_line -- '-p'\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n"
  },
  {
    "path": "test/50-assert-19-refute.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\n\n@test 'refute() <expression>: returns 0 if <expression> evaluates to FALSE' {\n  run refute false\n  [ \"$status\" -eq 0 ]\n  [ \"${#lines[@]}\" -eq 0 ]\n}\n\n@test 'refute() <expression>: returns 1 and displays <expression> if it evaluates to TRUE' {\n  run refute true\n  [ \"$status\" -eq 1 ]\n  [ \"${#lines[@]}\" -eq 3 ]\n  [ \"${lines[0]}\" == '-- assertion succeeded, but it was expected to fail --' ]\n  [ \"${lines[1]}\" == 'expression : true' ]\n  [ \"${lines[2]}\" == '--' ]\n}\n"
  },
  {
    "path": "test/test_helper.bash",
    "content": "setup() {\n  export TEST_MAIN_DIR=\"${BATS_TEST_DIRNAME}/..\"\n  export TEST_DEPS_DIR=\"${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}\"\n\n  # Load dependencies.\n  load \"${TEST_DEPS_DIR}/bats-support/load.bash\"\n\n  # Load library.\n  load '../load'\n}\n"
  }
]