Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: test/mjsunit/es6/string-repeat.js

Issue 1454543003: [es6] Allow any valid repeat of empty string in String.prototype.repeat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/string.js ('k') | test/test262/test262.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 assertEquals("", "".repeat(5)); 58 assertEquals("", "".repeat(5));
59 assertEquals("", "abc".repeat(0)); 59 assertEquals("", "abc".repeat(0));
60 assertEquals("abcabc", "abc".repeat(2.0)); 60 assertEquals("abcabc", "abc".repeat(2.0));
61 61
62 assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "a".repeat(37)); 62 assertEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "a".repeat(37));
63 assertThrows('"a".repeat(-1)', RangeError); 63 assertThrows('"a".repeat(-1)', RangeError);
64 assertThrows('"a".repeat(Number.POSITIVE_INFINITY)', RangeError); 64 assertThrows('"a".repeat(Number.POSITIVE_INFINITY)', RangeError);
65 assertThrows('"a".repeat(Math.pow(2, 30))', RangeError); 65 assertThrows('"a".repeat(Math.pow(2, 30))', RangeError);
66 assertThrows('"a".repeat(Math.pow(2, 40))', RangeError); 66 assertThrows('"a".repeat(Math.pow(2, 40))', RangeError);
67 67
68 // Handling empty strings
69 assertThrows('"".repeat(-1)', RangeError);
70 assertThrows('"".repeat(Number.POSITIVE_INFINITY)', RangeError);
71 assertEquals("", "".repeat(Math.pow(2, 30)));
72 assertEquals("", "".repeat(Math.pow(2, 40)));
73
68 var myobj = { 74 var myobj = {
69 toString: function() { 75 toString: function() {
70 return "abc"; 76 return "abc";
71 }, 77 },
72 repeat : String.prototype.repeat 78 repeat : String.prototype.repeat
73 }; 79 };
74 assertEquals("abc", myobj.repeat(1)); 80 assertEquals("abc", myobj.repeat(1));
75 assertEquals("abcabc", myobj.repeat(2)); 81 assertEquals("abcabc", myobj.repeat(2));
OLDNEW
« no previous file with comments | « src/js/string.js ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698