blob: a78b742428889c48a68221e9d80b1efa0b660e3f [file] [log] [blame]
ggaren@apple.com38bea922008-06-02 16:30:10 +00001<p>This test verifies that an exception thrown during array sort immediately ends execution.</p>
2<p>If the test passes, you'll see a pass message below.</p>
3
4<pre id="console">FAIL: Exception did not propogate from array sort.</pre>
5
6<script>
7function log(s)
8{
9 document.getElementById("console").innerHTML = s + "\n";
10}
11
rniwa@webkit.org03b9c6d2012-07-16 01:41:53 +000012if (window.testRunner)
13 testRunner.dumpAsText();
ggaren@apple.com38bea922008-06-02 16:30:10 +000014
15var passed = true;
16
17var array = [ 1, 2, 3 ];
18var sortFunction = (function () {
19 var alreadyCalled = false;
20 return function (a, b)
21 {
22 if (alreadyCalled)
23 passed = false;
24
25 alreadyCalled = true;
26 throw 'threw';
27 };
28})();
29
30try {
31 array.sort(sortFunction);
32} catch(e) {
33 var result = passed ? "PASS"
34 : "FAIL: sort function was called after an exception was thrown"
35 log (result);
36}
37</script>