blob: a58122286852d2a4370449ef0c1e683c6593e65e [file] [log] [blame]
msaboff@apple.comfb3ba9f2019-07-06 13:34:51 +00001//@ requireOptions("--jitPolicyScale=0", "--useConcurrentJIT=0")
2// This tests that when a switch(String) converts the String argument, it properly handles OOM
3
4function test(createOOMString)
5{
6 var str = String.fromCharCode(365);
7 if (createOOMString)
8 str = str.padEnd(2147483644, '123');
9
10 switch (str) {
11 case "one":
12 throw "Case \"one\", dhouldn't get here";
13 break;
14 case "two":
15 throw "Case \"two\", shouldn't get here";
16 break;
17 case "three":
18 throw "Case \"three\", shouldn't get here";
19 break;
20 default:
21 if (createOOMString)
22 throw "Default case, shouldn't get here";
23 break;
24 }
25}
26
27function testLowerTiers()
28{
29 for (let i = 0; i < 200; i++) {
30 try {
31 test(true);
32 } catch(e) {
33 if (e != "Error: Out of memory")
34 throw "Unexpecte error: \"" + e + "\"";
35 }
36 }
37}
38
39function testFTL()
40{
41 for (let i = 0; i < 1000; i++) {
42 try {
43 test(i >= 50);
44 } catch(e) {
45 if (e != "Error: Out of memory")
46 throw "Unexpecte error: \"" + e + "\"";
47 }
48 }
49}
50
51testLowerTiers();
52testFTL();