matchers: fix a message typo.

* specl/matchers.lua (matchers.error): 'containing' has only one 'a'!

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
shell: use the correct parameter name.

* specl/shell.lua (matchers.match_output, matchers.contain_output):
Format a correctly named parameter.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
specs: test the correct matcher when tickling errors.

* specs/shell_spec.yaml (contain_output matcher): Don't call the
should_output matcher by mistake!

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
specs: use unique description text in shell_spec.yaml.

* specs/shell_spec.yaml: correctly describe the behaviour being
checked.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
shell: add Process errout matchers.

* specs/shell_spec.lua (output_error matcher)
(match_error matcher, contain_error matcher): Specifications for
new matchers to check the contents of stderr from a Process.
* specl/shell.lua (matchers.output_error, matchers.match_error)
(matchers.contain_error): Implement new matchers.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
color: use color.reset instead of "%{reset}".

* specl/color.lua (colormap): Add reset.
* specl/formatter/progress.lua, specl/formatter/report.lua: Use it.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
std: add chomp from upstream lua-stdlib.

* specl/std.lua (chomp): New function, from lua-stdlib string_ext.
* specl/util.lua (chomp): Re-export std.chomp.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
matchers: more powerful matcher result message API.

* specl/matchers.lua (Matcher): Don't add spaces and commas auto-
matically, assuming output always fits on a line, but do set
format_actual and format_expect to provide that by default.
Adjust all clients.
* specl/color.lua (colormap): Add an entry for coloring shell
output.
* specl/shell.lua: Use new shell color, and new Matcher formatting
API to present nicely formatted output and error stream display.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: make output of failed expectations prettier.

* specl/color.lua (shell): Rename from this...
(match): ...to this. Adjust all callers.
* specl/shell.lua (escape, colon): Move from here...
* specl/matchers.lua (escape, reformat): ...to here. Adjust all
callers.
(M): Re-export reformat for use in specl/shell.lua.
* specl/std.lua (prettytostring): New function, from lua-stdlib
string_ext module.
* specl/util.lua (prettytostring): Re-export std.prettytostring.
* specl/matchers.lua (matcher.contain): Use prettytostring to
show contents of failed expections with tables.
* specs/matchers_spec.yaml, specs/shell_spec.yaml: Many new
examples to verify prettier failed expectation output for each
matcher.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
specl: show description and offset line for example compile errors.

Previously, if the Lua code of any example failed, Specl would
dump the stack, usually containing a useless list of nested
run_context, run_examples etc etc.  We can already do a much
better job than that... libyaml needs to provide the support
for full and proper filewise line numbers though.
* specs/specl_spec.yaml (it reports line of error): Example to
demonstrate that the offset line of a compile failure is shown
on stderr.
* src/specl.lua (compile_example): Add a description parameter,
and use it as a prefix for displaying the line offset for the
failure, along with the Lua error.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
matchers: support `one_of` syntax for alternatives.

* specs/matchers_spec.yaml: Add `one_of` examples for every
matcher.
(it diagnoses zero alternatives with one_of): Add an example of
getting a diagnostic from calling ...one_of {}.
* specs/shell_spec.yaml: Add `one_of` examples for every matcher.
* specl/matcher.lua (expect): Rename `matcher` parameter to
`matcher_name`.
(expect.__index:score): Factor out of returned function.
(expect.__index): Return a functable instead of a function, with
a `one_of` method, and a `__call` metamethod.
(Matcher["one_of?"]): Call the matcherp predicate with every
table entry, until one matches successfully.
(Matcher): Add default for `format_one_of`.
* specl/util.lua (concat): Factor pretty alternatives display
formatting out of type_error.
(M.QUOTED): Export a constant for self-documenting concat calls,
using `concat (foo, util.QUOTED)`.
(type_error): Simplify.
* specl/matcher.lua (matchers.error, matchers.match)
(matchers.contain): Add `format_one_of` methods.
* specl/util.lua (type_check): Support '#table' in the typelist to
specify a non-empty table.
(type_error): Display nicely formatted error when an empty table
is found when checking for '#table'.
* specl/util.lua (map): Move above first use, in concat ().
* docs/specl.md (Matching alternatives with `one_of`): Document it.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: use Lua "%q" formatting instead of rolling our own.

* specl/matchers.lua (q): Use Lua "%q" formatting instead of
manually emulating it.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: no need to use matchers.stringify in shell.lua.

* specl/shell.lua (matchers.exit): Use `tostring` instead of
importing matchers.stringify into `q`.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: rename expect target parameter to actual.

* specl/matchers.lua (expect): Rename <target> parameter to
<actual> to match the rest of the code.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: move long format display from shell.lua to matchers.lua.

* specl/matcher.lua (reformat): Rename single item reformatting
from this...
(_reformat): to this.
* specl/shell.lua (concat): Move from here...
* specl/matchers.lua (reformat): ...to here, making use of
_reformat to simplify.
(matchers.error): Use long format output.
* specs/matchers_spec.yaml: Adjust.
* specl/shell.lua: Simplify matchers accordingly.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
matchers: support `any_of` as an alias for `one_of`.

* specl/matchers.lua (matchers.error): Display "no error" when no
error message was raised, but one was expected.
(adaptor_error): New function. Diagnose misuse of `should`
adaptors.
(expect): Don't overwrite full matcher name, use `matcher_root`
to hold the matcher lookup key.
Add support for `any_of` adaptor, mainly for use with `should_not`
because `expect (1).should_not_be.one_of {1, 2 ,3}` reads badly.
Call `adaptor_error` when an unsupported adaptor is called.
* specs/matchers_spec.yaml: Lots more examples to exercise every
permutation of matcher vs. not vs. one_of or any_of.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: remove `one_of` support, always use `any_of`.

* specl/matchers.lua (Matcher["one_of?"}, Matcher.format_one_of):
Renamed from these...
(Matcher["any_of?"], Matcher.format_any_of): ...to these.
Adjust all callers.
(adaptor_error): Folded back into expect.__index.
(expect.one_of): Remove.
* specs/matchers_spec.yaml, specs/shell_spec.yaml: Adjust.
* docs/specl.md: Update.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
refactor: untabify.

Bring back zmacs... vi's TABy auto-indent is EVIL!
* specl/color.lua, specl/formatter/progress.lua,
specl/formatter/report.lua, specl/formatter/tap.lua,
specl/matchers.lua, specl/util.lua, src/specl.lua: Untabify.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
docs: convert to jekyll markdown format.

Updating the docs site is now a simple matter of copying this
file to index.md in the gh-pages branch, and letting github do
its magic to pick up the changes.
* docs/specl.md: Add YAML frontmatter.
Wrap code blocks in pygments highlight tags.
Redo numbered headers with ## format markup for jekyll.
Add markdown section anchors that match jekyll auto-generated
anchors for easy cross-referencing.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
maint: use Lua 5.2 compatible pattern escaping.

Lua 5.1 accepts patterns with unknown % escapes treated as
literals, but Lua 5.2 raises an error. Factor pattern escaping
into a function.
Thank you, Travis!
* specl/util.lua (plain): New function to escape only pattern
magic characters.
* specl/matchers.lua (escape, reformat, matchers.error)
(matchers.contain): Use it.
* specl/shell.lua (matchers.contain_output)
(matchers.contain_error): Likewise.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>