1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/strict/10.6.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 + 1.6 +/* 1.7 + * Any copyright is dedicated to the Public Domain. 1.8 + * http://creativecommons.org/licenses/publicdomain/ 1.9 + */ 1.10 + 1.11 +function callFunctionBody(expr) { 1.12 + return ( 1.13 + '(function f() {\n' 1.14 + + 'Object.defineProperties(arguments, {1: { writable: false },\n' 1.15 + + ' 2: { configurable: false },\n' 1.16 + + ' 3: { writable: false,\n' 1.17 + + ' configurable: false }});\n' 1.18 + + 'return (' + expr + ');\n' 1.19 + + '})(0, 1, 2, 3);'); 1.20 +} 1.21 + 1.22 +assertEq(testLenientAndStrict(callFunctionBody('arguments[0] = 42'), 1.23 + returns(42), returns(42)), 1.24 + true); 1.25 + 1.26 +assertEq(testLenientAndStrict(callFunctionBody('delete arguments[0]'), 1.27 + returns(true), returns(true)), 1.28 + true); 1.29 + 1.30 + 1.31 +assertEq(testLenientAndStrict(callFunctionBody('arguments[1] = 42'), 1.32 + returns(42), raisesException(TypeError)), 1.33 + true); 1.34 + 1.35 +assertEq(testLenientAndStrict(callFunctionBody('delete arguments[1]'), 1.36 + returns(true), returns(true)), 1.37 + true); 1.38 + 1.39 + 1.40 +assertEq(testLenientAndStrict(callFunctionBody('arguments[2] = 42'), 1.41 + returns(42), returns(42)), 1.42 + true); 1.43 + 1.44 +assertEq(testLenientAndStrict(callFunctionBody('delete arguments[2]'), 1.45 + returns(false), raisesException(TypeError)), 1.46 + true); 1.47 + 1.48 + 1.49 +assertEq(testLenientAndStrict(callFunctionBody('arguments[3] = 42'), 1.50 + returns(42), raisesException(TypeError)), 1.51 + true); 1.52 + 1.53 +assertEq(testLenientAndStrict(callFunctionBody('delete arguments[3]'), 1.54 + returns(false), raisesException(TypeError)), 1.55 + true); 1.56 + 1.57 + 1.58 +reportCompare(true, true);