y-assertion-start.js (1095B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-assertion 5 es6id: 21.2.2.6 6 description: The `y` flag has no effect on the `^` assertion 7 info: | 8 Even when the y flag is used with a pattern, ^ always matches only at the 9 beginning of Input, or (if Multiline is true) at the beginning of a line. 10 ---*/ 11 12 var re; 13 14 re = /^a/y; 15 16 re.lastIndex = 0; 17 assert.sameValue( 18 re.test('a'), true, 'positive: beginning of input (without `m`)' 19 ); 20 21 re.lastIndex = 1; 22 assert.sameValue( 23 re.test(' a'), false, 'negative: within a line (without `m`)' 24 ); 25 26 re.lastIndex = 1; 27 assert.sameValue( 28 re.test('\na'), false, 'negative: beginning of line (without `m`)' 29 ); 30 31 re = /^a/my; 32 33 re.lastIndex = 0; 34 assert.sameValue( 35 re.test('a'), true, 'positive: beginning of input (with `m`)' 36 ); 37 38 re.lastIndex = 1; 39 assert.sameValue( 40 re.test(' a'), false, 'negative: within a line (with `m`)' 41 ); 42 43 re.lastIndex = 1; 44 assert.sameValue( 45 re.test('\na'), true, 'positive: beginning of line (with `m`)' 46 ); 47 48 reportCompare(0, 0);