// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.

// t_builtin-iterator.go
package expr

import (
	"testing"
)

func TestFuncRun(t *testing.T) {
	section := "Builtin-Iterator"

	inputs := []inputType{
		/*   1 */ {`builtin "iterator"; it=$(1,2,3); run(it)`, nil, nil},
		/*   2 */ {`builtin "iterator"; run($(1,2,3), func(index,item){item+10})`, nil, nil},
		/*   3 */ {`builtin "iterator"; run($(1,2,3), func(index,item){status=status+item; true}, {"status":0})`, int64(6), nil},
		/*   4 */ {`builtin ["iterator", "fmt"]; run($(1,2,3), func(index,item){println(item+10)})`, nil, nil},
		/*   5 */ {`builtin "iterator"; run(nil)`, nil, `paramter "iterator" must be an iterator, passed <nil> [nil]`},
		/*   6 */ {`builtin "iterator"; run($(1,2,3), nil)`, nil, nil},
		/*   7 */ {`builtin "iterator"; run($(1,2,3), func(){1}, "prrr")`, nil, `paramter "vars" must be a dictionary, passed prrr [string]`},
		/*   8 */ {`builtin "iterator"; run($(1,2,3), operator=nil)`, nil, nil},
		/*   9 */ {`builtin "iterator"; run($(1,2,3), operatorx=nil)`, nil, `run(): unknown param "operatorx"`},
	}

	//t.Setenv("EXPR_PATH", ".")

	//runTestSuiteSpec(t, section, inputs, 1)
	runTestSuite(t, section, inputs)
}
