|
1 // Binary: cache/js-opt-32-2dc40eb83023-linux |
|
2 // Flags: -m -n -a |
|
3 // |
|
4 function toPrinted(value) |
|
5 value = value.replace(/\\n/g, 'NL') |
|
6 .replace(/\\r/g, 'CR') |
|
7 .replace(/[^\x20-\x7E]+/g, escapeString); |
|
8 function escapeString (str) |
|
9 { |
|
10 var a, b, c, d; |
|
11 var len = str.length; |
|
12 var result = ""; |
|
13 var digits = ["0", "1", "2", "3", "4", "5", "6", "7", |
|
14 "8", "9", "A", "B", "C", "D", "E", "F"]; |
|
15 for (var i=0; i<len; i++) |
|
16 { |
|
17 var ch = str.charCodeAt(i); |
|
18 a = digits[ch & 0xf]; |
|
19 if (ch) |
|
20 { |
|
21 c = digits[ch & 0xf]; |
|
22 ch >>= 4; |
|
23 d = digits[ch & 0xf]; |
|
24 result += "\\u" + d + c + b + a; |
|
25 } |
|
26 } |
|
27 } |
|
28 function reportCompare (expected, actual, description) { |
|
29 function test() { |
|
30 try |
|
31 { |
|
32 } |
|
33 catch(e) |
|
34 { |
|
35 } |
|
36 } |
|
37 } |
|
38 try { |
|
39 gczeal(2,4); |
|
40 function setprop() { |
|
41 } |
|
42 } catch(exc1) {} |
|
43 var trimMethods = ['trim', 'trimLeft', 'trimRight']; |
|
44 var whitespace = [ |
|
45 {s : '\u2028', t : 'LINE SEPARATOR'}, |
|
46 ]; |
|
47 for (var j = 0; j < trimMethods.length; ++j) |
|
48 { |
|
49 var method = trimMethods[j]; |
|
50 for (var i = 0; i < whitespace.length; ++i) |
|
51 { |
|
52 var v = whitespace[i].s; |
|
53 var t = whitespace[i].t; |
|
54 v = v + v + v; |
|
55 str = v; |
|
56 expected = ''; |
|
57 actual = str[method](); |
|
58 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()'); |
|
59 } |
|
60 } |