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
47424d90
Commit
47424d90
authored
Feb 14, 2012
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
text/template: drop reference to os.EPERM in the test
R=golang-dev, gri CC=golang-dev
https://golang.org/cl/5654077
parent
28ffb38f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
src/pkg/text/template/exec_test.go
src/pkg/text/template/exec_test.go
+10
-9
No files found.
src/pkg/text/template/exec_test.go
View file @
47424d90
...
...
@@ -9,7 +9,6 @@ import (
"errors"
"flag"
"fmt"
"os"
"reflect"
"strings"
"testing"
...
...
@@ -168,10 +167,12 @@ func (t *T) MAdd(a int, b []int) []int {
return
v
}
// EPERM returns a value and an error according to its argument.
func
(
t
*
T
)
EPERM
(
error
bool
)
(
bool
,
error
)
{
var
myError
=
errors
.
New
(
"my error"
)
// MyError returns a value and an error according to its argument.
func
(
t
*
T
)
MyError
(
error
bool
)
(
bool
,
error
)
{
if
error
{
return
true
,
os
.
EPERM
return
true
,
myError
}
return
false
,
nil
}
...
...
@@ -417,8 +418,8 @@ var execTests = []execTest{
{
"or as if false"
,
`{{or .SIEmpty "slice is empty"}}`
,
"slice is empty"
,
tVal
,
true
},
// Error handling.
{
"error method, error"
,
"{{.
EPERM
true}}"
,
""
,
tVal
,
false
},
{
"error method, no error"
,
"{{.
EPERM
false}}"
,
"false"
,
tVal
,
true
},
{
"error method, error"
,
"{{.
MyError
true}}"
,
""
,
tVal
,
false
},
{
"error method, no error"
,
"{{.
MyError
false}}"
,
"false"
,
tVal
,
true
},
// Fixed bugs.
// Must separate dot and receiver; otherwise args are evaluated with dot set to variable.
...
...
@@ -565,18 +566,18 @@ func TestDelims(t *testing.T) {
func
TestExecuteError
(
t
*
testing
.
T
)
{
b
:=
new
(
bytes
.
Buffer
)
tmpl
:=
New
(
"error"
)
_
,
err
:=
tmpl
.
Parse
(
"{{.
EPERM
true}}"
)
_
,
err
:=
tmpl
.
Parse
(
"{{.
MyError
true}}"
)
if
err
!=
nil
{
t
.
Fatalf
(
"parse error: %s"
,
err
)
}
err
=
tmpl
.
Execute
(
b
,
tVal
)
if
err
==
nil
{
t
.
Errorf
(
"expected error; got none"
)
}
else
if
!
strings
.
Contains
(
err
.
Error
(),
os
.
EPERM
.
Error
())
{
}
else
if
!
strings
.
Contains
(
err
.
Error
(),
myError
.
Error
())
{
if
*
debug
{
fmt
.
Printf
(
"test execute error: %s
\n
"
,
err
)
}
t
.
Errorf
(
"expected
os.EPERM
; got %s"
,
err
)
t
.
Errorf
(
"expected
myError
; got %s"
,
err
)
}
}
...
...
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