Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Issue 1042523004: Add a test for trimming leading whitespace in multiline strings (Closed)

Created:
5 years, 9 months ago by Brian Wilkerson
Modified:
5 years, 8 months ago
Reviewers:
Paul Berry, gbracha, hausner
CC:
reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add a test for trimming leading whitespace in multiline strings R=paulberry@google.com Committed: https://code.google.com/p/dart/source/detail?r=44755

Patch Set 1 #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -0 lines) Patch
M tests/language/language.status View 1 chunk +1 line, -0 lines 0 comments Download
A tests/language/multiline_strings_test.dart View 1 chunk +44 lines, -0 lines 5 comments Download

Messages

Total messages: 11 (3 generated)
Brian Wilkerson
5 years, 9 months ago (2015-03-27 18:47:07 UTC) #2
Paul Berry
lgtm
5 years, 9 months ago (2015-03-27 19:12:58 UTC) #3
Brian Wilkerson
Committed patchset #1 (id:1) manually as 44755 (presubmit successful).
5 years, 9 months ago (2015-03-27 19:28:23 UTC) #4
hausner
This test is wrong in my opinion. https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_strings_test.dart File tests/language/multiline_strings_test.dart (right): https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_strings_test.dart#newcode11 tests/language/multiline_strings_test.dart:11: Expect.equals('\\\nfoo', '''\\ ...
5 years, 8 months ago (2015-03-31 22:15:36 UTC) #6
hausner
Correction. https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_strings_test.dart File tests/language/multiline_strings_test.dart (right): https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_strings_test.dart#newcode11 tests/language/multiline_strings_test.dart:11: Expect.equals('\\\nfoo', '''\\ On 2015/03/31 22:15:36, hausner wrote: > ...
5 years, 8 months ago (2015-03-31 22:33:05 UTC) #7
Paul Berry
https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_strings_test.dart File tests/language/multiline_strings_test.dart (right): https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_strings_test.dart#newcode15 tests/language/multiline_strings_test.dart:15: foo'''); On 2015/03/31 22:33:04, hausner wrote: > This multiline ...
5 years, 8 months ago (2015-03-31 23:33:03 UTC) #8
hausner
I spoke to Gilad about this today, but please reassign the bug you filed against ...
5 years, 8 months ago (2015-04-01 00:13:57 UTC) #9
gbracha
5 years, 8 months ago (2015-04-02 19:25:58 UTC) #11
Message was sent while issue was closed.
Belatedly publishing my comments. Will update bug accordingly.

https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_st...
File tests/language/multiline_strings_test.dart (right):

https://codereview.chromium.org/1042523004/diff/1/tests/language/multiline_st...
tests/language/multiline_strings_test.dart:15: foo''');
On 2015/03/31 23:33:03, Paul Berry wrote:
> On 2015/03/31 22:33:04, hausner wrote:
> > This multiline string should be equal to 'foo', since the first line only
> > contains whitespace (a tab) before the newline.
> 
> The relevant spec text is: "If the first line of a multiline string consists
> solely of the whitespace characters defined by the production WHITESPACE,
> possibly prefixed by \, then that line is ignored, including the new line at
its
> end".
> 
> It isn't manifestly stated in the spec text whether it's referring to the raw
> uninterpreted characters of the string as they appear in the source file, or
the
> characters that result after escape sequences have been interpreted.  But we
> have to choose one interpretation and use it consistently, and reading between
> the lines, I think it's pretty clear that the intention was to refer to the
raw
> uninterpreted characters.  (If the intention had been to refer to the
characters
> that result after escape sequences have been interpreted, then there would
have
> been no need for the phrase "possibly prefixed by \"; in fact, the presence of
> this phrase would cause even "\\ " to be trimmed, which matches neither VM nor
> Dart2js behavior, and which I think would be very unexpected.)  So under my
> interpretation, Brian's test is correct--"\t" should not be trimmed from the
> string, because "t" is not a whitespace character.
> 
> Should we ask Gilad to weigh in?

The idea was (I believe) to ignore invisible stuff people may have typed after
the opening of the string.  Maybe we should have left it at that, but someone
noted that say, tab and \ followed by tab were the same. But the argument would
apply to \t. It is also much easier to understand that way.

The wording should be clarified, but basically, if it *any* kind of whitespace,
you ignore it. So while Paul and Brian's interpretation is sensible vis-a-vis
the wording, I don't think an ordinary human would expect such subtlety.

In any case, at some point it would make sense to reword the spec. since it
seems insufficient verbiage was dedicated to this weighty topic.

Powered by Google App Engine
This is Rietveld 408576698