TestPrintf

This commit is contained in:
xushiwei
2024-04-20 13:50:48 +08:00
parent 6a359a4d4d
commit 1ec438a361
3 changed files with 66 additions and 17 deletions

View File

@@ -192,6 +192,21 @@ define { i64, double } @fn(double %0) {
`)
}
func TestPrintf(t *testing.T) {
prog := NewProgram(nil)
pkg := prog.NewPackage("bar", "foo/bar")
pchar := types.NewPointer(types.Typ[types.Int8])
params := types.NewTuple(types.NewVar(0, nil, "format", pchar), VArg())
rets := types.NewTuple(types.NewVar(0, nil, "", types.Typ[types.Int32]))
sig := types.NewSignatureType(nil, nil, nil, params, rets, false)
pkg.NewFunc("printf", sig)
assertPkg(t, pkg, `; ModuleID = 'foo/bar'
source_filename = "foo/bar"
declare i32 @printf(ptr, ...)
`)
}
func TestBinOp(t *testing.T) {
prog := NewProgram(nil)
pkg := prog.NewPackage("bar", "foo/bar")