OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package template | 5 package template |
6 | 6 |
7 import ( | 7 import ( |
8 "reflect" | 8 "reflect" |
9 "testing" | 9 "testing" |
10 ) | 10 ) |
(...skipping 28 matching lines...) Expand all Loading... |
39 tLeft, | 39 tLeft, |
40 {itemNumber, "1"}, | 40 {itemNumber, "1"}, |
41 {itemNumber, "02"}, | 41 {itemNumber, "02"}, |
42 {itemNumber, "0x14"}, | 42 {itemNumber, "0x14"}, |
43 {itemNumber, "-7.2i"}, | 43 {itemNumber, "-7.2i"}, |
44 {itemNumber, "1e3"}, | 44 {itemNumber, "1e3"}, |
45 {itemNumber, "+1.2e-4"}, | 45 {itemNumber, "+1.2e-4"}, |
46 tRight, | 46 tRight, |
47 tEOF, | 47 tEOF, |
48 }}, | 48 }}, |
49 » {"dots", "{{.x . .2 .x.y }}", []item{ | 49 » {"dot", "{{.}}", []item{ |
| 50 » » tLeft, |
| 51 » » {itemDot, "."}, |
| 52 » » tRight, |
| 53 » » tEOF, |
| 54 » }}, |
| 55 » {"dots", "{{.x . .2 .x.y}}", []item{ |
50 tLeft, | 56 tLeft, |
51 {itemField, ".x"}, | 57 {itemField, ".x"}, |
52 {itemDot, "."}, | 58 {itemDot, "."}, |
53 {itemNumber, ".2"}, | 59 {itemNumber, ".2"}, |
54 » » {itemField, ".x"}, | 60 » » {itemField, ".x.y"}, |
55 » » {itemField, ".y"}, | |
56 tRight, | 61 tRight, |
57 tEOF, | 62 tEOF, |
58 }}, | 63 }}, |
59 {"keywords", "{{range if else end}}", []item{ | 64 {"keywords", "{{range if else end}}", []item{ |
60 tLeft, | 65 tLeft, |
61 {itemRange, "range"}, | 66 {itemRange, "range"}, |
62 {itemIf, "if"}, | 67 {itemIf, "if"}, |
63 {itemElse, "else"}, | 68 {itemElse, "else"}, |
64 {itemEnd, "end"}, | 69 {itemEnd, "end"}, |
65 tRight, | 70 tRight, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 125 } |
121 | 126 |
122 func TestLex(t *testing.T) { | 127 func TestLex(t *testing.T) { |
123 for _, test := range lexTests { | 128 for _, test := range lexTests { |
124 items := collect(&test) | 129 items := collect(&test) |
125 if !reflect.DeepEqual(items, test.items) { | 130 if !reflect.DeepEqual(items, test.items) { |
126 t.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, ite
ms, test.items) | 131 t.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, ite
ms, test.items) |
127 } | 132 } |
128 } | 133 } |
129 } | 134 } |
OLD | NEW |