Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
cf8b9ce5
Commit
cf8b9ce5
authored
Apr 14, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test & fix template used twice
R=r DELTA=30 (30 added, 0 deleted, 0 changed) OCL=27470 CL=27474
parent
fa602260
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
src/lib/template/template.go
src/lib/template/template.go
+1
-0
src/lib/template/template_test.go
src/lib/template/template_test.go
+29
-0
No files found.
src/lib/template/template.go
View file @
cf8b9ce5
...
...
@@ -514,6 +514,7 @@ func (t *Template) Execute(data interface{}, wr io.Write) *os.Error {
val
:=
reflect
.
NewValue
(
data
);
ch
:=
make
(
chan
*
os
.
Error
);
go
func
()
{
t
.
p
=
0
;
t
.
execute
(
&
state
{
nil
,
ch
,
val
,
wr
});
ch
<-
nil
;
// clean return;
}();
...
...
src/lib/template/template_test.go
View file @
cf8b9ce5
...
...
@@ -199,8 +199,37 @@ func TestStringDriverType(t *testing.T) {
}
var
b
io
.
ByteBuffer
;
err
=
tmpl
.
Execute
(
"hello"
,
&
b
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
s
:=
string
(
b
.
Data
());
if
s
!=
"template: hello"
{
t
.
Errorf
(
"failed passing string as data: expected %q got %q"
,
"template: hello"
,
s
)
}
}
func
TestTwice
(
t
*
testing
.
T
)
{
tmpl
,
err
,
line
:=
Parse
(
"template: {@}"
,
nil
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
var
b
io
.
ByteBuffer
;
err
=
tmpl
.
Execute
(
"hello"
,
&
b
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
s
:=
string
(
b
.
Data
());
text
:=
"template: hello"
;
if
s
!=
text
{
t
.
Errorf
(
"failed passing string as data: expected %q got %q"
,
text
,
s
);
}
err
=
tmpl
.
Execute
(
"hello"
,
&
b
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
s
=
string
(
b
.
Data
());
text
+=
text
;
if
s
!=
text
{
t
.
Errorf
(
"failed passing string as data: expected %q got %q"
,
text
,
s
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment