1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/strict/12.10.1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 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 +/* 1.12 + * 'with' statements are forbidden in strict top-level code. This is 1.13 + * eval code, but that's close enough. 1.14 + */ 1.15 +assertEq(testLenientAndStrict('with (1) {}', 1.16 + completesNormally, 1.17 + raisesException(SyntaxError)), 1.18 + true); 1.19 + 1.20 +/* 'with' statements are forbidden in strict function code. */ 1.21 +assertEq(testLenientAndStrict('function f() { "use strict"; with (1) {} }', 1.22 + parseRaisesException(SyntaxError), 1.23 + parseRaisesException(SyntaxError)), 1.24 + true); 1.25 + 1.26 +/* 1.27 + * A use strict directive in a function mustn't affect the strictness 1.28 + * of subsequent code. 1.29 + */ 1.30 +assertEq(parsesSuccessfully('function f() { "use strict"; }; with (1) {}'), 1.31 + true); 1.32 + 1.33 +reportCompare(true, true);