-
Notifications
You must be signed in to change notification settings - Fork 0
Expectations
Tim edited this page Sep 19, 2015
·
4 revisions
These follow the syntax described in Syntax.
Both Assertions and Assumptions declare expectations. A Failed Assumption however only causes a test to be skipped.
| Assertion/Assumption | Expected value |
|---|---|
true |
true |
truthy |
not false, not nil
|
false |
false |
falsy |
false or nil
|
nil |
nil |
--- compare identity: `expected == actual`
equal(expected, actual)
equals(expected, actual)--- deep compare table keys and values
same(expected, actual)
--- assert entries in lists to be unique
unique(actual, deep)near(expected, actual, tolerance)match(pattern, actual, [init, [plain]])
matches(pattern, actual, [init, [plain]])pattern, init are defined as with string.match. If plain is defined, string.find is used instead.
Also see the chapter on patterns.
booleannumberstringtableniluserdatafunctionthread
error(func, [expected_error])
errors(func, [expected_error])
error_matches(func, pattern, [init, [plain]])
error_match(func, pattern, [init, [plain]])
matches_error(func, pattern, [init, [plain]])
match_error(func, pattern, [init, [plain]])pattern, init are defined as with string.match. If plain is defined, string.find is used instead.
Also see the chapter on patterns.
--- test if of same type() and having the same metatable
same_class(expected, actual)itemstack
called()
called_at_least(count)
called_at_most(count)
called_more_than(count)
called_less_than(count)
-- takes parameters or matchers
called_with(expected, ...)
returned_with(expected, ...)Expected parameters for *_with can be exact parameters or Matchers