printer: constraints formatting (#209)
Uses `buildtag.Format` to format constraints in the assembly and stub file printers. This will ensure `// + build` and `//go:build` syntax are used consistent with the current Go version. Updates #183
This commit is contained in:
committed by
GitHub
parent
55d98ccf77
commit
79bee1a316
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/mmcloughlin/avo/attr"
|
||||
"github.com/mmcloughlin/avo/build"
|
||||
"github.com/mmcloughlin/avo/buildtags"
|
||||
"github.com/mmcloughlin/avo/printer"
|
||||
"github.com/mmcloughlin/avo/reg"
|
||||
)
|
||||
@@ -73,13 +74,24 @@ func TestConstraints(t *testing.T) {
|
||||
ctx.ConstraintExpr("linux,386 darwin,!cgo")
|
||||
ctx.ConstraintExpr("!noasm")
|
||||
|
||||
AssertPrintsLines(t, ctx, printer.NewGoAsm, []string{
|
||||
expect := []string{
|
||||
"// Code generated by avo. DO NOT EDIT.",
|
||||
"",
|
||||
"// +build linux,386 darwin,!cgo",
|
||||
"// +build !noasm",
|
||||
"",
|
||||
})
|
||||
}
|
||||
if buildtags.GoBuildSyntaxSupported() {
|
||||
expect = append(expect,
|
||||
"//go:build ((linux && 386) || (darwin && !cgo)) && !noasm",
|
||||
)
|
||||
}
|
||||
if buildtags.PlusBuildSyntaxSupported() {
|
||||
expect = append(expect,
|
||||
"// +build linux,386 darwin,!cgo",
|
||||
"// +build !noasm",
|
||||
)
|
||||
}
|
||||
expect = append(expect, "")
|
||||
|
||||
AssertPrintsLines(t, ctx, printer.NewGoAsm, expect)
|
||||
}
|
||||
|
||||
func TestAlignmentNoOperands(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user