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 check_syntax_error (s) { 16 try { 17 eval (s); 18 assert (false); 19 } catch (e) { 20 assert (e instanceof SyntaxError); 21 } 22} 23 24/* Test case #1 */ 25check_syntax_error ( 26" new function f(f) { \ 27 return {className: 'xxx'}; \ 28}; \ 29x = 1; \ 30function g(active) { \ 31 for (i = 1; i <= 1000; i++) { if (i == active) { \ 32 x = i; if (f(\"\" + i) != null) { } \ 33 } else { \ 34 if (f(\"\" + i) != null) } \ 35 } \ 36} \ 37g(0) \ 38"); 39 40/* Test case #2 */ 41check_syntax_error ( 42" new function a(a) {;for (f in [1,2,3]) print(f); \ 43}; 1; \ 44function g(active) { \ 45 for (i = 1; i <= 1000; i++) { if (i == active) { \ 46 xI \ 47 if (f != null) { } \ 48 } else { \ 49 if (f(\"\" + i) != null) } \ 50 } \ 51} \ 52g(0) \ 53"); 54 55/* Test case #3 */ 56check_syntax_error ( 57" new function f(f) {;for (f in [1,2,3]) pRint(f); \ 58}; 1; \ 59function g(active) { \ 60 for (i = 1; i <= 1000; i++) { if (i == active) { \ 61 x \ 62 if (f != null) { } \ 63 } else { \ 64 if (f(\"\" + i) != null) } \ 65 } \ 66} \ 67g(0) \ 68"); 69