summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/string-add-try-catch.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/compiler/string-add-try-catch.js')
-rw-r--r--deps/v8/test/mjsunit/compiler/string-add-try-catch.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/compiler/string-add-try-catch.js b/deps/v8/test/mjsunit/compiler/string-add-try-catch.js
index d7a3d2583c..5ae5b00d18 100644
--- a/deps/v8/test/mjsunit/compiler/string-add-try-catch.js
+++ b/deps/v8/test/mjsunit/compiler/string-add-try-catch.js
@@ -4,6 +4,9 @@
// Flags: --allow-natives-syntax
+// Test that string concatenation overflow (going over string max length)
+// is handled gracefully, i.e. an error is thrown
+
var a = "a".repeat(%StringMaxLength());
(function() {
@@ -37,3 +40,57 @@ var a = "a".repeat(%StringMaxLength());
foo("a");
assertInstanceof(foo(a), RangeError);
})();
+
+(function() {
+ function foo(a, b) {
+ try {
+ return "0123456789012".concat(a);
+ } catch (e) {
+ return e;
+ }
+ }
+
+ foo("a");
+ foo("a");
+ %OptimizeFunctionOnNextCall(foo);
+ foo("a");
+ assertInstanceof(foo(a), RangeError);
+})();
+
+var obj = {
+ toString: function() {
+ throw new Error('toString has thrown');
+ }
+};
+
+(function() {
+ function foo(a, b) {
+ try {
+ return "0123456789012" + obj;
+ } catch (e) {
+ return e;
+ }
+ }
+
+ foo("a");
+ foo("a");
+ %OptimizeFunctionOnNextCall(foo);
+ foo("a");
+ assertInstanceof(foo(a), Error);
+})();
+
+(function() {
+ function foo(a, b) {
+ try {
+ return a + 123;
+ } catch (e) {
+ return e;
+ }
+ }
+
+ foo("a");
+ foo("a");
+ %OptimizeFunctionOnNextCall(foo);
+ foo("a");
+ assertInstanceof(foo(a), RangeError);
+})();