Added more tests

This commit is contained in:
Eduard Urbach 2025-02-07 21:25:29 +01:00
parent a562f521b6
commit 6ebd1829fb
Signed by: eduard
GPG key ID: 49226B848C78F6C8
5 changed files with 6 additions and 9 deletions

View file

@ -4,6 +4,7 @@ import (
"path/filepath"
"git.akyoto.dev/cli/q/src/config"
"git.akyoto.dev/cli/q/src/errors"
"git.akyoto.dev/cli/q/src/fs"
"git.akyoto.dev/cli/q/src/token"
)
@ -13,7 +14,7 @@ func (s *Scanner) scanImport(file *fs.File, tokens token.List, i int) (int, erro
i++
if tokens[i].Kind != token.Identifier {
panic("expected package name")
return i, errors.New(errors.ExpectedPackageName, file, tokens[i].Position)
}
packageName := tokens[i].Text(file.Bytes)
@ -31,11 +32,5 @@ func (s *Scanner) scanImport(file *fs.File, tokens token.List, i int) (int, erro
}
s.queueDirectory(fullPath, packageName)
i++
if tokens[i].Kind != token.NewLine && tokens[i].Kind != token.EOF {
panic("expected newline or eof")
}
return i, nil
}