mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
11 years ago
1 changed files with 37 additions and 0 deletions
@ -0,0 +1,37 @@ |
|||
/*=== |
|||
10 x |
|||
10 y |
|||
100000 x |
|||
100000 y |
|||
===*/ |
|||
|
|||
/* String repeat can be implemented with an array join. */ |
|||
|
|||
function dump(x) { |
|||
var ch = '?' |
|||
if (x.length > 0) { |
|||
ch = x.charAt(0); |
|||
for (var i = 0; i < x.length; i++) { |
|||
if (x.charAt(i) !== ch) { |
|||
throw new Error('error in string'); |
|||
} |
|||
} |
|||
} |
|||
print(x.length, ch); |
|||
} |
|||
|
|||
try { |
|||
dump(Array.prototype.join.call({ length: 10 + 1 }, 'x')); |
|||
var arr = []; arr.length = 10 + 1; |
|||
dump(arr.join('y')); |
|||
} catch (e) { |
|||
print(e); |
|||
} |
|||
|
|||
try { |
|||
dump(Array.prototype.join.call({ length: 100000 + 1 }, 'x')); |
|||
var arr = []; arr.length = 100000 + 1; |
|||
dump(arr.join('y')); |
|||
} catch (e) { |
|||
print(e); |
|||
} |
Loading…
Reference in new issue