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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 last = z; | 145 last = z; |
146 cache.push(z); | 146 cache.push(z); |
147 offset += i; | 147 offset += i; |
148 } | 148 } |
149 for (var i = 63; i >= 0; i--) { | 149 for (var i = 63; i >= 0; i--) { |
150 var z = cache.pop(); | 150 var z = cache.pop(); |
151 assertTrue(/\u2028123456789ABCDEF/.test(z)); | 151 assertTrue(/\u2028123456789ABCDEF/.test(z)); |
152 assertEquals(xl - offset, z.length); | 152 assertEquals(xl - offset, z.length); |
153 offset -= i; | 153 offset -= i; |
154 } | 154 } |
| 155 |
| 156 |
| 157 // Order of conversions. |
| 158 { |
| 159 let log = []; |
| 160 let string = {[Symbol.toPrimitive]() { log.push("this"); return "abc" }}; |
| 161 let start = {[Symbol.toPrimitive]() { log.push("start"); return 0 }}; |
| 162 let length = {[Symbol.toPrimitive]() { log.push("length"); return 1 }}; |
| 163 assertEquals("a", String.prototype.substr.call(string, start, length)); |
| 164 assertEquals(["this", "start", "length"], log); |
| 165 } |
| 166 { |
| 167 let log = []; |
| 168 let string = {[Symbol.toPrimitive]() { log.push("this"); return "abc" }}; |
| 169 let start = {[Symbol.toPrimitive]() { log.push("start"); return 0 }}; |
| 170 let length = {[Symbol.toPrimitive]() { log.push("length"); return 0 }}; |
| 171 assertEquals("", String.prototype.substr.call(string, start, length)); |
| 172 assertEquals(["this", "start", "length"], log); |
| 173 } |
OLD | NEW |