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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 var c = String.fromCharCode(i); | 159 var c = String.fromCharCode(i); |
160 alpha[i] = c[0]; | 160 alpha[i] = c[0]; |
161 } | 161 } |
162 var alphaStr = alpha.join(""); | 162 var alphaStr = alpha.join(""); |
163 | 163 |
164 // Now test chars. | 164 // Now test chars. |
165 for (var i = 1; i < 128; i++) { | 165 for (var i = 1; i < 128; i++) { |
166 assertEquals(alpha[i], alphaStr[i]); | 166 assertEquals(alpha[i], alphaStr[i]); |
167 assertEquals(String.fromCharCode(i), alphaStr[i]); | 167 assertEquals(String.fromCharCode(i), alphaStr[i]); |
168 } | 168 } |
| 169 |
| 170 // Test for keyed ic. |
| 171 var foo = ['a12', ['a', 2, 'c'], 'a31', 42]; |
| 172 var results = [1, 2, 3, NaN]; |
| 173 for (var i = 0; i < 200; ++i) { |
| 174 var index = Math.floor(i / 50); |
| 175 var receiver = foo[index]; |
| 176 var expected = results[index]; |
| 177 var actual = +(receiver[1]); |
| 178 assertEquals(expected, actual); |
| 179 } |
| 180 |
| 181 var keys = [0, '1', 2, 3.0]; |
| 182 var str = 'abcd', arr = ['a', 'b', 'c', 'd']; |
| 183 for (var i = 0; i < 200; ++i) { |
| 184 var index = Math.floor(i / 50); |
| 185 var key = keys[index]; |
| 186 var expected = arr[index]; |
| 187 var actual = str[key]; |
| 188 assertEquals(expected, actual); |
| 189 } |
OLD | NEW |