OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 function test(length) { | 52 function test(length) { |
53 var str = ""; | 53 var str = ""; |
54 var strLower = ""; | 54 var strLower = ""; |
55 var strUpper = ""; | 55 var strUpper = ""; |
56 for (var i = 0; i < length; i++) { | 56 for (var i = 0; i < length; i++) { |
57 var c = Math.round(0x7f * Math.random()); | 57 var c = Math.round(0x7f * Math.random()); |
58 str += String.fromCharCode(c); | 58 str += String.fromCharCode(c); |
59 strLower += String.fromCharCode(charCodeToLower(c)); | 59 strLower += String.fromCharCode(charCodeToLower(c)); |
60 strUpper += String.fromCharCode(charCodeToUpper(c)); | 60 strUpper += String.fromCharCode(charCodeToUpper(c)); |
61 } | 61 } |
62 %FlattenString(strLower); | 62 str = %FlattenString(str); |
63 %FlattenString(strUpper); | 63 strLower = %FlattenString(strLower); |
| 64 strUpper = %FlattenString(strUpper); |
64 // Sequential string. | 65 // Sequential string. |
65 assertEquals(strLower, str.toLowerCase()); | 66 assertEquals(strLower, str.toLowerCase()); |
66 assertEquals(strUpper, str.toUpperCase()); | 67 assertEquals(strUpper, str.toUpperCase()); |
67 // Cons string. | 68 // Cons string. |
68 assertEquals(strLower + strLower, (str + str).toLowerCase()); | 69 assertEquals(strLower + strLower, (str + str).toLowerCase()); |
69 assertEquals(strUpper + strUpper, (str + str).toUpperCase()); | 70 assertEquals(strUpper + strUpper, (str + str).toUpperCase()); |
70 // Sliced string. | 71 // Sliced string. |
71 assertEquals(strLower.substring(1), str.substring(1).toLowerCase()); | 72 assertEquals(strLower.substring(1), str.substring(1).toLowerCase()); |
72 assertEquals(strUpper.substring(1), str.substring(1).toUpperCase()); | 73 assertEquals(strUpper.substring(1), str.substring(1).toUpperCase()); |
73 // External string. | 74 // External string. |
74 externalizeString(str, false); | 75 externalizeString(str, false); |
75 assertEquals(strLower, str.toLowerCase()); | 76 assertEquals(strLower, str.toLowerCase()); |
76 assertEquals(strUpper, str.toUpperCase()); | 77 assertEquals(strUpper, str.toUpperCase()); |
77 } | 78 } |
78 | 79 |
79 for (var i = 1; i <= 128; i <<= 1); { | 80 for (var i = 1; i <= 128; i <<= 1); { |
80 for (var j = 0; j < 8; j++) { | 81 for (var j = 0; j < 8; j++) { |
81 for (var k = 0; k < 3; k++) { | 82 for (var k = 0; k < 3; k++) { |
82 test(i + j); | 83 test(i + j); |
83 } | 84 } |
84 } | 85 } |
85 } | 86 } |
OLD | NEW |