Test-More / test-more

Test2, Test::More, Test::Simple and Test::Builder Perl modules for writing tests
Other
140 stars 87 forks source link

Discourage checking hash fields in `object`. #994

Open schwern opened 8 years ago

schwern commented 8 years ago

It's glassbox testing to say that an object must contain certain hash fields and should not be encouraged. Unfortunately the object doc example spends half its time on this.

This is particularly egregious with end. This requires that the object contain exactly certain specific fields and no others. And end only applies to certain parts of the object description complicating how the user expects end to work.

To that end...

This eliminates a bunch of redundancy in object with hash and array, and it allows the object docs to focus on blackbox testing.

exodist commented 8 years ago

I am not sure we need to allow hash/array to work inside object, instead we can rely on the 'this' prop provided by meta:

object {
    prop this => hash { ... }; # Check the hash of the object
};

This already works as written today.

exodist commented 8 years ago

#76 would discourage the use of Object { ... } in favor of

st Object => sub {
    stc method => 'expect';
}

fields would essentially be discouraged everywhere, so the problem this ticket mentions would be solved.