a lot oh changes to the test framework and new test files t_builtin-fmt_test.go and t_plugin_test.go added
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
|
||||
// t_builtin-fmt.go
|
||||
package expr
|
||||
|
||||
import (
|
||||
// "errors"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFuncFmt(t *testing.T) {
|
||||
section := "Builtin-Fmt"
|
||||
|
||||
inputs := []inputType{
|
||||
/* 1 */ {`builtin "fmt"; print("ciao")`, int64(4), nil},
|
||||
/* 2 */ {`builtin "fmt"; println(" ciao")`, int64(6), nil},
|
||||
}
|
||||
|
||||
//t.Setenv("EXPR_PATH", ".")
|
||||
|
||||
// parserTestSpec(t, section, inputs, 19)
|
||||
runTestSuite(t, section, inputs)
|
||||
}
|
||||
|
||||
|
||||
func TestFmt(t *testing.T) {
|
||||
section := "Builtin-Fmt"
|
||||
|
||||
text := "ciao mondo"
|
||||
inputs := []inputType{
|
||||
/* 1 */ {fmt.Sprintf(`println("%s")`, text), int64(11), nil},
|
||||
}
|
||||
|
||||
// t.Setenv("EXPR_PATH", ".")
|
||||
|
||||
var b bytes.Buffer
|
||||
ctx := NewSimpleStore()
|
||||
currentStdout := SetCtrl(ctx, ControlStdout, &b)
|
||||
|
||||
runCtxTestSuite(t, ctx, section, inputs)
|
||||
|
||||
SetCtrl(ctx, ControlStdout, currentStdout)
|
||||
if b.String() != text + "\n" {
|
||||
t.Errorf("println(): Got: %q, Want: %q", b.String(), text+"\n")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user