1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15function f() { 16 return 'foo'; 17} 18assert ((function() { 19 if (1 === 1) { 20 function f() { 21 return 'bar'; 22 } 23 } 24 return f(); 25})() === 'bar'); 26 27function check_syntax_error (s) { 28 try { 29 eval (s); 30 assert (false); 31 } 32 catch (e) { 33 assert (e instanceof SyntaxError); 34 } 35} 36 37check_syntax_error ("'use strict'; function arguments () {}"); 38check_syntax_error ("'use strict'; var l = function arguments () {}"); 39 40check_syntax_error ("function f__strict_mode_duplicate_parameters (p, p) { 'use strict'; }"); 41 42function test_strict_mode_propagation_in_func_expr_and_getters_setters () { 43 var p = function () { 44 'use strict'; 45 46 return true; 47 } 48 49 var o = { get prop () { 'use strict'; return true; }, set prop (v) { 'use strict'; } }; 50 51 function test () { 52 tmp_eval = eval; 53 eval = tmp_eval; 54 } 55} 56