moo.core.tests.test_parser

Functions

test_article_stripping_lowercase(article)

Lowercase articles the/a/an/my are stripped as specifiers.

test_balanced_double_quotes_no_error()

Correctly balanced quotes should parse without error.

test_dead_dobj_raises_no_such_object(t_init, ...)

A verb name that exists somewhere + an unresolvable dobj should raise NoSuchObjectError, not NoSuchVerbError — so the player sees There is no 'lunch' here. instead of I don't know how to do that.

test_do_command_absent_falls_through_to_normal_dispatch(...)

When do_command does not exist, normal dispatch runs unchanged.

test_do_command_falsy_return_falls_through_to_normal_dispatch(...)

do_command returning False allows normal verb dispatch.

test_do_command_receives_words_as_args(...)

do_command receives the tokenized command words as positional args.

test_do_command_truthy_return_skips_normal_dispatch(...)

do_command returning True prevents normal verb dispatch.

test_escaped_quotes_do_not_count_as_unmatched()

Escaped quotes inside a string should not trigger the unmatched-quote check.

test_expand_wildcard()

test_get_dobj_lookup_falls_back_when_no_local_match(...)

get_dobj(lookup=True) falls back to global lookup() when no local match.

test_get_dobj_lookup_prefers_local_match(...)

get_dobj(lookup=True) returns the locally-matched object when one exists.

test_interpret_runs_each_fragment(t_init, ...)

A period+space-separated command invokes the parser once per fragment (trailing period on the last fragment stays as text — see test_split_fragments_trailing_period_kept).

test_ispec_this_constraint_is_enforced(...)

An --ispec to:this verb matches only when the to indirect object resolves to the verb's own object.

test_lex_canonical_preposition_unchanged()

test_lex_direct_object()

test_lex_direct_object_with_preposition()

test_lex_imperative_command()

test_lex_look_at_QUOTED_painting_with_the_glasses()

test_lex_object_of_the_preposition()

test_lex_synonym_preposition_normalized()

test_multi_prep_verb_still_matches_prepless_command(...)

A single verb declaring several prepositions stays permissive: it matches both a prep-less command and one using a declared prep (the behavior look and friends rely on).

test_parse_command_referring_to_aliases(...)

test_parse_direct_object(t_init, t_wizard)

test_parse_direct_object_and_multiple_prepositions_with_specifiers(...)

test_parse_direct_object_object_of_the_preposition_with_preposition(...)

test_parse_double_quoted_string_with_escaped_inner_quotes(...)

test_parse_double_quoted_string_with_inner_escaped_quotes(...)

test_parse_imperative_command(t_init, t_wizard)

test_parse_object_of_the_preposition(t_init, ...)

test_parse_object_of_the_preposition_with_preposition(...)

test_parse_specifier(t_init, t_wizard)

test_parse_synonym_get_pobj_str(t_init, t_wizard)

test_parse_synonym_has_pobj_str(t_init, t_wizard)

test_parse_with_complex_name(t_init, t_wizard)

test_parse_with_my_object(t_init, t_wizard)

test_parse_with_quoted_strings(t_init, t_wizard)

test_parse_with_quoted_strings_and_escapes(...)

test_possessive_specifier_stays_as_specifier()

Bill's (a proper noun possessive) is treated as a specifier on the dobj — this branch of the SPEC regex preserves casing.

test_same_name_variants_dispatch_by_preposition(...)

Among same-named verbs on one object, the variant whose declared preposition matches the command wins — not the one created first.

test_split_fragments_all_separators_falls_back()

An input of pure separators round-trips so the parser raises its usual error.

test_split_fragments_at_prefixed_verb_splits()

Wizard/builder verbs starting with @ are valid fragment heads.

test_split_fragments_comma_no_space_kept()

n,n,n (no spaces) is NOT split — cardinal-direction shorthand that the canonical splitter handled is sacrificed to protect [1,2,3] JSON values.

test_split_fragments_comma_separates_with_alpha_continuation()

Commas split only when followed by whitespace + alpha.

test_split_fragments_inside_brackets_preserved()

Commas/periods inside (), [], {} never split.

test_split_fragments_leading_then_dropped()

A leading then produces only the following fragment.

test_split_fragments_mixed_at_and_alpha_chain()

A single line can chain @-verbs and plain verbs across separators.

test_split_fragments_no_separators_round_trips()

test_split_fragments_period_no_space_kept()

foo.bar (no space after period) is not a split — preserves decimals, abbreviations, file paths, etc.

test_split_fragments_period_separates_with_alpha_continuation()

Period+space splits a Zork-style multi-action input into fragments.

test_split_fragments_quoted_periods_preserved()

Periods inside quoted strings must not split the command.

test_split_fragments_quoted_then_preserved()

then inside quotes is just text, not a separator.

test_split_fragments_semicolon_no_space_kept()

; with no following whitespace+alpha is not a separator.

test_split_fragments_semicolon_separates()

; is a separator alongside . and ,.

test_split_fragments_then_is_case_insensitive()

test_split_fragments_then_is_word_boundary()

then only splits when it stands alone — not inside theory etc.

test_split_fragments_then_separates()

test_split_fragments_trailing_period_kept()

Trailing period with no alpha continuation stays as text — so emote waves hello. reaches the verb intact.

test_three_unescaped_quotes_raises_usage_error()

Three unescaped quotes (odd) should raise UsageError.

test_unknown_verb_with_dobj_str_raises_no_such_verb(...)

If the verb name does not exist anywhere at all, the error stays NoSuchVerbError even when the player typed a dobj.

test_unknown_verb_with_no_dobj_still_raises_no_such_verb(...)

Regression: typing nonsense with no dobj still produces NoSuchVerbError.

test_unmatched_double_quote_raises_usage_error()

Unclosed double quote in a command should raise UsageError immediately.

test_verb_dispatch_is_case_insensitive(...)

Verbs are stored lowercase; uppercase input must still dispatch.