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

DM-10777: Create TransformBoundedField #24

Merged
merged 3 commits into from Jul 10, 2017
Merged

DM-10777: Create TransformBoundedField #24

merged 3 commits into from Jul 10, 2017

Conversation

r-owen
Copy link
Contributor

@r-owen r-owen commented Jul 6, 2017

No description provided.

For two objects be equal, they both must have the same attributes and all contained objects
must be equal. However, this test ignores the difference between attributes that are not set
and attributes that are set to their default value, because that difference is irrelevant
to most behavior.
Copy link

Choose a reason for hiding this comment

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

Most, but not all. Would be nice to know the difference. Perhaps it is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You raise a good point. The AST manual is somewhat vague on this and I'm going to play it safe and not ignore the difference. That will require a tweak in afw's Transform constructor, but it's probably worth the tweak.

src/Object.cc Outdated
std::replace(thisStr.begin(), thisStr.end(), '#', ' ');
std::replace(rhsStr.begin(), rhsStr.end(), '#', ' ');

return rhsStr == thisStr;
Copy link

Choose a reason for hiding this comment

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

Hmm, I can't say I'm wildly enthusiastic about comparing equality through comparing string representations. Is there really no better way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but unfortunately there is no better way.

frame3 = astshim.Frame(2)
frame3.title = "Frame 3"
frameSet3 = astshim.FrameSet(frame3)
self.assertNotEqual(frameSet1, frameSet3)
Copy link

Choose a reason for hiding this comment

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

You test for the complicated cases, but not the easy ones (where there is no difference between unset and default value). Say: frameSet1 == frameSet1 and astshim.Frame(2) == astshim.Frame(2). Unlikely to fail, but still.

Copy link

Choose a reason for hiding this comment

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

Additionally you may want a test for a more complicated case where multiple attributes are present.

Copy link

Choose a reason for hiding this comment

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

And what happens if say title = "bla#with this? E.g. one of the things in the printed representation has a hash? I don't know if that can happen, but it may be a problem with the string comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a test for two objects with equal attributes. Good suggestion!

I don't think testing frameSet1 against itself is interesting because the fallback is pointer equality.

The attribute containing a hash is a good point, but no longer relevant because I am no longer stripping hash marks.

show2 = obj.show(False).strip()
self.assertTrue(show2.startswith("Begin ZoomMap"))
self.assertNotIn("# Zoom", show2)

Copy link

Choose a reason for hiding this comment

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

What if it does something else? Say insert #zoom or otherwise change the expected test? Isn't it better to explicitly check the expected string for equality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. I'll test for exact strings

Equality is based on the string representation
because AST offers no better way.
@r-owen r-owen merged commit a28931d into master Jul 10, 2017
@ktlim ktlim deleted the tickets/DM-10777 branch August 25, 2018 04:29
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.

None yet

2 participants