| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| InspectorTest.runTestSuite([ |
| function testSimple(next) |
| { |
| var regexes = [/hello/g, /[0-9]+/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("hello123hello123", regexes); |
| dumpResults(results); |
| next(); |
| }, |
| |
| function testMatchAtStart(next) |
| { |
| var regexes = [/yes/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("yes thank you", regexes); |
| dumpResults(results); |
| next(); |
| }, |
| |
| function testMatchAtEnd(next) |
| { |
| var regexes = [/you/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("yes thank you", regexes); |
| dumpResults(results); |
| next(); |
| }, |
| |
| function testAvoidInnerMatch(next) |
| { |
| var regexes = [/url\("red\.com"\)/g, /red/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("image: url(\"red.com\")", regexes); |
| dumpResults(results); |
| next(); |
| }, |
| |
| function testNoMatch(next) |
| { |
| var regexes = [/something/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("nothing", regexes); |
| dumpResults(results); |
| next(); |
| }, |
| |
| function testNoMatches(next) |
| { |
| var regexes = [/something/g, /123/g, /abc/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("nothing", regexes); |
| dumpResults(results); |
| next(); |
| }, |
| |
| function testComplex(next) |
| { |
| var regexes = [/\(([^)]+)\)/g, /okay/g, /ka/g]; |
| var results = TextUtils.TextUtils.splitStringByRegexes("Start. (okay) kit-kat okay (kale) ka( ) okay. End", regexes); |
| dumpResults(results); |
| next(); |
| } |
| ]); |
| |
| function dumpResults(results) |
| { |
| for (var i = 0; i < results.length; i++) { |
| var result = results[i]; |
| InspectorTest.addResult("\"" + result.value + "\", " + result.position + ", " + result.regexIndex); |
| } |
| } |
| } |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| Tests TextUtils.TextUtils.splitStringByRegexes. |
| </p> |
| </body> |
| </html> |