v8/test/mjsunit/string-trim.js
Mathias Bynens e0e8431d92 [esnext] Implement String.prototype.{trimStart,trimEnd}
Until now, String.prototype.{trimLeft,trimRight} were non-standard
language extensions, required for Web compatibility.

The proposal at https://github.com/tc39/proposal-string-left-right-trim
standardizes this functionality as String.prototype.{trimStart,trimEnd},
and defines String.prototype.{trimLeft,trimRight} as aliases for
backwards compatibility.

This patch implements that proposal behind the --harmony-string-trimming
flag.

Bug: v8:6530
Change-Id: Id21e624c12a79e6b782efb049a48901b9da7db71
Reviewed-on: https://chromium-review.googlesource.com/867044
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50717}
2018-01-19 13:39:46 +00:00

12 lines
497 B
JavaScript

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-string-trimming
assertEquals('trim', String.prototype.trim.name);
assertEquals('trimStart', String.prototype.trimStart.name);
assertEquals('trimStart', String.prototype.trimLeft.name);
assertEquals('trimEnd', String.prototype.trimEnd.name);
assertEquals('trimEnd', String.prototype.trimRight.name);