Skip to content

Commit

Permalink
Use string notation for one line regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Setogit authored and Tetsuo Seto committed Aug 31, 2016
1 parent 3ebd0a4 commit 0f75465
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 105 deletions.
48 changes: 16 additions & 32 deletions test/gpb-translate-helper.js
Expand Up @@ -76,17 +76,15 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
'*** translation failed: messages.json\n',
'--- translating gpbtestmain_plain.txt\n',
'*** translation failed: plain.txt\n',
'--- translated 0 messages, 0 words, 0 characters\n',
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down Expand Up @@ -189,17 +187,15 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
'*** translation failed: messages.json\n',
'--- translating gpbtestmain_plain.txt\n',
'*** translation failed: plain.txt\n',
'--- translated 0 messages, 0 words, 0 characters\n',
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down Expand Up @@ -302,16 +298,13 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
'--- translating gpbtestmain_plain.txt\n',
new RegExp(
'--- translated 2 messages, 25 words, 13[36]{1} characters\n'),
/--- translated 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down Expand Up @@ -430,16 +423,13 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
'--- translating gpbtestmain_plain.txt\n',
new RegExp(
'--- translated 2 messages, 25 words, 13[36]{1} characters\n'),
/--- translated 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down Expand Up @@ -558,16 +548,13 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
'--- translating gpbtestmain_plain.txt\n',
new RegExp(
'--- translated 2 messages, 25 words, 13[36]{1} characters\n'),
/--- translated 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down Expand Up @@ -686,16 +673,13 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
'--- translating gpbtestmain_plain.txt\n',
new RegExp(
'--- translated 2 messages, 25 words, 13[36]{1} characters\n'),
/--- translated 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down
20 changes: 10 additions & 10 deletions test/test-extract-2.js
Expand Up @@ -11,8 +11,8 @@ var targets = {
extract000: {
out: [
'--- cloned /node_modules/gsub/intl/en/gsub.txt\n',
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
' extracted: User name is %s.\n',
' extracted: user: %s\n',
'\n--- root: \n--- max depth: unlimited\n--- cloned: 1 txt\n' +
Expand All @@ -24,8 +24,8 @@ var targets = {
},
extract001: {
out: [
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
' extracted: User name is %s.\n',
'\n--- root: \n--- max depth: N/A\n--- cloned: N/A\n' +
'--- scanned: 1 js, 0 html \n--- skipped: 0 js, 0 html \n' +
Expand All @@ -36,8 +36,8 @@ var targets = {
},
extract002: {
out: [
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
' extracted: User name is %s.\n',
'\n--- root: \n--- max depth: N/A\n--- cloned: N/A\n' +
'--- scanned: 1 js, 0 html \n--- skipped: 0 js, 0 html \n' +
Expand All @@ -49,8 +49,8 @@ var targets = {
extract003: {
out: [
'--- cloned /node_modules/gsub/intl/en/gsub.txt\n',
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
' extracted: User name is %s.\n',
' extracted: user: %s\n',
'\n--- root: \n--- max depth: unlimited\n--- cloned: 1 txt\n' +
Expand All @@ -62,8 +62,8 @@ var targets = {
},
extract004: {
out: [
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
new RegExp('^[\*]{3} Skipped non-literal argument of \"g.log\" at '),
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
/^[\*]{3} Skipped non-literal argument of "g\.log" at /,
' extracted: User name is %s.\n',
'\n--- root: \n--- max depth: N/A\n--- cloned: N/A\n' +
'--- scanned: 1 js, 0 html \n--- skipped: 0 js, 0 html \n' +
Expand Down
4 changes: 2 additions & 2 deletions test/test-setdir.js
Expand Up @@ -20,14 +20,14 @@ var targets = {
out: [
],
err: [
new RegExp('^[\*]{3} setRootDir: Intl dir not found under: '),
/^[\*]{3} setRootDir: Intl dir not found under: /,
],
},
setdir002: {
out: [
],
err: [
new RegExp('^[\*]{3} setRootDir: Root path is not a directory: '),
/^[\*]{3} setRootDir: Root path is not a directory: /,
],
},
};
Expand Down
2 changes: 1 addition & 1 deletion test/test-setregex.js
Expand Up @@ -12,7 +12,7 @@ var targets = {
out: [
],
err: [
new RegExp('[\"]{0,1}undefined[\"]{0,1} == true\n'),
/["]{0,1}undefined["]{0,1} == true\n/,
],
},
setregex001: {
Expand Down
117 changes: 57 additions & 60 deletions test/test-translate-2.js
Expand Up @@ -11,34 +11,31 @@ var targets = {
translate000: {
out: [
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages.json\n',
new RegExp('[\.]*--- translated to de\n'),
new RegExp('[\.]*--- translated to es\n'),
new RegExp('[\.]*--- translated to fr\n'),
new RegExp('[\.]*--- translated to it\n'),
new RegExp('[\.]*--- translated to pt\n'),
new RegExp('[\.]*--- translated to ja\n'),
new RegExp('[\.]*--- translated to ko\n'),
new RegExp('[\.]*--- translated to zh-Hans\n'),
new RegExp('[\.]*--- translated to zh-Hant\n'),
/[\.]*--- translated to de\n/,
/[\.]*--- translated to es\n/,
/[\.]*--- translated to fr\n/,
/[\.]*--- translated to it\n/,
/[\.]*--- translated to pt\n/,
/[\.]*--- translated to ja\n/,
/[\.]*--- translated to ko\n/,
/[\.]*--- translated to zh-Hans\n/,
/[\.]*--- translated to zh-Hant\n/,
'--- translating gpbtestmain_plain.txt\n',
new RegExp('[\.]*--- translated to de\n'),
new RegExp('[\.]*--- translated to es\n'),
new RegExp('[\.]*--- translated to fr\n'),
new RegExp('[\.]*--- translated to it\n'),
new RegExp('[\.]*--- translated to pt\n'),
new RegExp('[\.]*--- translated to ja\n'),
new RegExp('[\.]*--- translated to ko\n'),
new RegExp('[\.]*--- translated to zh-Hans\n'),
new RegExp('[\.]*--- translated to zh-Hant\n'),
new RegExp(
'--- translated 2 messages, 25 words, 13[36]{1} characters\n'),
/[\.]*--- translated to de\n/,
/[\.]*--- translated to es\n/,
/[\.]*--- translated to fr\n/,
/[\.]*--- translated to it\n/,
/[\.]*--- translated to pt\n/,
/[\.]*--- translated to ja\n/,
/[\.]*--- translated to ko\n/,
/[\.]*--- translated to zh-Hans\n/,
/[\.]*--- translated to zh-Hant\n/,
/--- translated 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linting gpbtestmain en\n',
new RegExp(
'--- linted 2 messages, 25 words, 13[36]{1} characters\n'),
/--- linted 2 messages, 25 words, 13[36]{1} characters\n/,
'--- linted gpbtestmain en\n',
'--- linting gpbtestmain de\n',
'--- linted gpbtestmain de\n',
Expand Down Expand Up @@ -143,45 +140,45 @@ var targets = {
'--- linted 4 messages, 4 words, 14 characters\n',
'--- linted gpbtestmain en\n',
'--- translating gpbtestmain_messages_rightleft_000000.json\n',
new RegExp('[\.]*--- translated to de\n'),
new RegExp('[\.]*--- translated to es\n'),
new RegExp('[\.]*--- translated to fr\n'),
new RegExp('[\.]*--- translated to it\n'),
new RegExp('[\.]*--- translated to pt\n'),
new RegExp('[\.]*--- translated to ja\n'),
new RegExp('[\.]*--- translated to ko\n'),
new RegExp('[\.]*--- translated to zh-Hans\n'),
new RegExp('[\.]*--- translated to zh-Hant\n'),
/[\.]*--- translated to de\n/,
/[\.]*--- translated to es\n/,
/[\.]*--- translated to fr\n/,
/[\.]*--- translated to it\n/,
/[\.]*--- translated to pt\n/,
/[\.]*--- translated to ja\n/,
/[\.]*--- translated to ko\n/,
/[\.]*--- translated to zh-Hans\n/,
/[\.]*--- translated to zh-Hant\n/,
'--- translating gpbtestmain_messages_rightleft_000001.json\n',
new RegExp('[\.]*--- translated to de\n'),
new RegExp('[\.]*--- translated to es\n'),
new RegExp('[\.]*--- translated to fr\n'),
new RegExp('[\.]*--- translated to it\n'),
new RegExp('[\.]*--- translated to pt\n'),
new RegExp('[\.]*--- translated to ja\n'),
new RegExp('[\.]*--- translated to ko\n'),
new RegExp('[\.]*--- translated to zh-Hans\n'),
new RegExp('[\.]*--- translated to zh-Hant\n'),
/[\.]*--- translated to de\n/,
/[\.]*--- translated to es\n/,
/[\.]*--- translated to fr\n/,
/[\.]*--- translated to it\n/,
/[\.]*--- translated to pt\n/,
/[\.]*--- translated to ja\n/,
/[\.]*--- translated to ko\n/,
/[\.]*--- translated to zh-Hans\n/,
/[\.]*--- translated to zh-Hant\n/,
'--- translating gpbtestmain_messages_yesnot_000000.json\n',
new RegExp('[\.]*--- translated to de\n'),
new RegExp('[\.]*--- translated to es\n'),
new RegExp('[\.]*--- translated to fr\n'),
new RegExp('[\.]*--- translated to it\n'),
new RegExp('[\.]*--- translated to pt\n'),
new RegExp('[\.]*--- translated to ja\n'),
new RegExp('[\.]*--- translated to ko\n'),
new RegExp('[\.]*--- translated to zh-Hans\n'),
new RegExp('[\.]*--- translated to zh-Hant\n'),
/[\.]*--- translated to de\n/,
/[\.]*--- translated to es\n/,
/[\.]*--- translated to fr\n/,
/[\.]*--- translated to it\n/,
/[\.]*--- translated to pt\n/,
/[\.]*--- translated to ja\n/,
/[\.]*--- translated to ko\n/,
/[\.]*--- translated to zh-Hans\n/,
/[\.]*--- translated to zh-Hant\n/,
'--- translating gpbtestmain_messages_yesnot_000001.json\n',
new RegExp('[\.]*--- translated to de\n'),
new RegExp('[\.]*--- translated to es\n'),
new RegExp('[\.]*--- translated to fr\n'),
new RegExp('[\.]*--- translated to it\n'),
new RegExp('[\.]*--- translated to pt\n'),
new RegExp('[\.]*--- translated to ja\n'),
new RegExp('[\.]*--- translated to ko\n'),
new RegExp('[\.]*--- translated to zh-Hans\n'),
new RegExp('[\.]*--- translated to zh-Hant\n'),
/[\.]*--- translated to de\n/,
/[\.]*--- translated to es\n/,
/[\.]*--- translated to fr\n/,
/[\.]*--- translated to it\n/,
/[\.]*--- translated to pt\n/,
/[\.]*--- translated to ja\n/,
/[\.]*--- translated to ko\n/,
/[\.]*--- translated to zh-Hans\n/,
/[\.]*--- translated to zh-Hant\n/,
'--- translated 4 messages, 4 words, 14 characters\n',
'--- linting gpbtestmain en\n',
'--- linted 4 messages, 4 words, 14 characters\n',
Expand Down

0 comments on commit 0f75465

Please sign in to comment.