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 15var t; 16 17t = /\//.exec("/"); 18assert (t == "/"); 19 20t = /[/]/.exec("/"); 21assert ("a"+/x/+"b" == "a/x/b"); 22 23t = /\/\[[\]/]/.exec("/[/"); 24assert (t == "/[/"); 25 26t = /\u0000/.exec("\u0000"); 27assert (t == "\u0000"); 28 29try { 30 eval("/" + String.fromCharCode("0x0000") + "/"); 31} catch (e) { 32 assert (false); 33} 34 35try { 36 eval("var x = 5\n\n/foo/"); 37 assert(false); 38} catch (e) { 39 assert(e instanceof SyntaxError); 40} 41 42try { 43 eval("var x = 5;\n\n/foo/"); 44} catch (e) { 45 assert(false); 46} 47 48try { 49 eval("for (;false;/abc/.exec(\"abc\")) {5}"); 50} catch (e) { 51 assert(false); 52} 53 54try { 55 eval("var a = [] /foo/"); 56 assert(false); 57} catch (e) { 58 assert(e instanceof SyntaxError); 59} 60 61try { 62 eval("/"); 63 assert(false); 64} catch (e) { 65 assert(e instanceof SyntaxError); 66} 67 68try { 69 eval("var x = /aaa/"); 70} catch (e) { 71 assert (false); 72} 73 74try { 75 eval("{}/a/g"); 76} catch (e) { 77 assert (false); 78} 79 80try { 81 eval("var a, g; +{}/a/g"); 82} catch (e) { 83 assert (false); 84} 85