ShouldType

ShouldType is the base type passed between UFCS words in fluent assertions. It stores the left-hand side expression of the phrase, called "got" in errors, as well as the words making up the assertion phrase as template arguments.

Constructors

this
this(G got, int refCount)

Manually initialize a new ShouldType value from an existing one's ref count. All ShouldTypes of one phrase must use the same reference counter.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Enums

hasWord
eponymoustemplate hasWord(string word)

Evaluates to true if the given word exists in the current phrase.

Functions

addWord
auto addWord()

Add a word to the phrase. Can be chained.

check
void check(bool condition, string expected, string butGot, string file, size_t line)

Checks a boolean condition for truth, throwing an exception when it fails. The components making up the exception string are passed lazily. The message has the form: "Test failed: expected {expected}[ because reason], but got {butGot}" For instance: "Test failed: expected got.empty() because there should be nothing in there, but got [5]." In that case, expected is "got.empty()" and butGot is "[5]".

empty
auto empty(Fence _, string file, size_t line)
Undocumented in source. Be warned that the author may not have intended to support it.
got
auto got()
Undocumented in source. Be warned that the author may not have intended to support it.
got
const(typeof(this.got_())) got()
Undocumented in source. Be warned that the author may not have intended to support it.
terminateChain
void terminateChain()

Mark that the semantic end of this phrase has been reached. If this is not called, the phrase will error on scope exit.

Templates

allowOnlyWords
template allowOnlyWords(allowedWords...)

Allows to check that only a select list of words are permitted before the current word. On failure, an informative error is printed. Usage: should.allowOnlyWords!("word1", "word2").before!"newWord";

requireWord
template requireWord(string requiredWord)

Allows to check that a specified word appeared in the phrase before the current word. On failure, an informative error is printed. Usage: should.requireWord!"word".before!"newWord";

Meta