github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/starlib/starlarkerrors/errors_test.go (about) 1 // Copyright 2021 Edward McFarlane. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package starlarkerrors_test 6 7 import ( 8 "io" 9 "testing" 10 11 "github.com/emcfarlane/larking/starlib" 12 "github.com/emcfarlane/larking/starlib/starlarkerrors" 13 "go.starlark.net/starlark" 14 ) 15 16 // ioEOF fails with an io.EOF error. 17 func ioEOF(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 18 return nil, io.EOF 19 } 20 21 func TestExecFile(t *testing.T) { 22 globals := starlark.StringDict{ 23 "io_eof": starlarkerrors.NewError(io.EOF), 24 "io_eof_func": starlark.NewBuiltin("io_eof_func", ioEOF), 25 } 26 starlib.RunTests(t, "testdata/*.star", globals) 27 }