mirror of
https://github.com/golang/go
synced 2024-11-22 02:24:41 -07:00
exp/template: silence test noise (but add a flag to put it back)
Also delete a TODO and clean up a little evaluation code. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/4643071
This commit is contained in:
parent
33705ddea1
commit
64228e36a4
@ -200,8 +200,7 @@ func (s *state) evalCommand(data reflect.Value, cmd *commandNode, final reflect.
|
|||||||
return s.evalFieldOrCall(data, n.ident, cmd.args, final)
|
return s.evalFieldOrCall(data, n.ident, cmd.args, final)
|
||||||
}
|
}
|
||||||
if len(cmd.args) > 1 || final.IsValid() {
|
if len(cmd.args) > 1 || final.IsValid() {
|
||||||
// TODO: functions
|
s.errorf("can't give argument to non-function %s", cmd.args[0])
|
||||||
s.errorf("can't give argument to non-method %s", cmd.args[0])
|
|
||||||
}
|
}
|
||||||
switch word := cmd.args[0].(type) {
|
switch word := cmd.args[0].(type) {
|
||||||
case *dotNode:
|
case *dotNode:
|
||||||
@ -224,9 +223,8 @@ func (s *state) evalCommand(data reflect.Value, cmd *commandNode, final reflect.
|
|||||||
}
|
}
|
||||||
case *stringNode:
|
case *stringNode:
|
||||||
return reflect.ValueOf(word.text)
|
return reflect.ValueOf(word.text)
|
||||||
default:
|
|
||||||
s.errorf("can't handle command %q", firstWord)
|
|
||||||
}
|
}
|
||||||
|
s.errorf("can't handle command %q", firstWord)
|
||||||
panic("not reached")
|
panic("not reached")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
package template
|
package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
const dumpErrors = true
|
var debug = flag.Bool("debug", false, "show the errors produced by the tests")
|
||||||
|
|
||||||
type numberTest struct {
|
type numberTest struct {
|
||||||
text string
|
text string
|
||||||
@ -193,7 +194,7 @@ func TestParse(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
case err != nil && !test.ok:
|
case err != nil && !test.ok:
|
||||||
// expected error, got one
|
// expected error, got one
|
||||||
if dumpErrors {
|
if *debug {
|
||||||
fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
|
fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
@ -49,7 +49,7 @@ func TestSetParse(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
case err != nil && !test.ok:
|
case err != nil && !test.ok:
|
||||||
// expected error, got one
|
// expected error, got one
|
||||||
if dumpErrors {
|
if *debug {
|
||||||
fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
|
fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user