| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'multiline-001.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
var SECTION = "RegExp/multiline-001"; |
| 17 |
var VERSION = "ECMA_2"; |
| 18 |
var TITLE = "RegExp: multiline flag"; |
| 19 |
var BUGNUMBER="343901"; |
| 20 |
|
| 21 |
startTest(); |
| 22 |
|
| 23 |
var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + |
| 24 |
"northern flicker\npileated\n"; |
| 25 |
|
| 26 |
AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); |
| 27 |
|
| 28 |
AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); |
| 29 |
|
| 30 |
test(); |
| 31 |
|
| 32 |
|
| 33 |
function AddRegExpCases |
| 34 |
( regexp, pattern, index, matches_array ) { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
if ( regexp.exec(pattern) == null || matches_array == null ) { |
| 39 |
AddTestCase( |
| 40 |
regexp + ".exec(" + pattern +")", |
| 41 |
matches_array, |
| 42 |
regexp.exec(pattern) ); |
| 43 |
|
| 44 |
return; |
| 45 |
} |
| 46 |
|
| 47 |
AddTestCase( |
| 48 |
regexp.toString() + ".exec(" + pattern +").length", |
| 49 |
matches_array.length, |
| 50 |
regexp.exec(pattern).length ); |
| 51 |
|
| 52 |
AddTestCase( |
| 53 |
regexp.toString() + ".exec(" + pattern +").index", |
| 54 |
index, |
| 55 |
regexp.exec(pattern).index ); |
| 56 |
|
| 57 |
AddTestCase( |
| 58 |
regexp + ".exec(" + pattern +").input", |
| 59 |
pattern, |
| 60 |
regexp.exec(pattern).input ); |
| 61 |
|
| 62 |
|
| 63 |
for ( var matches = 0; matches < matches_array.length; matches++ ) { |
| 64 |
AddTestCase( |
| 65 |
regexp + ".exec(" + pattern +")[" + matches +"]", |
| 66 |
matches_array[matches], |
| 67 |
regexp.exec(pattern)[matches] ); |
| 68 |
} |
| 69 |
} |