Skip to content

test(parser): planeswalker inverted counter prohibition regression#3501

Merged
matthewevans merged 1 commit into
phase-rs:mainfrom
kiannidev:feat/issue-3483-planeswalker-counter-prohibition
Jun 16, 2026
Merged

test(parser): planeswalker inverted counter prohibition regression#3501
matthewevans merged 1 commit into
phase-rs:mainfrom
kiannidev:feat/issue-3483-planeswalker-counter-prohibition

Conversation

@kiannidev

Copy link
Copy Markdown
Contributor

Summary

  • Add inverted_counter_prohibition_planeswalkers regression test

Test plan

  • cargo test -p engine --lib inverted_counter_prohibition_planeswalkers

Closes #3500. Closes #3453.

Made with Cursor

Explicit regression for Planeswalkers can't have counters put on them.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kiannidev kiannidev requested a review from matthewevans as a code owner June 16, 2026 13:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds two new unit tests, inverted_counter_prohibition_planeswalkers and inverted_counter_prohibition_artifacts, to verify the parsing of counter prohibition replacement effects. Feedback indicates that these tests are redundant because their coverage is already thoroughly handled by the existing inverted_typed_counter_prohibition_covers_every_permanent_type test, so they should be removed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +12349 to +12383
#[test]
fn inverted_counter_prohibition_planeswalkers() {
let def = parse_replacement_line(
"Planeswalkers can't have counters put on them.",
"Test Card",
)
.expect("planeswalker counter prohibition must parse");
assert_eq!(def.event, ReplacementEvent::AddCounter);
assert_eq!(
def.quantity_modification,
Some(QuantityModification::Prevent)
);
assert!(matches!(
def.valid_card,
Some(TargetFilter::Typed(tf))
if tf.type_filters == vec![TypeFilter::Planeswalker]
));
}

#[test]
fn inverted_counter_prohibition_artifacts() {
let def = parse_replacement_line("Artifacts can't have counters put on them.", "Test Card")
.expect("artifact counter prohibition must parse");
assert_eq!(def.event, ReplacementEvent::AddCounter);
assert_eq!(
def.quantity_modification,
Some(QuantityModification::Prevent)
);
assert!(matches!(
def.valid_card,
Some(TargetFilter::Typed(tf))
if tf.type_filters == vec![TypeFilter::Artifact]
));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[MEDIUM] Redundant test cases. Evidence: crates/engine/src/parser/oracle_replacement.rs:12349-12383. Why it matters: These tests duplicate coverage already provided by inverted_typed_counter_prohibition_covers_every_permanent_type (lines 11189-11223), which is even more thorough as it also asserts the InZone property and that the controller is None. Suggested fix: Remove the redundant test functions.

@matthewevans matthewevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer review — ENQUEUE-READY (test PR)

Verdict: looks good. Both tests drive the real parser entry point and discriminate against live logic.

Test discrimination — PASS

inverted_counter_prohibition_planeswalkers and inverted_counter_prohibition_artifacts call parse_replacement_line("Planeswalkers can't have counters put on them.", ...) / "Artifacts ..." — the full parser entry — and assert:

  • event == ReplacementEvent::AddCounter
  • quantity_modification == Some(Prevent)
  • valid_card is Typed(tf) with tf.type_filters == [Planeswalker] / [Artifact]

These pin the output of parse_inverted_typed_counter_prohibition (oracle_replacement.rs:5400), which is real, general logic — it uses separated_list1 over parse_counter_prohibition_type and explicitly admits Artifact/Creature/Enchantment/Land/Planeswalker/Battle. If the dispatch arm (:536) or that combinator were reverted, parse_replacement_line returns None, the .expect(...) panics, and both tests fail. Discriminating, not AST-shape-only.

Notes

  • Good that both Planeswalker and Artifact are covered — exercises the building block across the type-list class rather than one subject. Confirms the inverted ("type is subject") surface form, distinct from the Counters can't be put on X form.
  • Closes #3500. Closes #3453#3453 is an issue, not an open PR; no duplicate-PR collision.

No production behavior change. Approving.

@matthewevans matthewevans added the test Add tests label Jun 16, 2026
@matthewevans matthewevans self-assigned this Jun 16, 2026
@matthewevans matthewevans added this pull request to the merge queue Jun 16, 2026
@matthewevans matthewevans removed their assignment Jun 16, 2026
Merged via the queue into phase-rs:main with commit 0562c88 Jun 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Add tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(parser): planeswalker inverted counter prohibition regression feat(parser): planeswalkers counter prohibition inverse wording

2 participants