2013-06-27 20:02:04 +00:00
|
|
|
|
# Copyright 2013 the V8 project authors. All rights reserved.
|
|
|
|
|
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
|
# are met:
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
|
#
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
|
|
|
|
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
|
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
2018-01-19 13:05:01 +00:00
|
|
|
|
This test checks the `trim`, `trimStart`/`trimLeft`, and `trimEnd`/`trimRight` methods on `String.prototype`.
|
2013-06-27 20:02:04 +00:00
|
|
|
|
|
|
|
|
|
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PASS whitespace[0].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[0].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[0].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[0].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[0].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[1].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[1].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[1].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[1].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[1].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[2].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[2].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[2].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[2].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[2].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[3].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[3].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[3].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[3].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[3].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[4].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[4].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[4].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[4].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[4].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[5].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[5].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[5].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[5].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[5].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[6].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[6].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[6].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[6].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[6].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[7].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[7].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[7].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[7].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[7].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[8].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[8].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[8].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[8].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[8].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[9].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[9].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[9].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[9].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[9].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[10].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[10].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[10].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[10].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[10].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[11].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[11].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[11].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[11].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[11].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[12].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[12].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[12].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[12].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[12].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[13].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[13].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[13].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[13].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[13].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[14].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[14].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[14].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[14].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[14].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[15].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[15].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[15].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[15].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[15].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[16].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[16].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[16].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[16].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[16].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[17].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[17].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[17].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[17].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[17].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[18].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[18].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[18].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[18].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[18].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[19].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[19].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[19].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[19].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[19].s.trimRight() is ''
|
|
|
|
|
PASS whitespace[20].s.trim() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[20].s.trimStart() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[20].s.trimLeft() is ''
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS whitespace[20].s.trimEnd() is ''
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS whitespace[20].s.trimRight() is ''
|
2014-02-10 12:43:10 +00:00
|
|
|
|
FAIL whitespace[21].s.trim() should be . Was .
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL whitespace[21].s.trimStart() should be . Was .
|
2014-02-10 12:43:10 +00:00
|
|
|
|
FAIL whitespace[21].s.trimLeft() should be . Was .
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL whitespace[21].s.trimEnd() should be . Was .
|
2014-02-10 12:43:10 +00:00
|
|
|
|
FAIL whitespace[21].s.trimRight() should be . Was .
|
|
|
|
|
FAIL wsString.trim() should be . Was .
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL wsString.trimStart() should be . Was .
|
2014-02-10 12:43:10 +00:00
|
|
|
|
FAIL wsString.trimLeft() should be . Was .
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL wsString.trimEnd() should be . Was
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
|
|
|
|
.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL wsString.trimRight() should be . Was
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
|
|
|
|
.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL trimString.trim() should be foo bar. Was foo bar
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
2018-01-19 13:05:01 +00:00
|
|
|
|
.
|
|
|
|
|
FAIL trimString.trimStart() should be foo bar
|
|
|
|
|
|
|
|
|
|
. Was foo bar
|
|
|
|
|
|
|
|
|
|
.
|
|
|
|
|
FAIL trimString.trimLeft() should be foo bar
|
|
|
|
|
|
|
|
|
|
. Was foo bar
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
|
|
|
|
.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL trimString.trimEnd() should be
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
2018-01-19 13:05:01 +00:00
|
|
|
|
foo bar. Was
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
2018-01-19 13:05:01 +00:00
|
|
|
|
foo bar
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
|
|
|
|
.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL trimString.trimRight() should be
|
|
|
|
|
|
|
|
|
|
foo bar. Was
|
|
|
|
|
|
|
|
|
|
foo bar
|
|
|
|
|
|
|
|
|
|
.
|
|
|
|
|
FAIL leftTrimString.trim() should be foo bar. Was foo bar
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
|
|
|
|
.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS leftTrimString.trimStart() is leftTrimString
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS leftTrimString.trimLeft() is leftTrimString
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL leftTrimString.trimEnd() should be foo bar. Was foo bar
|
|
|
|
|
|
|
|
|
|
.
|
|
|
|
|
FAIL leftTrimString.trimRight() should be foo bar. Was foo bar
|
2014-02-10 12:43:10 +00:00
|
|
|
|
|
|
|
|
|
.
|
|
|
|
|
FAIL rightTrimString.trim() should be foo bar. Was foo bar.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
FAIL rightTrimString.trimStart() should be foo bar. Was foo bar.
|
2014-02-10 12:43:10 +00:00
|
|
|
|
FAIL rightTrimString.trimLeft() should be foo bar. Was foo bar.
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS rightTrimString.trimEnd() is rightTrimString
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS rightTrimString.trimRight() is rightTrimString
|
|
|
|
|
PASS trim.call(0) is '0'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(0) is '0'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(0) is '0'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(0) is '0'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(0) is '0'
|
|
|
|
|
PASS trim.call(Infinity) is 'Infinity'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(Infinity) is 'Infinity'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(Infinity) is 'Infinity'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(Infinity) is 'Infinity'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(Infinity) is 'Infinity'
|
|
|
|
|
PASS trim.call(NaN) is 'NaN'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(NaN) is 'NaN'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(NaN) is 'NaN'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(NaN) is 'NaN'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(NaN) is 'NaN'
|
|
|
|
|
PASS trim.call(true) is 'true'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(true) is 'true'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(true) is 'true'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(true) is 'true'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(true) is 'true'
|
|
|
|
|
PASS trim.call(false) is 'false'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(false) is 'false'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(false) is 'false'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(false) is 'false'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(false) is 'false'
|
|
|
|
|
PASS trim.call(({})) is '[object Object]'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(({})) is '[object Object]'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(({})) is '[object Object]'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(({})) is '[object Object]'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(({})) is '[object Object]'
|
|
|
|
|
PASS trim.call(({toString:function(){return 'wibble'}})) is 'wibble'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(({toString:function(){return 'wibble'}})) is 'wibble'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(({toString:function(){return 'wibble'}})) is 'wibble'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(({toString:function(){return 'wibble'}})) is 'wibble'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(({toString:function(){return 'wibble'}})) is 'wibble'
|
|
|
|
|
PASS trim.call(['an','array']) is 'an,array'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimStart.call(['an','array']) is 'an,array'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimLeft.call(['an','array']) is 'an,array'
|
2018-01-19 13:05:01 +00:00
|
|
|
|
PASS trimEnd.call(['an','array']) is 'an,array'
|
2013-06-27 20:02:04 +00:00
|
|
|
|
PASS trimRight.call(['an','array']) is 'an,array'
|
|
|
|
|
PASS successfullyParsed is true
|
|
|
|
|
|
|
|
|
|
TEST COMPLETE
|
|
|
|
|
|