Debian Codegraph @

rhino/testsrc/doctests/string.trim.doctest

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 js> load('testsrc/doctests/util.js');
6
7 js> String.prototype.trim;
8 function trim() { [native code for String.trim, arity=0] }
9
10 js> String.prototype.trim.call({toString: function() { return "a" }});
11 a
12
13 js> " hello ".trim() === "hello";
14 true
15
16 js> var chr = String.fromCharCode;
17 js> var str = "" +
18 > // ecma whitespace
19 > chr(0x0009) + chr(0x000B) + chr(0x000C) + chr(0x0020) + chr(0x00A0) + chr(0xFEFF) +
20 > // unicode whitespace
21 > chr(0x1680) + chr(0x180E) +
22 > chr(0x2000) + chr(0x2001) + chr(0x2002) + chr(0x2003) + chr(0x2004) + chr(0x2005) + chr(0x2006) + chr(0x2007) + chr(0x2008) + chr(0x2009) + chr(0x200A) +
23 > chr(0x202F) + chr(0x205F) + chr(0x3000) +
24 > // ecma line terminators
25 > chr(0x000A) + chr(0x000D) + chr(0x2028) + chr(0x2029) +
26 >
27 > "abc";
28 js> str.trim() === "abc";
29 true