You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
garble/testdata/scripts/syntax.txt

110 lines
1.7 KiB
Plaintext

env GOPRIVATE=test/main
garble -debugdir=debug build
exec ./main$exe
cmp stderr main.stderr
! binsubstr main$exe 'localName' 'globalConst' 'globalVar' 'globalType' 'valuable information'
binsubstr debug/main/scopes.go 'localName' 'globalConst'
[short] stop # no need to verify this with -short
go build
exec ./main$exe
cmp stderr main.stderr
binsubstr main$exe 'globalVar' # 'globalType' only matches on go < 1.15
! binsubstr main$exe 'localName' 'globalConst'
-- go.mod --
module test/main
-- main.go --
package main
import (
"encoding/json"
"go/ast"
)
// This comment contains valuable information. Ensure it's not in the final binary.
var V interface{}
type T struct {
ast.Node
*ast.Ident
}
type EncodingT struct {
Foo int
}
type Embedded int
type Embedding struct {
Embedded
}
type embedded int
type embedding struct {
embedded
}
// embedded fields whose type is in the universe scope used to crash garble
type EmbeddingUniverseScope struct {
error
int
string
}
func main() {
switch V := V.(type) {
case int:
var _ int = V
case nil:
println("nil case")
}
enc, _ := json.Marshal(EncodingT{Foo: 3})
println(string(enc))
scopesTest()
}
-- scopes.go --
package main
const globalConst = 1
type globalType int
var (
globalVar = 1
globalVarTyped globalType = 1
)
func scopesTest() {
println(globalVar, globalConst, globalVarTyped)
const localNameConst = 1
localNameShort := 4
type localNameType int
var (
localNameVar = 5
localNameTypeVar localNameType = 1
)
println(localNameConst, localNameShort, localNameVar, localNameTypeVar, input("input"))
}
func input(localNameParam string) (localNameReturn string) { return localNameParam }
-- main.stderr --
nil case
{"Foo":3}
1 1 1
1 4 5 1 input