|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 |
|
3 /* |
|
4 * Any copyright is dedicated to the Public Domain. |
|
5 * http://creativecommons.org/licenses/publicdomain/ |
|
6 */ |
|
7 |
|
8 function callFunctionBody(expr) { |
|
9 return ( |
|
10 '(function f() {\n' |
|
11 + 'Object.defineProperties(arguments, {1: { writable: false },\n' |
|
12 + ' 2: { configurable: false },\n' |
|
13 + ' 3: { writable: false,\n' |
|
14 + ' configurable: false }});\n' |
|
15 + 'return (' + expr + ');\n' |
|
16 + '})(0, 1, 2, 3);'); |
|
17 } |
|
18 |
|
19 assertEq(testLenientAndStrict(callFunctionBody('arguments[0] = 42'), |
|
20 returns(42), returns(42)), |
|
21 true); |
|
22 |
|
23 assertEq(testLenientAndStrict(callFunctionBody('delete arguments[0]'), |
|
24 returns(true), returns(true)), |
|
25 true); |
|
26 |
|
27 |
|
28 assertEq(testLenientAndStrict(callFunctionBody('arguments[1] = 42'), |
|
29 returns(42), raisesException(TypeError)), |
|
30 true); |
|
31 |
|
32 assertEq(testLenientAndStrict(callFunctionBody('delete arguments[1]'), |
|
33 returns(true), returns(true)), |
|
34 true); |
|
35 |
|
36 |
|
37 assertEq(testLenientAndStrict(callFunctionBody('arguments[2] = 42'), |
|
38 returns(42), returns(42)), |
|
39 true); |
|
40 |
|
41 assertEq(testLenientAndStrict(callFunctionBody('delete arguments[2]'), |
|
42 returns(false), raisesException(TypeError)), |
|
43 true); |
|
44 |
|
45 |
|
46 assertEq(testLenientAndStrict(callFunctionBody('arguments[3] = 42'), |
|
47 returns(42), raisesException(TypeError)), |
|
48 true); |
|
49 |
|
50 assertEq(testLenientAndStrict(callFunctionBody('delete arguments[3]'), |
|
51 returns(false), raisesException(TypeError)), |
|
52 true); |
|
53 |
|
54 |
|
55 reportCompare(true, true); |