Commit 295ceb45 authored by Robert Griesemer's avatar Robert Griesemer

remove uses of string concatenation from src and misc directory

R=rsc
https://golang.org/cl/172041
parent 09cec0e1
...@@ -124,7 +124,7 @@ func dosync(c *http.Conn, r *http.Request) { ...@@ -124,7 +124,7 @@ func dosync(c *http.Conn, r *http.Request) {
func usage() { func usage() {
fmt.Fprintf(os.Stderr, fmt.Fprintf(os.Stderr,
"usage: godoc package [name ...]\n" "usage: godoc package [name ...]\n"+
" godoc -http=:6060\n"); " godoc -http=:6060\n");
flag.PrintDefaults(); flag.PrintDefaults();
os.Exit(2); os.Exit(2);
......
...@@ -2174,7 +2174,7 @@ func output() { ...@@ -2174,7 +2174,7 @@ func output() {
} else if temp1[k] < 0 { // reduce/reduce conflict } else if temp1[k] < 0 { // reduce/reduce conflict
if foutput != nil { if foutput != nil {
fmt.Fprintf(foutput, fmt.Fprintf(foutput,
"\n %v: reduce/reduce conflict (red'ns " "\n %v: reduce/reduce conflict (red'ns "+
"%v and %v) on %v", "%v and %v) on %v",
i, -temp1[k], lastred, symnam(k)) i, -temp1[k], lastred, symnam(k))
} }
...@@ -2734,7 +2734,7 @@ nextn: ...@@ -2734,7 +2734,7 @@ nextn:
// states are equal // states are equal
indgo[i] = n; indgo[i] = n;
if adb > 1 { if adb > 1 {
fmt.Fprintf(ftable, "State %v: entry at" fmt.Fprintf(ftable, "State %v: entry at"+
"%v equals state %v\n", "%v equals state %v\n",
i, n, j) i, n, j)
} }
......
...@@ -99,8 +99,8 @@ var facts = map[int]string{ ...@@ -99,8 +99,8 @@ var facts = map[int]string{
2: "2", 2: "2",
10: "3628800", 10: "3628800",
20: "2432902008176640000", 20: "2432902008176640000",
100: "933262154439441526816992388562667004907159682643816214685929" 100: "933262154439441526816992388562667004907159682643816214685929" +
"638952175999932299156089414639761565182862536979208272237582" "638952175999932299156089414639761565182862536979208272237582" +
"51185210916864000000000000000000000000", "51185210916864000000000000000000000000",
} }
......
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
const ( const (
sa = "991"; sa = "991";
sb = "2432902008176640000"; // 20! sb = "2432902008176640000"; // 20!
sc = "933262154439441526816992388562667004907159682643816214685929" sc = "933262154439441526816992388562667004907159682643816214685929" +
"638952175999932299156089414639761565182862536979208272237582" "638952175999932299156089414639761565182862536979208272237582" +
"51185210916864000000000000000000000000"; // 100! "51185210916864000000000000000000000000"; // 100!
sp = "170141183460469231731687303715884105727"; // prime sp = "170141183460469231731687303715884105727"; // prime
) )
......
...@@ -49,7 +49,7 @@ var gzipTests = []gzipTest{ ...@@ -49,7 +49,7 @@ var gzipTests = []gzipTest{
gzipTest{ // concatenation gzipTest{ // concatenation
"hello.txt", "hello.txt",
"hello.txt x2", "hello.txt x2",
"hello world\n" "hello world\n" +
"hello world\n", "hello world\n",
[]byte{ []byte{
0x1f, 0x8b, 0x08, 0x08, 0xc8, 0x58, 0x13, 0x4a, 0x1f, 0x8b, 0x08, 0x08, 0xc8, 0x58, 0x13, 0x4a,
...@@ -86,34 +86,34 @@ var gzipTests = []gzipTest{ ...@@ -86,34 +86,34 @@ var gzipTests = []gzipTest{
gzipTest{ // has dynamic huffman blocks gzipTest{ // has dynamic huffman blocks
"gettysburg", "gettysburg",
"gettysburg", "gettysburg",
" Four score and seven years ago our fathers brought forth on\n" " Four score and seven years ago our fathers brought forth on\n" +
"this continent, a new nation, conceived in Liberty, and dedicated\n" "this continent, a new nation, conceived in Liberty, and dedicated\n" +
"to the proposition that all men are created equal.\n" "to the proposition that all men are created equal.\n" +
" Now we are engaged in a great Civil War, testing whether that\n" " Now we are engaged in a great Civil War, testing whether that\n" +
"nation, or any nation so conceived and so dedicated, can long\n" "nation, or any nation so conceived and so dedicated, can long\n" +
"endure.\n" "endure.\n" +
" We are met on a great battle-field of that war.\n" " We are met on a great battle-field of that war.\n" +
" We have come to dedicate a portion of that field, as a final\n" " We have come to dedicate a portion of that field, as a final\n" +
"resting place for those who here gave their lives that that\n" "resting place for those who here gave their lives that that\n" +
"nation might live. It is altogether fitting and proper that\n" "nation might live. It is altogether fitting and proper that\n" +
"we should do this.\n" "we should do this.\n" +
" But, in a larger sense, we can not dedicate — we can not\n" " But, in a larger sense, we can not dedicate — we can not\n" +
"consecrate — we can not hallow — this ground.\n" "consecrate — we can not hallow — this ground.\n" +
" The brave men, living and dead, who struggled here, have\n" " The brave men, living and dead, who struggled here, have\n" +
"consecrated it, far above our poor power to add or detract.\n" "consecrated it, far above our poor power to add or detract.\n" +
"The world will little note, nor long remember what we say here,\n" "The world will little note, nor long remember what we say here,\n" +
"but it can never forget what they did here.\n" "but it can never forget what they did here.\n" +
" It is for us the living, rather, to be dedicated here to the\n" " It is for us the living, rather, to be dedicated here to the\n" +
"unfinished work which they who fought here have thus far so\n" "unfinished work which they who fought here have thus far so\n" +
"nobly advanced. It is rather for us to be here dedicated to\n" "nobly advanced. It is rather for us to be here dedicated to\n" +
"the great task remaining before us — that from these honored\n" "the great task remaining before us — that from these honored\n" +
"dead we take increased devotion to that cause for which they\n" "dead we take increased devotion to that cause for which they\n" +
"gave the last full measure of devotion —\n" "gave the last full measure of devotion —\n" +
" that we here highly resolve that these dead shall not have\n" " that we here highly resolve that these dead shall not have\n" +
"died in vain — that this nation, under God, shall have a new\n" "died in vain — that this nation, under God, shall have a new\n" +
"birth of freedom — and that government of the people, by the\n" "birth of freedom — and that government of the people, by the\n" +
"people, for the people, shall not perish from this earth.\n" "people, for the people, shall not perish from this earth.\n" +
"\n" "\n" +
"Abraham Lincoln, November 19, 1863, Gettysburg, Pennsylvania\n", "Abraham Lincoln, November 19, 1863, Gettysburg, Pennsylvania\n",
[]byte{ []byte{
0x1f, 0x8b, 0x08, 0x08, 0xd1, 0x12, 0x2b, 0x4a, 0x1f, 0x8b, 0x08, 0x08, 0xd1, 0x12, 0x2b, 0x4a,
......
...@@ -74,7 +74,7 @@ func TestStringResize(t *testing.T) { ...@@ -74,7 +74,7 @@ func TestStringResize(t *testing.T) {
checkSize(t, a.Resize(10, 0), 10, 10); checkSize(t, a.Resize(10, 0), 10, 10);
for i := 4; i < a.Len(); i++ { for i := 4; i < a.Len(); i++ {
if a.At(i) != "" { if a.At(i) != "" {
t.Errorf("expected a.At(%d) == " "; found %s", i, a.At(i)) t.Errorf("expected a.At(%d) == "+"; found %s", i, a.At(i))
} }
} }
} }
......
...@@ -100,45 +100,45 @@ func TestCertificateParse(t *testing.T) { ...@@ -100,45 +100,45 @@ func TestCertificateParse(t *testing.T) {
} }
} }
var certBytes = "308203223082028ba00302010202106edf0d9499fd4533dd1297fc42a93be1300d06092a864886" var certBytes = "308203223082028ba00302010202106edf0d9499fd4533dd1297fc42a93be1300d06092a864886" +
"f70d0101050500304c310b3009060355040613025a4131253023060355040a131c546861777465" "f70d0101050500304c310b3009060355040613025a4131253023060355040a131c546861777465" +
"20436f6e73756c74696e67202850747929204c74642e311630140603550403130d546861777465" "20436f6e73756c74696e67202850747929204c74642e311630140603550403130d546861777465" +
"20534743204341301e170d3039303332353136343932395a170d3130303332353136343932395a" "20534743204341301e170d3039303332353136343932395a170d3130303332353136343932395a" +
"3069310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630" "3069310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630" +
"140603550407130d4d6f756e7461696e205669657731133011060355040a130a476f6f676c6520" "140603550407130d4d6f756e7461696e205669657731133011060355040a130a476f6f676c6520" +
"496e63311830160603550403130f6d61696c2e676f6f676c652e636f6d30819f300d06092a8648" "496e63311830160603550403130f6d61696c2e676f6f676c652e636f6d30819f300d06092a8648" +
"86f70d010101050003818d0030818902818100c5d6f892fccaf5614b064149e80a2c9581a218ef" "86f70d010101050003818d0030818902818100c5d6f892fccaf5614b064149e80a2c9581a218ef" +
"41ec35bd7a58125ae76f9ea54ddc893abbeb029f6b73616bf0ffd868791fba7af9c4aebf3706ba" "41ec35bd7a58125ae76f9ea54ddc893abbeb029f6b73616bf0ffd868791fba7af9c4aebf3706ba" +
"3eeaeed27435b4ddcfb157c05f351d66aa87fee0de072d66d773affbd36ab78bef090e0cc861a9" "3eeaeed27435b4ddcfb157c05f351d66aa87fee0de072d66d773affbd36ab78bef090e0cc861a9" +
"03ac90dd98b51c9c41566c017f0beec3bff391051ffba0f5cc6850ad2a590203010001a381e730" "03ac90dd98b51c9c41566c017f0beec3bff391051ffba0f5cc6850ad2a590203010001a381e730" +
"81e430280603551d250421301f06082b0601050507030106082b06010505070302060960864801" "81e430280603551d250421301f06082b0601050507030106082b06010505070302060960864801" +
"86f842040130360603551d1f042f302d302ba029a0278625687474703a2f2f63726c2e74686177" "86f842040130360603551d1f042f302d302ba029a0278625687474703a2f2f63726c2e74686177" +
"74652e636f6d2f54686177746553474343412e63726c307206082b060105050701010466306430" "74652e636f6d2f54686177746553474343412e63726c307206082b060105050701010466306430" +
"2206082b060105050730018616687474703a2f2f6f6373702e7468617774652e636f6d303e0608" "2206082b060105050730018616687474703a2f2f6f6373702e7468617774652e636f6d303e0608" +
"2b060105050730028632687474703a2f2f7777772e7468617774652e636f6d2f7265706f736974" "2b060105050730028632687474703a2f2f7777772e7468617774652e636f6d2f7265706f736974" +
"6f72792f5468617774655f5347435f43412e637274300c0603551d130101ff04023000300d0609" "6f72792f5468617774655f5347435f43412e637274300c0603551d130101ff04023000300d0609" +
"2a864886f70d01010505000381810062f1f3050ebc105e497c7aedf87e24d2f4a986bb3b837bd1" "2a864886f70d01010505000381810062f1f3050ebc105e497c7aedf87e24d2f4a986bb3b837bd1" +
"9b91ebcad98b065992f6bd2b49b7d6d3cb2e427a99d606c7b1d46352527fac39e6a8b6726de5bf" "9b91ebcad98b065992f6bd2b49b7d6d3cb2e427a99d606c7b1d46352527fac39e6a8b6726de5bf" +
"70212a52cba07634a5e332011bd1868e78eb5e3c93cf03072276786f207494feaa0ed9d53b2110" "70212a52cba07634a5e332011bd1868e78eb5e3c93cf03072276786f207494feaa0ed9d53b2110" +
"a76571f90209cdae884385c882587030ee15f33d761e2e45a6bc308203233082028ca003020102" "a76571f90209cdae884385c882587030ee15f33d761e2e45a6bc308203233082028ca003020102" +
"020430000002300d06092a864886f70d0101050500305f310b3009060355040613025553311730" "020430000002300d06092a864886f70d0101050500305f310b3009060355040613025553311730" +
"15060355040a130e566572695369676e2c20496e632e31373035060355040b132e436c61737320" "15060355040a130e566572695369676e2c20496e632e31373035060355040b132e436c61737320" +
"33205075626c6963205072696d6172792043657274696669636174696f6e20417574686f726974" "33205075626c6963205072696d6172792043657274696669636174696f6e20417574686f726974" +
"79301e170d3034303531333030303030305a170d3134303531323233353935395a304c310b3009" "79301e170d3034303531333030303030305a170d3134303531323233353935395a304c310b3009" +
"060355040613025a4131253023060355040a131c54686177746520436f6e73756c74696e672028" "060355040613025a4131253023060355040a131c54686177746520436f6e73756c74696e672028" +
"50747929204c74642e311630140603550403130d5468617774652053474320434130819f300d06" "50747929204c74642e311630140603550403130d5468617774652053474320434130819f300d06" +
"092a864886f70d010101050003818d0030818902818100d4d367d08d157faecd31fe7d1d91a13f" "092a864886f70d010101050003818d0030818902818100d4d367d08d157faecd31fe7d1d91a13f" +
"0b713cacccc864fb63fc324b0794bd6f80ba2fe10493c033fc093323e90b742b71c403c6d2cde2" "0b713cacccc864fb63fc324b0794bd6f80ba2fe10493c033fc093323e90b742b71c403c6d2cde2" +
"2ff50963cdff48a500bfe0e7f388b72d32de9836e60aad007bc4644a3b847503f270927d0e62f5" "2ff50963cdff48a500bfe0e7f388b72d32de9836e60aad007bc4644a3b847503f270927d0e62f5" +
"21ab693684317590f8bfc76c881b06957cc9e5a8de75a12c7a68dfd5ca1c875860190203010001" "21ab693684317590f8bfc76c881b06957cc9e5a8de75a12c7a68dfd5ca1c875860190203010001" +
"a381fe3081fb30120603551d130101ff040830060101ff020100300b0603551d0f040403020106" "a381fe3081fb30120603551d130101ff040830060101ff020100300b0603551d0f040403020106" +
"301106096086480186f842010104040302010630280603551d110421301fa41d301b3119301706" "301106096086480186f842010104040302010630280603551d110421301fa41d301b3119301706" +
"035504031310507269766174654c6162656c332d313530310603551d1f042a30283026a024a022" "035504031310507269766174654c6162656c332d313530310603551d1f042a30283026a024a022" +
"8620687474703a2f2f63726c2e766572697369676e2e636f6d2f706361332e63726c303206082b" "8620687474703a2f2f63726c2e766572697369676e2e636f6d2f706361332e63726c303206082b" +
"0601050507010104263024302206082b060105050730018616687474703a2f2f6f6373702e7468" "0601050507010104263024302206082b060105050730018616687474703a2f2f6f6373702e7468" +
"617774652e636f6d30340603551d25042d302b06082b0601050507030106082b06010505070302" "617774652e636f6d30340603551d25042d302b06082b0601050507030106082b06010505070302" +
"06096086480186f8420401060a6086480186f845010801300d06092a864886f70d010105050003" "06096086480186f8420401060a6086480186f845010801300d06092a864886f70d010105050003" +
"81810055ac63eadea1ddd2905f9f0bce76be13518f93d9052bc81b774bad6950a1eededcfddb07" "81810055ac63eadea1ddd2905f9f0bce76be13518f93d9052bc81b774bad6950a1eededcfddb07" +
"e9e83994dcab72792f06bfab8170c4a8edea5334edef1e53d906c7562bd15cf4d18a8eb42bb137" "e9e83994dcab72792f06bfab8170c4a8edea5334edef1e53d906c7562bd15cf4d18a8eb42bb137" +
"9048084225c53e8acb7feb6f04d16dc574a2f7a27c7b603c77cd0ece48027f012fb69b37e02a2a" "9048084225c53e8acb7feb6f04d16dc574a2f7a27c7b603c77cd0ece48027f012fb69b37e02a2a" +
"36dcd585d6ace53f546f961e05af" "36dcd585d6ace53f546f961e05af"
...@@ -20,14 +20,14 @@ type testpair struct { ...@@ -20,14 +20,14 @@ type testpair struct {
var pairs = []testpair{ var pairs = []testpair{
// Wikipedia example // Wikipedia example
testpair{ testpair{
"Man is distinguished, not only by his reason, but by this singular passion from " "Man is distinguished, not only by his reason, but by this singular passion from " +
"other animals, which is a lust of the mind, that by a perseverance of delight in " "other animals, which is a lust of the mind, that by a perseverance of delight in " +
"the continued and indefatigable generation of knowledge, exceeds the short " "the continued and indefatigable generation of knowledge, exceeds the short " +
"vehemence of any carnal pleasure.", "vehemence of any carnal pleasure.",
"9jqo^BlbD-BleB1DJ+*+F(f,q/0JhKF<GL>Cj@.4Gp$d7F!,L7@<6@)/0JDEF<G%<+EV:2F!,\n" "9jqo^BlbD-BleB1DJ+*+F(f,q/0JhKF<GL>Cj@.4Gp$d7F!,L7@<6@)/0JDEF<G%<+EV:2F!,\n" +
"O<DJ+*.@<*K0@<6L(Df-\\0Ec5e;DffZ(EZee.Bl.9pF\"AGXBPCsi+DGm>@3BB/F*&OCAfu2/AKY\n" "O<DJ+*.@<*K0@<6L(Df-\\0Ec5e;DffZ(EZee.Bl.9pF\"AGXBPCsi+DGm>@3BB/F*&OCAfu2/AKY\n" +
"i(DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF<G:8+EV:.+Cf>-FD5W8ARlolDIa\n" "i(DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF<G:8+EV:.+Cf>-FD5W8ARlolDIa\n" +
"l(DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G\n" "l(DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G\n" +
">uD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c\n", ">uD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c\n",
}, },
} }
......
...@@ -46,16 +46,16 @@ func TestGitTable(t *testing.T) { ...@@ -46,16 +46,16 @@ func TestGitTable(t *testing.T) {
var gitPairs = []testpair{ var gitPairs = []testpair{
// Wikipedia example, adapted. // Wikipedia example, adapted.
testpair{ testpair{
"Man is distinguished, not only by his reason, but by this singular passion from " "Man is distinguished, not only by his reason, but by this singular passion from " +
"other animals, which is a lust of the mind, that by a perseverance of delight in " "other animals, which is a lust of the mind, that by a perseverance of delight in " +
"the continued and indefatigable generation of knowledge, exceeds the short " "the continued and indefatigable generation of knowledge, exceeds the short " +
"vehemence of any carnal pleasure.", "vehemence of any carnal pleasure.",
"zO<`^zX>%ZCX>)XGZfA9Ab7*B`EFf-gbRchTY<VDJc_3(Mb0BhMVRLV8EFfZabRc4R\n" "zO<`^zX>%ZCX>)XGZfA9Ab7*B`EFf-gbRchTY<VDJc_3(Mb0BhMVRLV8EFfZabRc4R\n" +
"zAarPHb0BkRZfA9DVR9gFVRLh7Z*CxFa&K)QZ**v7av))DX>DO_b1WctXlY|;AZc?T\n" "zAarPHb0BkRZfA9DVR9gFVRLh7Z*CxFa&K)QZ**v7av))DX>DO_b1WctXlY|;AZc?T\n" +
"zVIXXEb95kYW*~HEWgu;7Ze%PVbZB98AYyqSVIXj2a&u*NWpZI|V`U(3W*}r`Y-wj`\n" "zVIXXEb95kYW*~HEWgu;7Ze%PVbZB98AYyqSVIXj2a&u*NWpZI|V`U(3W*}r`Y-wj`\n" +
"zbRcPNAarPDAY*TCbZKsNWn>^>Ze$>7Ze(R<VRUI{VPb4$AZKN6WpZJ3X>V>IZ)PBC\n" "zbRcPNAarPDAY*TCbZKsNWn>^>Ze$>7Ze(R<VRUI{VPb4$AZKN6WpZJ3X>V>IZ)PBC\n" +
"zZf|#NWn^b%EFfigV`XJzb0BnRWgv5CZ*p`Xc4cT~ZDnp_Wgu^6AYpEKAY);2ZeeU7\n" "zZf|#NWn^b%EFfigV`XJzb0BnRWgv5CZ*p`Xc4cT~ZDnp_Wgu^6AYpEKAY);2ZeeU7\n" +
"IaBO8^b9HiME&u=k\n", "IaBO8^b9HiME&u=k\n",
}, },
} }
......
...@@ -232,8 +232,8 @@ type T1 struct { ...@@ -232,8 +232,8 @@ type T1 struct {
a int; a int;
} }
const F1 = `datafmt "datafmt";` const F1 = `datafmt "datafmt";` +
`int = "%d";` `int = "%d";` +
`datafmt.T1 = "<" a ">";` `datafmt.T1 = "<" a ">";`
func TestStruct1(t *testing.T) { check(t, F1, "<42>", T1{42}) } func TestStruct1(t *testing.T) { check(t, F1, "<42>", T1{42}) }
...@@ -248,14 +248,14 @@ type T2 struct { ...@@ -248,14 +248,14 @@ type T2 struct {
} }
const F2a = F1 + const F2a = F1 +
`string = "%s";` `string = "%s";` +
`ptr = *;` `ptr = *;` +
`datafmt.T2 = s ["-" p "-"];` `datafmt.T2 = s ["-" p "-"];`
const F2b = F1 + const F2b = F1 +
`string = "%s";` `string = "%s";` +
`ptr = *;` `ptr = *;` +
`datafmt.T2 = s ("-" p "-" | "empty");` `datafmt.T2 = s ("-" p "-" | "empty");`
func TestStruct2(t *testing.T) { func TestStruct2(t *testing.T) {
check(t, F2a, "foo", T2{"foo", nil}); check(t, F2a, "foo", T2{"foo", nil});
...@@ -272,17 +272,17 @@ type T3 struct { ...@@ -272,17 +272,17 @@ type T3 struct {
a []int; a []int;
} }
const F3a = `datafmt "datafmt";` const F3a = `datafmt "datafmt";` +
`default = "%v";` `default = "%v";` +
`array = *;` `array = *;` +
`datafmt.T3 = s {" " a a / ","};` `datafmt.T3 = s {" " a a / ","};`
const F3b = `datafmt "datafmt";` const F3b = `datafmt "datafmt";` +
`int = "%d";` `int = "%d";` +
`string = "%s";` `string = "%s";` +
`array = *;` `array = *;` +
`nil = ;` `nil = ;` +
`empty = *:nil;` `empty = *:nil;` +
`datafmt.T3 = s [a:empty ": " {a / "-"}]` `datafmt.T3 = s [a:empty ": " {a / "-"}]`
func TestStruct3(t *testing.T) { func TestStruct3(t *testing.T) {
...@@ -301,20 +301,20 @@ type T4 struct { ...@@ -301,20 +301,20 @@ type T4 struct {
a []int; a []int;
} }
const F4a = `datafmt "datafmt";` const F4a = `datafmt "datafmt";` +
`int = "%d";` `int = "%d";` +
`ptr = *;` `ptr = *;` +
`array = *;` `array = *;` +
`nil = ;` `nil = ;` +
`empty = *:nil;` `empty = *:nil;` +
`datafmt.T4 = "<" (x:empty x | "-") ">" ` `datafmt.T4 = "<" (x:empty x | "-") ">" `
const F4b = `datafmt "datafmt";` const F4b = `datafmt "datafmt";` +
`int = "%d";` `int = "%d";` +
`ptr = *;` `ptr = *;` +
`array = *;` `array = *;` +
`nil = ;` `nil = ;` +
`empty = *:nil;` `empty = *:nil;` +
`datafmt.T4 = "<" (a:empty {a / ", "} | "-") ">" ` `datafmt.T4 = "<" (a:empty {a / ", "} | "-") ">" `
func TestStruct4(t *testing.T) { func TestStruct4(t *testing.T) {
...@@ -334,10 +334,10 @@ type Point struct { ...@@ -334,10 +334,10 @@ type Point struct {
x, y int; x, y int;
} }
const FPoint = `datafmt "datafmt";` const FPoint = `datafmt "datafmt";` +
`int = "%d";` `int = "%d";` +
`hexInt = "0x%x";` `hexInt = "0x%x";` +
`string = "---%s---";` `string = "---%s---";` +
`datafmt.Point = name "{" x ", " y:hexInt "}";` `datafmt.Point = name "{" x ", " y:hexInt "}";`
func TestStructPoint(t *testing.T) { func TestStructPoint(t *testing.T) {
...@@ -349,7 +349,7 @@ func TestStructPoint(t *testing.T) { ...@@ -349,7 +349,7 @@ func TestStructPoint(t *testing.T) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Formatting a slice (documentation example) // Formatting a slice (documentation example)
const FSlice = `int = "%b";` const FSlice = `int = "%b";` +
`array = { * / ", " }` `array = { * / ", " }`
func TestSlice(t *testing.T) { check(t, FSlice, "10, 11, 101, 111", []int{2, 3, 5, 7}) } func TestSlice(t *testing.T) { check(t, FSlice, "10, 11, 101, 111", []int{2, 3, 5, 7}) }
......
...@@ -87,7 +87,7 @@ func (p *parser) init(filename string, src []byte, mode uint) { ...@@ -87,7 +87,7 @@ func (p *parser) init(filename string, src []byte, mode uint) {
// Parsing support // Parsing support
func (p *parser) printTrace(a ...) { func (p *parser) printTrace(a ...) {
const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " +
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "; ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ";
const n = uint(len(dots)); const n = uint(len(dots));
fmt.Printf("%5d:%3d: ", p.pos.Line, p.pos.Column); fmt.Printf("%5d:%3d: ", p.pos.Line, p.pos.Column);
......
...@@ -66,8 +66,8 @@ var tokens = [...]elt{ ...@@ -66,8 +66,8 @@ var tokens = [...]elt{
elt{token.CHAR, "'\\uff16'", literal}, elt{token.CHAR, "'\\uff16'", literal},
elt{token.CHAR, "'\\U0000ff16'", literal}, elt{token.CHAR, "'\\U0000ff16'", literal},
elt{token.STRING, "`foobar`", literal}, elt{token.STRING, "`foobar`", literal},
elt{token.STRING, "`" `foo elt{token.STRING, "`" + `foo
bar` bar` +
"`", "`",
literal, literal,
}, },
...@@ -345,16 +345,15 @@ func TestIllegalChars(t *testing.T) { ...@@ -345,16 +345,15 @@ func TestIllegalChars(t *testing.T) {
func TestStdErrorHander(t *testing.T) { func TestStdErrorHander(t *testing.T) {
const src = "@\n" // illegal character, cause an error const src = "@\n" + // illegal character, cause an error
"@ @\n" // two errors on the same line "@ @\n" + // two errors on the same line
"//line File2:20\n" "//line File2:20\n" +
"@\n" // different file, but same line "@\n" + // different file, but same line
"//line File2:1\n" "//line File2:1\n" +
"@ @\n" // same file, decreasing line number "@ @\n" + // same file, decreasing line number
"//line File1:1\n" "//line File1:1\n" +
"@ @ @"; // original file, line 1 again "@ @ @"; // original file, line 1 again
v := new(ErrorVector); v := new(ErrorVector);
nerrors := Tokenize("File1", strings.Bytes(src), v, 0, nerrors := Tokenize("File1", strings.Bytes(src), v, 0,
func(pos token.Position, tok token.Token, litb []byte) bool { func(pos token.Position, tok token.Token, litb []byte) bool {
......
...@@ -39,8 +39,8 @@ func TestReadFile(t *testing.T) { ...@@ -39,8 +39,8 @@ func TestReadFile(t *testing.T) {
func TestWriteFile(t *testing.T) { func TestWriteFile(t *testing.T) {
filename := "_obj/rumpelstilzchen"; filename := "_obj/rumpelstilzchen";
data := "Programming today is a race between software engineers striving to " data := "Programming today is a race between software engineers striving to " +
"build bigger and better idiot-proof programs, and the Universe trying " "build bigger and better idiot-proof programs, and the Universe trying " +
"to produce bigger and better idiots. So far, the Universe is winning."; "to produce bigger and better idiots. So far, the Universe is winning.";
if err := WriteFile(filename, strings.Bytes(data), 0644); err != nil { if err := WriteFile(filename, strings.Bytes(data), 0644); err != nil {
......
...@@ -35,13 +35,13 @@ type myStruct struct { ...@@ -35,13 +35,13 @@ type myStruct struct {
MapPtrStruct map[string]*myStruct; MapPtrStruct map[string]*myStruct;
} }
const encoded = `{"t":true,"f":false,"s":"abc","i8":1,"i16":2,"i32":3,"i64":4,` const encoded = `{"t":true,"f":false,"s":"abc","i8":1,"i16":2,"i32":3,"i64":4,` +
` "u8":5,"u16":6,"u32":7,"u64":8,` ` "u8":5,"u16":6,"u32":7,"u64":8,` +
` "i":-9,"u":10,"bogusfield":"should be ignored",` ` "i":-9,"u":10,"bogusfield":"should be ignored",` +
` "fl":11.5,"fl32":12.25,"fl64":13.75,` ` "fl":11.5,"fl32":12.25,"fl64":13.75,` +
` "a":["x","y","z"],"my":{"s":"subguy"},` ` "a":["x","y","z"],"my":{"s":"subguy"},` +
`"map":{"k1":[1,2,3],"k2":[],"k3":[3,4]},` `"map":{"k1":[1,2,3],"k2":[],"k3":[3,4]},` +
`"mapstruct":{"m1":{"u8":8}},` `"mapstruct":{"m1":{"u8":8}},` +
`"mapptrstruct":{"m1":{"u8":8}}}` `"mapptrstruct":{"m1":{"u8":8}}}`
var decodedMap = map[string][]int{ var decodedMap = map[string][]int{
......
This diff is collapsed.
...@@ -20,7 +20,7 @@ var shifttests = []shiftTest{ ...@@ -20,7 +20,7 @@ var shifttests = []shiftTest{
shiftTest{0, 100, "0"}, shiftTest{0, 100, "0"},
shiftTest{1, 100, "1267650600228229401496703205376"}, shiftTest{1, 100, "1267650600228229401496703205376"},
shiftTest{1, -100, shiftTest{1, -100,
"0.00000000000000000000000000000078886090522101180541" "0.00000000000000000000000000000078886090522101180541" +
"17285652827862296732064351090230047702789306640625", "17285652827862296732064351090230047702789306640625",
}, },
shiftTest{12345678, 8, "3160493568"}, shiftTest{12345678, 8, "3160493568"},
......
...@@ -284,40 +284,40 @@ var tests = []entry{ ...@@ -284,40 +284,40 @@ var tests = []entry{
entry{ entry{
"9a", "9a",
1, 0, 0, '.', 0, 1, 0, 0, '.', 0,
"1\t2\t3\t4\n" "1\t2\t3\t4\n" +
"11\t222\t3333\t44444\n", "11\t222\t3333\t44444\n",
"1.2..3...4\n" "1.2..3...4\n" +
"11222333344444\n", "11222333344444\n",
}, },
entry{ entry{
"9b", "9b",
1, 0, 0, '.', FilterHTML, 1, 0, 0, '.', FilterHTML,
"1\t2<!---\f--->\t3\t4\n" // \f inside HTML is ignored "1\t2<!---\f--->\t3\t4\n" + // \f inside HTML is ignored
"11\t222\t3333\t44444\n", "11\t222\t3333\t44444\n",
"1.2<!---\f--->..3...4\n" "1.2<!---\f--->..3...4\n" +
"11222333344444\n", "11222333344444\n",
}, },
entry{ entry{
"9c", "9c",
1, 0, 0, '.', 0, 1, 0, 0, '.', 0,
"1\t2\t3\t4\f" // \f causes a newline and flush "1\t2\t3\t4\f" + // \f causes a newline and flush
"11\t222\t3333\t44444\n", "11\t222\t3333\t44444\n",
"1234\n" "1234\n" +
"11222333344444\n", "11222333344444\n",
}, },
entry{ entry{
"9c debug", "9c debug",
1, 0, 0, '.', Debug, 1, 0, 0, '.', Debug,
"1\t2\t3\t4\f" // \f causes a newline and flush "1\t2\t3\t4\f" + // \f causes a newline and flush
"11\t222\t3333\t44444\n", "11\t222\t3333\t44444\n",
"1|2|3|4\n" "1|2|3|4\n" +
"11|222|3333|44444\n", "11|222|3333|44444\n",
}, },
...@@ -338,144 +338,144 @@ var tests = []entry{ ...@@ -338,144 +338,144 @@ var tests = []entry{
entry{ entry{
"11", "11",
8, 0, 1, '.', 0, 8, 0, 1, '.', 0,
"本\tb\tc\n" "本\tb\tc\n" +
"aa\t\u672c\u672c\u672c\tcccc\tddddd\n" "aa\t\u672c\u672c\u672c\tcccc\tddddd\n" +
"aaa\tbbbb\n", "aaa\tbbbb\n",
"本.......b.......c\n" "本.......b.......c\n" +
"aa......本本本.....cccc....ddddd\n" "aa......本本本.....cccc....ddddd\n" +
"aaa.....bbbb\n", "aaa.....bbbb\n",
}, },
entry{ entry{
"12a", "12a",
8, 0, 1, ' ', AlignRight, 8, 0, 1, ' ', AlignRight,
"a\tè\tc\t\n" "a\tè\tc\t\n" +
"aa\tèèè\tcccc\tddddd\t\n" "aa\tèèè\tcccc\tddddd\t\n" +
"aaa\tèèèè\t\n", "aaa\tèèèè\t\n",
" a è c\n" " a è c\n" +
" aa èèè cccc ddddd\n" " aa èèè cccc ddddd\n" +
" aaa èèèè\n", " aaa èèèè\n",
}, },
entry{ entry{
"12b", "12b",
2, 0, 0, ' ', 0, 2, 0, 0, ' ', 0,
"a\tb\tc\n" "a\tb\tc\n" +
"aa\tbbb\tcccc\n" "aa\tbbb\tcccc\n" +
"aaa\tbbbb\n", "aaa\tbbbb\n",
"a b c\n" "a b c\n" +
"aa bbbcccc\n" "aa bbbcccc\n" +
"aaabbbb\n", "aaabbbb\n",
}, },
entry{ entry{
"12c", "12c",
8, 0, 1, '_', 0, 8, 0, 1, '_', 0,
"a\tb\tc\n" "a\tb\tc\n" +
"aa\tbbb\tcccc\n" "aa\tbbb\tcccc\n" +
"aaa\tbbbb\n", "aaa\tbbbb\n",
"a_______b_______c\n" "a_______b_______c\n" +
"aa______bbb_____cccc\n" "aa______bbb_____cccc\n" +
"aaa_____bbbb\n", "aaa_____bbbb\n",
}, },
entry{ entry{
"13a", "13a",
4, 0, 1, '-', 0, 4, 0, 1, '-', 0,
"4444\t日本語\t22\t1\t333\n" "4444\t日本語\t22\t1\t333\n" +
"999999999\t22\n" "999999999\t22\n" +
"7\t22\n" "7\t22\n" +
"\t\t\t88888888\n" "\t\t\t88888888\n" +
"\n" "\n" +
"666666\t666666\t666666\t4444\n" "666666\t666666\t666666\t4444\n" +
"1\t1\t999999999\t0000000000\n", "1\t1\t999999999\t0000000000\n",
"4444------日本語-22--1---333\n" "4444------日本語-22--1---333\n" +
"999999999-22\n" "999999999-22\n" +
"7---------22\n" "7---------22\n" +
"------------------88888888\n" "------------------88888888\n" +
"\n" "\n" +
"666666-666666-666666----4444\n" "666666-666666-666666----4444\n" +
"1------1------999999999-0000000000\n", "1------1------999999999-0000000000\n",
}, },
entry{ entry{
"13b", "13b",
4, 0, 3, '.', 0, 4, 0, 3, '.', 0,
"4444\t333\t22\t1\t333\n" "4444\t333\t22\t1\t333\n" +
"999999999\t22\n" "999999999\t22\n" +
"7\t22\n" "7\t22\n" +
"\t\t\t88888888\n" "\t\t\t88888888\n" +
"\n" "\n" +
"666666\t666666\t666666\t4444\n" "666666\t666666\t666666\t4444\n" +
"1\t1\t999999999\t0000000000\n", "1\t1\t999999999\t0000000000\n",
"4444........333...22...1...333\n" "4444........333...22...1...333\n" +
"999999999...22\n" "999999999...22\n" +
"7...........22\n" "7...........22\n" +
"....................88888888\n" "....................88888888\n" +
"\n" "\n" +
"666666...666666...666666......4444\n" "666666...666666...666666......4444\n" +
"1........1........999999999...0000000000\n", "1........1........999999999...0000000000\n",
}, },
entry{ entry{
"13c", "13c",
8, 8, 1, '\t', FilterHTML, 8, 8, 1, '\t', FilterHTML,
"4444\t333\t22\t1\t333\n" "4444\t333\t22\t1\t333\n" +
"999999999\t22\n" "999999999\t22\n" +
"7\t22\n" "7\t22\n" +
"\t\t\t88888888\n" "\t\t\t88888888\n" +
"\n" "\n" +
"666666\t666666\t666666\t4444\n" "666666\t666666\t666666\t4444\n" +
"1\t1\t<font color=red attr=日本語>999999999</font>\t0000000000\n", "1\t1\t<font color=red attr=日本語>999999999</font>\t0000000000\n",
"4444\t\t333\t22\t1\t333\n" "4444\t\t333\t22\t1\t333\n" +
"999999999\t22\n" "999999999\t22\n" +
"7\t\t22\n" "7\t\t22\n" +
"\t\t\t\t88888888\n" "\t\t\t\t88888888\n" +
"\n" "\n" +
"666666\t666666\t666666\t\t4444\n" "666666\t666666\t666666\t\t4444\n" +
"1\t1\t<font color=red attr=日本語>999999999</font>\t0000000000\n", "1\t1\t<font color=red attr=日本語>999999999</font>\t0000000000\n",
}, },
entry{ entry{
"14", "14",
1, 0, 2, ' ', AlignRight, 1, 0, 2, ' ', AlignRight,
".0\t.3\t2.4\t-5.1\t\n" ".0\t.3\t2.4\t-5.1\t\n" +
"23.0\t12345678.9\t2.4\t-989.4\t\n" "23.0\t12345678.9\t2.4\t-989.4\t\n" +
"5.1\t12.0\t2.4\t-7.0\t\n" "5.1\t12.0\t2.4\t-7.0\t\n" +
".0\t0.0\t332.0\t8908.0\t\n" ".0\t0.0\t332.0\t8908.0\t\n" +
".0\t-.3\t456.4\t22.1\t\n" ".0\t-.3\t456.4\t22.1\t\n" +
".0\t1.2\t44.4\t-13.3\t\t", ".0\t1.2\t44.4\t-13.3\t\t",
" .0 .3 2.4 -5.1\n" " .0 .3 2.4 -5.1\n" +
" 23.0 12345678.9 2.4 -989.4\n" " 23.0 12345678.9 2.4 -989.4\n" +
" 5.1 12.0 2.4 -7.0\n" " 5.1 12.0 2.4 -7.0\n" +
" .0 0.0 332.0 8908.0\n" " .0 0.0 332.0 8908.0\n" +
" .0 -.3 456.4 22.1\n" " .0 -.3 456.4 22.1\n" +
" .0 1.2 44.4 -13.3", " .0 1.2 44.4 -13.3",
}, },
entry{ entry{
"14 debug", "14 debug",
1, 0, 2, ' ', AlignRight | Debug, 1, 0, 2, ' ', AlignRight | Debug,
".0\t.3\t2.4\t-5.1\t\n" ".0\t.3\t2.4\t-5.1\t\n" +
"23.0\t12345678.9\t2.4\t-989.4\t\n" "23.0\t12345678.9\t2.4\t-989.4\t\n" +
"5.1\t12.0\t2.4\t-7.0\t\n" "5.1\t12.0\t2.4\t-7.0\t\n" +
".0\t0.0\t332.0\t8908.0\t\n" ".0\t0.0\t332.0\t8908.0\t\n" +
".0\t-.3\t456.4\t22.1\t\n" ".0\t-.3\t456.4\t22.1\t\n" +
".0\t1.2\t44.4\t-13.3\t\t", ".0\t1.2\t44.4\t-13.3\t\t",
" .0| .3| 2.4| -5.1|\n" " .0| .3| 2.4| -5.1|\n" +
" 23.0| 12345678.9| 2.4| -989.4|\n" " 23.0| 12345678.9| 2.4| -989.4|\n" +
" 5.1| 12.0| 2.4| -7.0|\n" " 5.1| 12.0| 2.4| -7.0|\n" +
" .0| 0.0| 332.0| 8908.0|\n" " .0| 0.0| 332.0| 8908.0|\n" +
" .0| -.3| 456.4| 22.1|\n" " .0| -.3| 456.4| 22.1|\n" +
" .0| 1.2| 44.4| -13.3|", " .0| 1.2| 44.4| -13.3|",
}, },
...@@ -510,80 +510,80 @@ var tests = []entry{ ...@@ -510,80 +510,80 @@ var tests = []entry{
entry{ entry{
"16a", "16a",
100, 100, 0, '\t', 0, 100, 100, 0, '\t', 0,
"a\tb\t\td\n" "a\tb\t\td\n" +
"a\tb\t\td\te\n" "a\tb\t\td\te\n" +
"a\n" "a\n" +
"a\tb\tc\td\n" "a\tb\tc\td\n" +
"a\tb\tc\td\te\n", "a\tb\tc\td\te\n",
"a\tb\t\td\n" "a\tb\t\td\n" +
"a\tb\t\td\te\n" "a\tb\t\td\te\n" +
"a\n" "a\n" +
"a\tb\tc\td\n" "a\tb\tc\td\n" +
"a\tb\tc\td\te\n", "a\tb\tc\td\te\n",
}, },
entry{ entry{
"16b", "16b",
100, 100, 0, '\t', DiscardEmptyColumns, 100, 100, 0, '\t', DiscardEmptyColumns,
"a\vb\v\vd\n" "a\vb\v\vd\n" +
"a\vb\v\vd\ve\n" "a\vb\v\vd\ve\n" +
"a\n" "a\n" +
"a\vb\vc\vd\n" "a\vb\vc\vd\n" +
"a\vb\vc\vd\ve\n", "a\vb\vc\vd\ve\n",
"a\tb\td\n" "a\tb\td\n" +
"a\tb\td\te\n" "a\tb\td\te\n" +
"a\n" "a\n" +
"a\tb\tc\td\n" "a\tb\tc\td\n" +
"a\tb\tc\td\te\n", "a\tb\tc\td\te\n",
}, },
entry{ entry{
"16b debug", "16b debug",
100, 100, 0, '\t', DiscardEmptyColumns | Debug, 100, 100, 0, '\t', DiscardEmptyColumns | Debug,
"a\vb\v\vd\n" "a\vb\v\vd\n" +
"a\vb\v\vd\ve\n" "a\vb\v\vd\ve\n" +
"a\n" "a\n" +
"a\vb\vc\vd\n" "a\vb\vc\vd\n" +
"a\vb\vc\vd\ve\n", "a\vb\vc\vd\ve\n",
"a\t|b\t||d\n" "a\t|b\t||d\n" +
"a\t|b\t||d\t|e\n" "a\t|b\t||d\t|e\n" +
"a\n" "a\n" +
"a\t|b\t|c\t|d\n" "a\t|b\t|c\t|d\n" +
"a\t|b\t|c\t|d\t|e\n", "a\t|b\t|c\t|d\t|e\n",
}, },
entry{ entry{
"16c", "16c",
100, 100, 0, '\t', DiscardEmptyColumns, 100, 100, 0, '\t', DiscardEmptyColumns,
"a\tb\t\td\n" // hard tabs - do not discard column "a\tb\t\td\n" + // hard tabs - do not discard column
"a\tb\t\td\te\n" "a\tb\t\td\te\n" +
"a\n" "a\n" +
"a\tb\tc\td\n" "a\tb\tc\td\n" +
"a\tb\tc\td\te\n", "a\tb\tc\td\te\n",
"a\tb\t\td\n" "a\tb\t\td\n" +
"a\tb\t\td\te\n" "a\tb\t\td\te\n" +
"a\n" "a\n" +
"a\tb\tc\td\n" "a\tb\tc\td\n" +
"a\tb\tc\td\te\n", "a\tb\tc\td\te\n",
}, },
entry{ entry{
"16c debug", "16c debug",
100, 100, 0, '\t', DiscardEmptyColumns | Debug, 100, 100, 0, '\t', DiscardEmptyColumns | Debug,
"a\tb\t\td\n" // hard tabs - do not discard column "a\tb\t\td\n" + // hard tabs - do not discard column
"a\tb\t\td\te\n" "a\tb\t\td\te\n" +
"a\n" "a\n" +
"a\tb\tc\td\n" "a\tb\tc\td\n" +
"a\tb\tc\td\te\n", "a\tb\tc\td\te\n",
"a\t|b\t|\t|d\n" "a\t|b\t|\t|d\n" +
"a\t|b\t|\t|d\t|e\n" "a\t|b\t|\t|d\t|e\n" +
"a\n" "a\n" +
"a\t|b\t|c\t|d\n" "a\t|b\t|c\t|d\n" +
"a\t|b\t|c\t|d\t|e\n", "a\t|b\t|c\t|d\t|e\n",
}, },
} }
......
...@@ -97,62 +97,62 @@ var tests = []*Test{ ...@@ -97,62 +97,62 @@ var tests = []*Test{
// Section // Section
&Test{ &Test{
in: "{.section data }\n" in: "{.section data }\n" +
"some text for the section\n" "some text for the section\n" +
"{.end}\n", "{.end}\n",
out: "some text for the section\n", out: "some text for the section\n",
}, },
&Test{ &Test{
in: "{.section data }\n" in: "{.section data }\n" +
"{header}={integer}\n" "{header}={integer}\n" +
"{.end}\n", "{.end}\n",
out: "Header=77\n", out: "Header=77\n",
}, },
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"{header}={integer}\n" "{header}={integer}\n" +
"{.end}\n", "{.end}\n",
out: "Header=77\n", out: "Header=77\n",
}, },
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"data present\n" "data present\n" +
"{.or}\n" "{.or}\n" +
"data not present\n" "data not present\n" +
"{.end}\n", "{.end}\n",
out: "data present\n", out: "data present\n",
}, },
&Test{ &Test{
in: "{.section empty }\n" in: "{.section empty }\n" +
"data present\n" "data present\n" +
"{.or}\n" "{.or}\n" +
"data not present\n" "data not present\n" +
"{.end}\n", "{.end}\n",
out: "data not present\n", out: "data not present\n",
}, },
&Test{ &Test{
in: "{.section null }\n" in: "{.section null }\n" +
"data present\n" "data present\n" +
"{.or}\n" "{.or}\n" +
"data not present\n" "data not present\n" +
"{.end}\n", "{.end}\n",
out: "data not present\n", out: "data not present\n",
}, },
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"{header}={integer}\n" "{header}={integer}\n" +
"{.section @ }\n" "{.section @ }\n" +
"{header}={integer}\n" "{header}={integer}\n" +
"{.end}\n" "{.end}\n" +
"{.end}\n", "{.end}\n",
out: "Header=77\n" out: "Header=77\n" +
"Header=77\n", "Header=77\n",
}, },
&Test{ &Test{
...@@ -163,69 +163,69 @@ var tests = []*Test{ ...@@ -163,69 +163,69 @@ var tests = []*Test{
// Repeated // Repeated
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"{.repeated section @ }\n" "{.repeated section @ }\n" +
"{item}={value}\n" "{item}={value}\n" +
"{.end}\n" "{.end}\n" +
"{.end}\n", "{.end}\n",
out: "ItemNumber1=ValueNumber1\n" out: "ItemNumber1=ValueNumber1\n" +
"ItemNumber2=ValueNumber2\n", "ItemNumber2=ValueNumber2\n",
}, },
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"{.repeated section @ }\n" "{.repeated section @ }\n" +
"{item}={value}\n" "{item}={value}\n" +
"{.or}\n" "{.or}\n" +
"this should not appear\n" "this should not appear\n" +
"{.end}\n" "{.end}\n" +
"{.end}\n", "{.end}\n",
out: "ItemNumber1=ValueNumber1\n" out: "ItemNumber1=ValueNumber1\n" +
"ItemNumber2=ValueNumber2\n", "ItemNumber2=ValueNumber2\n",
}, },
&Test{ &Test{
in: "{.section @ }\n" in: "{.section @ }\n" +
"{.repeated section empty }\n" "{.repeated section empty }\n" +
"{item}={value}\n" "{item}={value}\n" +
"{.or}\n" "{.or}\n" +
"this should appear: empty field\n" "this should appear: empty field\n" +
"{.end}\n" "{.end}\n" +
"{.end}\n", "{.end}\n",
out: "this should appear: empty field\n", out: "this should appear: empty field\n",
}, },
&Test{ &Test{
in: "{.repeated section pdata }\n" in: "{.repeated section pdata }\n" +
"{item}\n" "{item}\n" +
"{.alternates with}\n" "{.alternates with}\n" +
"is\nover\nmultiple\nlines\n" "is\nover\nmultiple\nlines\n" +
"{.end}\n", "{.end}\n",
out: "ItemNumber1\n" out: "ItemNumber1\n" +
"is\nover\nmultiple\nlines\n" "is\nover\nmultiple\nlines\n" +
"ItemNumber2\n", "ItemNumber2\n",
}, },
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"{.repeated section @ }\n" "{.repeated section @ }\n" +
"{item}={value}\n" "{item}={value}\n" +
"{.alternates with}DIVIDER\n" "{.alternates with}DIVIDER\n" +
"{.or}\n" "{.or}\n" +
"this should not appear\n" "this should not appear\n" +
"{.end}\n" "{.end}\n" +
"{.end}\n", "{.end}\n",
out: "ItemNumber1=ValueNumber1\n" out: "ItemNumber1=ValueNumber1\n" +
"DIVIDER\n" "DIVIDER\n" +
"ItemNumber2=ValueNumber2\n", "ItemNumber2=ValueNumber2\n",
}, },
&Test{ &Test{
in: "{.repeated section vec }\n" in: "{.repeated section vec }\n" +
"{@}\n" "{@}\n" +
"{.end}\n", "{.end}\n",
out: "elt1\n" out: "elt1\n" +
"elt2\n", "elt2\n",
}, },
&Test{ &Test{
...@@ -236,15 +236,15 @@ var tests = []*Test{ ...@@ -236,15 +236,15 @@ var tests = []*Test{
// Nested names // Nested names
&Test{ &Test{
in: "{.section @ }\n" in: "{.section @ }\n" +
"{innerT.item}={innerT.value}\n" "{innerT.item}={innerT.value}\n" +
"{.end}", "{.end}",
out: "ItemNumber1=ValueNumber1\n", out: "ItemNumber1=ValueNumber1\n",
}, },
&Test{ &Test{
in: "{.section @ }\n" in: "{.section @ }\n" +
"{innerT.item}={.section innerT}{.section value}{@}{.end}{.end}\n" "{innerT.item}={.section innerT}{.section value}{@}{.end}{.end}\n" +
"{.end}", "{.end}",
out: "ItemNumber1=ValueNumber1\n", out: "ItemNumber1=ValueNumber1\n",
...@@ -253,32 +253,32 @@ var tests = []*Test{ ...@@ -253,32 +253,32 @@ var tests = []*Test{
// Formatters // Formatters
&Test{ &Test{
in: "{.section pdata }\n" in: "{.section pdata }\n" +
"{header|uppercase}={integer|+1}\n" "{header|uppercase}={integer|+1}\n" +
"{header|html}={integer|str}\n" "{header|html}={integer|str}\n" +
"{.end}\n", "{.end}\n",
out: "HEADER=78\n" out: "HEADER=78\n" +
"Header=77\n", "Header=77\n",
}, },
&Test{ &Test{
in: "{raw}\n" in: "{raw}\n" +
"{raw|html}\n", "{raw|html}\n",
out: "&<>!@ #$%^\n" out: "&<>!@ #$%^\n" +
"&amp;&lt;&gt;!@ #$%^\n", "&amp;&lt;&gt;!@ #$%^\n",
}, },
&Test{ &Test{
in: "{.section emptystring}emptystring{.end}\n" in: "{.section emptystring}emptystring{.end}\n" +
"{.section header}header{.end}\n", "{.section header}header{.end}\n",
out: "\nheader\n", out: "\nheader\n",
}, },
&Test{ &Test{
in: "{.section true}1{.or}2{.end}\n" in: "{.section true}1{.or}2{.end}\n" +
"{.section false}3{.or}4{.end}\n", "{.section false}3{.or}4{.end}\n",
out: "1\n4\n", out: "1\n4\n",
......
...@@ -313,9 +313,9 @@ func printCategories() { ...@@ -313,9 +313,9 @@ func printCategories() {
return; return;
} }
fmt.Printf( fmt.Printf(
"// Generated by running\n" "// Generated by running\n"+
"// maketables --tables=%s --data=%s\n" "// maketables --tables=%s --data=%s\n"+
"// DO NOT EDIT\n\n" "// DO NOT EDIT\n\n"+
"package unicode\n\n", "package unicode\n\n",
*tablelist, *tablelist,
*dataURL); *dataURL);
...@@ -590,8 +590,8 @@ func printScriptOrProperty(doProps bool) { ...@@ -590,8 +590,8 @@ func printScriptOrProperty(doProps bool) {
} }
fmt.Printf( fmt.Printf(
"// Generated by running\n" "// Generated by running\n"+
"// maketables --%s=%s --url=%s\n" "// maketables --%s=%s --url=%s\n"+
"// DO NOT EDIT\n\n", "// DO NOT EDIT\n\n",
flag, flag,
flaglist, flaglist,
...@@ -777,12 +777,12 @@ func printCases() { ...@@ -777,12 +777,12 @@ func printCases() {
return; return;
} }
fmt.Printf( fmt.Printf(
"// Generated by running\n" "// Generated by running\n"+
"// maketables --data=%s\n" "// maketables --data=%s\n"+
"// DO NOT EDIT\n\n" "// DO NOT EDIT\n\n"+
"// CaseRanges is the table describing case mappings for all letters with\n" "// CaseRanges is the table describing case mappings for all letters with\n"+
"// non-self mappings.\n" "// non-self mappings.\n"+
"var CaseRanges = _CaseRanges\n" "var CaseRanges = _CaseRanges\n"+
"var _CaseRanges = []CaseRange {\n", "var _CaseRanges = []CaseRange {\n",
*dataURL); *dataURL);
......
...@@ -16,8 +16,8 @@ const testInput = ` ...@@ -16,8 +16,8 @@ const testInput = `
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body xmlns:foo="ns1" xmlns="ns2" xmlns:tag="ns3" ` <body xmlns:foo="ns1" xmlns="ns2" xmlns:tag="ns3" ` +
"\r\n\t" ` > "\r\n\t" + ` >
<hello lang="en">World &lt;&gt;&apos;&quot; &#x767d;&#40300;翔</hello> <hello lang="en">World &lt;&gt;&apos;&quot; &#x767d;&#40300;翔</hello>
<goodbye /> <goodbye />
<outer foo:attr="value" xmlns:tag="ns4"> <outer foo:attr="value" xmlns:tag="ns4">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment