Fixed equality issue with int

This commit is contained in:
Sasha Koshka 2022-08-11 03:58:45 -05:00
parent bef5b0328e
commit 4d73fa4b83
2 changed files with 8 additions and 5 deletions

View File

@ -15,8 +15,8 @@ func TestTokenizeAll (test *testing.T) {
tokens, err := Tokenize(file) tokens, err := Tokenize(file)
// print all tokens // print all tokens
for _, token := range tokens { for index, token := range tokens {
test.Log("got token:", token.Describe()) test.Log(index, "\tgot token:", token.Describe())
} }
if err != nil { if err != nil {
@ -33,8 +33,8 @@ func TestTokenizeAll (test *testing.T) {
External: types.ModeWrite, External: types.ModeWrite,
}}, }},
Token { kind: TokenKindReturnDirection }, Token { kind: TokenKindReturnDirection },
Token { kind: TokenKindInt, value: -349820394 }, Token { kind: TokenKindInt, value: int64(-349820394) },
Token { kind: TokenKindUInt, value: 932748397 }, Token { kind: TokenKindUInt, value: uint64(932748397) },
Token { kind: TokenKindFloat, value: 239485.37520 }, Token { kind: TokenKindFloat, value: 239485.37520 },
Token { kind: TokenKindString, value: "hello world\n" }, Token { kind: TokenKindString, value: "hello world\n" },
Token { kind: TokenKindRune, value: 'E' }, Token { kind: TokenKindRune, value: 'E' },
@ -77,6 +77,9 @@ func TestTokenizeAll (test *testing.T) {
for index, token := range tokens { for index, token := range tokens {
if !token.Equals(correct[index]) { if !token.Equals(correct[index]) {
test.Log("token", index, "not equal") test.Log("token", index, "not equal")
test.Log (
"have", token.Describe(),
"want", correct[index].Describe())
test.Fail() test.Fail()
return return
} }

View File

@ -78,7 +78,7 @@ func (token Token) Value () (value any) {
// Equals returns whether this token is equal to another token // Equals returns whether this token is equal to another token
func (token Token) Equals (testToken Token) (match bool) { func (token Token) Equals (testToken Token) (match bool) {
return token.value == testToken.value return token == testToken
} }
// Location returns the location of the token in its file. // Location returns the location of the token in its file.