[JSC] DFG should respect node's strict flag
[WebKit-https.git] / JSTests / stress / put-by-val-direct-should-respect-strict-mode-of-inlining-codeblock.js
1 //@ runDefault("--useRandomizingFuzzerAgent=1", "--useConcurrentJIT=0")
2
3 let totalFailed = 0;
4
5 function shouldEqual(testId, iteration, actual, expected) {
6     if (actual != expected) {
7         throw new Error("Test #" + testId + ", iteration " + iteration + ", ERROR: expected \"" + expected + "\", got \"" + actual + "\"");
8     }
9 }
10
11 function makeUnwriteableUnconfigurableObject()
12 {
13     return Object.defineProperty([], 0, {value: "frozen", writable: false, configurable: false});
14 }
15
16 function testArrayOf(obj)
17 {
18     Array.of.call(function() { return obj; }, "no longer frozen");
19 }
20
21 noInline(testArrayOf);
22
23 let numIterations = 10000;
24
25 function runTest(testId, test, sourceMaker, expectedException) {
26     for (var i = 0; i < numIterations; i++) {
27         var exception = "No exception";
28         var obj = sourceMaker();
29
30         try {
31             test(obj);
32         } catch (e) {
33             exception = "" + e;
34             exception = exception.substr(0, 10); // Search for "TypeError:".
35         }
36         shouldEqual(testId, i, exception, expectedException);
37     }
38 }
39
40 runTest(1, testArrayOf, makeUnwriteableUnconfigurableObject, "TypeError:");