Added more tests
This commit is contained in:
@ -18,6 +18,7 @@ var (
|
||||
MissingGroupEnd = &Base{"Missing ')'"}
|
||||
MissingMainFunction = &Base{"Missing main function"}
|
||||
MissingOperand = &Base{"Missing operand"}
|
||||
MissingParameter = &Base{"Missing parameter"}
|
||||
MissingType = &Base{"Missing type"}
|
||||
NotImplemented = &Base{"Not implemented"}
|
||||
UnknownType = &Base{"Unknown type"}
|
||||
|
@ -164,7 +164,11 @@ func (s *Scanner) scanFunction(file *fs.File, tokens token.List, i int) (int, er
|
||||
count := 0
|
||||
|
||||
err := parameters.Split(func(tokens token.List) error {
|
||||
if len(tokens) < 2 {
|
||||
if len(tokens) == 0 {
|
||||
return errors.New(errors.MissingParameter, file, parameters[0].Position)
|
||||
}
|
||||
|
||||
if len(tokens) == 1 {
|
||||
return errors.New(errors.MissingType, file, tokens[0].End())
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,10 @@ func (list List) LastIndexKind(kind Kind) int {
|
||||
|
||||
// Split calls the callback function on each set of tokens in a comma separated list.
|
||||
func (list List) Split(call func(List) error) error {
|
||||
if len(list) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
start := 0
|
||||
groupLevel := 0
|
||||
|
||||
@ -58,12 +62,8 @@ func (list List) Split(call func(List) error) error {
|
||||
}
|
||||
}
|
||||
|
||||
if start != len(list) {
|
||||
parameter := list[start:]
|
||||
return call(parameter)
|
||||
}
|
||||
|
||||
return nil
|
||||
parameter := list[start:]
|
||||
return call(parameter)
|
||||
}
|
||||
|
||||
// Text returns the concatenated token text.
|
||||
|
Reference in New Issue
Block a user