|
spudplate
Template scaffolding compiler for spudlang .spud files
|
Test prompter: replays a fixed sequence of canned answers. More...
#include <interpreter.h>
Public Member Functions | |
| ScriptedPrompter (std::vector< std::string > answers) | |
Construct with the canned answers prompt will replay in order. | |
| std::string | prompt (const PromptRequest &req) override |
Display the prompt described by req and return the user's raw answer. | |
| bool | authorize (const std::string &summary) override |
| Display a security summary and return whether to proceed. | |
| const std::optional< PromptRequest > & | last_request () const |
| Most recent request seen, for assertions on rendering inputs. | |
| const std::vector< PromptRequest > & | requests () const |
| Every request seen so far, in order. | |
| void | set_authorize_response (bool value) |
Set what authorize returns. | |
| const std::optional< std::string > & | last_authorize_summary () const |
| Most recent authorize summary seen, for assertions. | |
Test prompter: replays a fixed sequence of canned answers.
Constructed with a vector of strings; each call to prompt consumes the next answer. Calling prompt after the queue is exhausted throws std::logic_error, so test retry-loop bugs cannot hang.
|
overridevirtual |
Display the prompt described by req and return the user's raw answer.
The interpreter parses the returned string, validates it against type and options, and on rejection calls back with previous_error set. Implementations deliver one raw line per call.
Implements spudplate::Prompter.
|
overridevirtual |
Display a security summary and return whether to proceed.
Called once, before any statement runs, when the program contains run clauses. The summary is multi-line and lists every literal command that may execute. Returning false aborts the run cleanly with no side effects.
Implements spudplate::Prompter.
|
inline |
Every request seen so far, in order.
Useful for asserting on counter, indent, or iteration sequences across a multi-prompt run.
|
inline |
Set what authorize returns.
Defaults to true (accept).