Skip to content

Comments

Verify default compiler in help text matches given default compiler#337

Merged
dlang-bot merged 1 commit intodlang:masterfrom
marler8997:rdmdTestVerifyDefaultCompiler
Mar 20, 2018
Merged

Verify default compiler in help text matches given default compiler#337
dlang-bot merged 1 commit intodlang:masterfrom
marler8997:rdmdTestVerifyDefaultCompiler

Conversation

@marler8997
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

rdmd_test.d Outdated
auto offset = helpText.indexOf(compilerHelpLine);
assert(offset >= 0);
auto compilerInHelp = helpText[offset + compilerHelpLine.length .. $];
compilerInHelp = compilerInHelp[0 .. compilerInHelp.countUntil!isWhite];
Copy link
Member

Choose a reason for hiding this comment

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

Don't mix slicing and countUntil! One counts code units, the other code points. It is always a mistake.

Either use byCodeUnit or just use indexOf (if we know the rest of the string, we should know what kind of whitespace it uses, too).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So is countUntil performing autodecoding?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, countUntil operates on ranges, and strings are auto-decoded when interpreted as ranges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, do "end of line" sequences for WYSIWYG strings change or do they always match the source?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at dmd source, looks like they all normalize to \n

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, countUntil operates on ranges, and strings are auto-decoded when interpreted as ranges.

How odd...this means that indexes into a "string range" will differ from indexes into a "string". I heard about this "autodecoding" confusion before but haven't run into it myself yet...illuminating

@marler8997 marler8997 force-pushed the rdmdTestVerifyDefaultCompiler branch from 2565753 to 0aeb69a Compare March 19, 2018 13:37
auto compilerInHelp = helpText[offset + compilerHelpLine.length .. $];
compilerInHelp = compilerInHelp[0 .. compilerInHelp.indexOf('\n')];
assert(defaultCompiler.baseName == compilerInHelp);
}

Choose a reason for hiding this comment

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

This is a nice additional test, thanks for adding it.

However, if you're thinking that it provides a path to (in future) removing the need for the --rdmd-default-compiler flag ... it won't. See remarks in the earlier PR about why that is.

@dlang-bot dlang-bot merged commit cf1124a into dlang:master Mar 20, 2018
@marler8997 marler8997 deleted the rdmdTestVerifyDefaultCompiler branch September 26, 2019 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants