Files
sdk/tests/corelib/string_trim_nel_test.dart
T
Robert Nystrom 0906af6d2f Reformat tests/corelib/.
I also regenerated the static error expectations (see #57042 for
context).

Change-Id: Ia0ca22604a0dd422cc265a46845afc43f551fe38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394572
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2024-11-14 13:04:51 +00:00

39 lines
1.3 KiB
Dart

// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// NEXT LINE (NEL, 0x85) character is special in that some Unicode versions do
// not include it as a whitespace character.
//
// However all Dart backends handle it as a whitespace character. dart2js and
// dart2wasm do this by a calling JS (`String.prototype.trim` and its
// left/right variants) and doing post-processing. To check these
// implementations tests in this file mix the SPACE character with NEL in
// various positions.
//
// string_trim_lr_test.dart tests various NEL characters on the left and right,
// but they do not mix NEL with other whitespace characters.
// string_trim_test.dart tests do not test NEL.
import "package:expect/expect.dart";
const int space = 0x20;
const int nel = 0x85;
const int h = 0x68;
const int i = 0x69;
void main() {
Expect.equals(
"hi",
String.fromCharCodes([space, nel, space, h, i]).trimLeft(),
);
Expect.equals(
"hi",
String.fromCharCodes([h, i, space, nel, space]).trimRight(),
);
Expect.equals(
"hi",
String.fromCharCodes([space, nel, space, h, i, space, nel, space]).trim(),
);
}