Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to collection tests #615

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

BarAgent
Copy link
Member

@BarAgent BarAgent commented Dec 8, 2013

Collections test suite was incorrect for element: the return value does not need to be the element type of the collection if default: is used.

Collections test suite was too strict with add! and remove!: OD implements them on <collection>, not just <sequence>.

…does not need to be the element type of the collection if “default:” is used.

Collections test suite was too strict with add! and remove!: OD implements them on <collection>, not just <sequence>.
@BarAgent
Copy link
Member Author

BarAgent commented Dec 8, 2013

This is related to #399.

@waywardmonkeys
Copy link
Member

Does this create any new failures with current OD or does it fix some?

@BarAgent
Copy link
Member Author

BarAgent commented Dec 8, 2013

In the collections-protocol-test-suite of common-dylan-test-suite-app, this pull request clears up two failing tests and adds a number of new failing tests.

It makes the tests on add! and remove! pass. The test was expecting them to return <sequence>, but they actually return <collection>, since OD implements those methods for sets.

It makes some tests on element fail. The test was expecting element(x, -1, default: #"wrong-default-type") to signal an error because #"wrong-default-type" does not match the collections' element type. This is how OD is currently implemented. But that behavior is incorrect; the correct behavior is that the element method returns #"wrong-default-type". This pull request changes the test to expect that behavior, and so the test fails.

@BarAgent
Copy link
Member Author

According to the function documentation, the return value of element is specialized to <object> and it returns the default: argument if the key is not present in the collection. DRM p. 300.

The return value of element is discussed more precisely in the "Element Types" section of the DRM. DRM p. 124:

Each instance of X of <collection> has a conceptual element type that is an instance of <type>. If the element type of X is T, X stores elements of type T. The element method will always return an instance of T

But a few paragraphs down, the DRM continues:

Note: the above statements about the value returned by element only apply when no default: keyword argument is specified.

Later, the "Limited Collection Types" section discusses the return value of element specifically in regards to limited collections, basically restating the above. DRM p. 128:

The element method will always return an instance of T1 … The above statements about the value returned by element only apply when no default: keyword is specified.

I take those disclaimers to mean that when the default: keyword is specified, there are no limits or expectations imposed upon the return value of element save those in the function documentation, which is that it must be a direct or indirect instance of <object>.

@brucehoult
Copy link

Well, presumably you can at least narrow it down to:

type-union(T, singleton(defaultArg))

On Wed, Dec 25, 2013 at 7:22 PM, Dustin Voss [email protected]:

According to the function documentation, the return value of element is
specialized to and it returns the default: argument if the key
is not present in the collection. DRM p. 300http://opendylan.org/books/drm/Collection_Operations#element
.

The return value of element is discussed more precisely in the "Element
Types" section of the DRM. DRM p. 124http://opendylan.org/books/drm/Element_Types
:

Each instance of X of has a conceptual element type that
is an instance of . If the element type of X is T, X stores
elements of type T. The element method will always return an instance
of T

But a few paragraphs down, the DRM continues:

Note: the above statements about the value returned by element only apply
when no default: keyword argument is specified.

Later, the "Limited Collection Types" section discusses the return value
of element specifically in regards to limited collections, basically
restating the above. DRM p. 128http://opendylan.org/books/drm/Limited_Collection_Types
:

The element method will always return an instance of T1 … The above
statements about the value returned by element only apply when no default:keyword is specified.

I take those disclaimers to mean that when the default: keyword is
specified, there are no limits or expectations imposed upon the return
value of element save those in the function documentation, which is that
it must be a direct or indirect instance of .


Reply to this email directly or view it on GitHubhttps://github.com//pull/615#issuecomment-31192808
.[image: Web Bug from
https://github.com/notifications/beacon/851040__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwMzQ4NTM2NSwiZGF0YSI6eyJpZCI6MjE2NTQyNDZ9fQ==--02eb4ddc62ae540664eb243d5776676edf43b10b.gif]

This message has been scanned for viruses and
dangerous content by MailScanner http://www.mailscanner.info/, and is
believed to be clean.

@BarAgent
Copy link
Member Author

Surely so, though the DRM doesn't say it flat-out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants