ccffer (Corner Case Faker Fuzzer) is
Only supports Go v1.18 and higher.
ccffer is licensed under the MIT
License: MIT License
templateをつかって
type X interface {
~int | ~string
}
func F[T X](v T) {
println(v + v)
println(string(v))
println(any(v).(int))
}
この関数に対して
package main_test
import "testing"
func TestF(t *testing.T) {
F(42)
F("42")
}
を作る
気づいたことを書いていきます
文脈をわからずに書いているので、気に入ったら修正してもらえるといいと思います。
これで実際のGoの型が取れるか?
いちいちMatchをかくしかないのか
var TypeVals map[string][]string = map[string][]string{
"bool": {"true", "false"},
"string": {"\"\""},
"int": {"0", "-(1 << 31) - 1", "1 << 31"},
"int64": {"0", "-(1 << 63) - 1", "1 << 63"},
"uint": {"0", "^uint(0)"},
// TODO: import math library by formatting test
// "float32": []string{"0", "math.NaN()", "math.Inf(0)", "math.Inf(-1)"},
}
静的解析して得た関数のデータを, コード生成用のデータに詰める
types.Instantiateはあるけど, astはInstantiateできない??
とりあえず単一のソースの中にある関数の定義のリストと構造体定義のリストを作る
package main
import (
"fmt"
)
func SignleArg(a int) {
fmt.Print(a)
}
func SignleRes() int {
return 42
}
func NamedRes() (g int) {
g = 42
return
}
func main() {
SignleArg(13)
_ = SignleRes()
_ = NamedRes()
}
package main
type (
A struct {
X int
}
B struct {
Y int
}
C interface {
C()
}
)
func StructF(a A) B {
return B{a.X}
}
func main() {
_ = StructF(A{})
}
package main
func SignleTypeParam[T any](a T) T {
return a
}
func TypeConstraint1[T comparable](a, b T) bool {
return a == b
}
func main() {
SignleTypeParam("hoge")
SignleTypeParam(13)
TypeConstraint1(1, 2)
TypeConstraint1("1,2", "2,3")
}
"go/parser", "go/token"を使ってとる
部分的なコードを実行したい時, ASTを取ってくるのが良いのか, それとも文字列を実行するのがいいのか
types.Eval()を使う
func main2() {
fmt.Print("hello")
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.