File: string.trim.doctest

package info (click to toggle)
htmlunit-core-js 2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 5,804 kB
  • ctags: 10,088
  • sloc: java: 75,059; xml: 889; sh: 14; makefile: 11
file content (25 lines) | stat: -rw-r--r-- 825 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
js> load('testsrc/doctests/util.js');

js> String.prototype.trim;
function trim() { [native code for String.trim, arity=0] }

js> String.prototype.trim.call({toString: function() { return "a" }});
a

js> "  hello ".trim() === "hello";
true

js> var chr = String.fromCharCode;
js> var str = "" +
  >   // ecma whitespace
  >   chr(0x0009) + chr(0x000B) + chr(0x000C) + chr(0x0020) + chr(0x00A0) + chr(0xFEFF) + 
  >   // unicode whitespace
  >   chr(0x1680) + chr(0x180E) + 
  >   chr(0x2000) + chr(0x2001) + chr(0x2002) + chr(0x2003) + chr(0x2004) + chr(0x2005) + chr(0x2006) + chr(0x2007) + chr(0x2008) + chr(0x2009) + chr(0x200A) + 
  >   chr(0x202F) + chr(0x205F) + chr(0x3000) + 
  >   // ecma line terminators
  >   chr(0x000A) + chr(0x000D) + chr(0x2028) + chr(0x2029) +
  >
  >   "abc";
js> str.trim() === "abc";
true