OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 // The sizes to test. | 86 // The sizes to test. |
87 var sizes = [1, 2, 100, 200, 300]; | 87 var sizes = [1, 2, 100, 200, 300]; |
88 | 88 |
89 // Run the test. | 89 // Run the test. |
90 for (var i = 0; i < sizes.length; i++) { | 90 for (var i = 0; i < sizes.length; i++) { |
91 testLiteral(sizes[i], false); | 91 testLiteral(sizes[i], false); |
92 testLiteral(sizes[i], true); | 92 testLiteral(sizes[i], true); |
93 } | 93 } |
94 | 94 |
| 95 |
| 96 function checkExpectedException(e) { |
| 97 assertInstanceof(e, RangeError); |
| 98 assertTrue(e.message.indexOf("Maximum call stack size exceeded") >= 0); |
| 99 } |
| 100 |
| 101 |
95 function testLiteralAndCatch(size) { | 102 function testLiteralAndCatch(size) { |
96 var big_enough = false; | 103 var big_enough = false; |
97 try { | 104 try { |
98 testLiteral(size, false); | 105 testLiteral(size, false); |
99 } catch (e) { | 106 } catch (e) { |
| 107 checkExpectedException(e); |
100 big_enough = true; | 108 big_enough = true; |
101 } | 109 } |
102 try { | 110 try { |
103 testLiteral(size, true); | 111 testLiteral(size, true); |
104 } catch (e) { | 112 } catch (e) { |
| 113 checkExpectedException(e); |
105 big_enough = true; | 114 big_enough = true; |
106 } | 115 } |
107 return big_enough; | 116 return big_enough; |
108 } | 117 } |
109 | 118 |
110 // Catch stack overflows. | 119 // Catch stack overflows. |
111 | 120 |
112 testLiteralAndCatch(1000) || | 121 testLiteralAndCatch(1000) || |
113 testLiteralAndCatch(20000) || | 122 testLiteralAndCatch(20000) || |
114 testLiteralAndCatch(200000); | 123 testLiteralAndCatch(200000); |
OLD | NEW |