call matches U for DNE is confusing.

Open
#952 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
perl
Domain
testing

Research direction

The issue provides a Perl reproducer showing that a misspelled method returning DNE matches U(); start by running this example and tracing the object matcher behavior involved in method calls. Done should provide a way to distinguish a method that returns undef from a method that does not exist, with tests covering both cases.

Written by the indexing model from the issue text.

Description

This is bit me a couple of times:

use Test2::V0;

package Foo {
  sub new { bless {}, __PACKAGE__ }
  sub bar { return undef; }
};

is(
  Foo->new,
  object {
    call baar => U();
  },
);

done_testing;

This passes because calling typo'd baar results in DNE which matches U. This makes sense for consistency with testing other types of objects, but I'm not sure if there is a way to test a method that returns undef without getting a pass on a method that does not exist.

Dominant language
Perl
Stars
149
Forks
98
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Test-More/test-more

All issues in Test-More/test-more

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.