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 r = RegExp ("a","gim"); 16var r2 = RegExp (r,"gim"); 17var r3 = RegExp (r); 18 19assert(r2.source === 'a'); 20assert(r2.global === true); 21assert(r2.ignoreCase === true); 22assert(r2.multiline === true); 23 24assert(r3.source === 'a'); 25assert(r3.global === true); 26assert(r3.ignoreCase === true); 27assert(r3.multiline === true); 28 29var obj = { get source() { throw 5 }, [Symbol.match] : true } 30 31try { 32 new RegExp (obj); 33 assert(false) 34} catch (e) { 35 assert(e === 5); 36} 37 38r = new RegExp ("a","gimuy"); 39assert (r.global === true); 40assert (r.ignoreCase === true); 41assert (r.multiline === true); 42assert (r.unicode === true); 43assert (r.sticky === true); 44 45try { 46 new RegExp ("a", "uu"); 47 assert (false); 48} catch (e) { 49 assert (e instanceof SyntaxError); 50} 51 52try { 53 new RegExp ("a", "yy"); 54 assert (false); 55} catch (e) { 56 assert (e instanceof SyntaxError); 57} 58