Skip to content

Commit 287b052

Browse files
committed
use q for ==, add test, tweak comment about unique
1 parent 89b7d26 commit 287b052

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

token/token.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// There are 2 types of Token, constant ones (with no "value") and the ones with attached
22
// value that is variable (e.g. IDENT, INT, FLOAT, STRING, *COMMENT).
3-
// We might use the upcoming unique https://tip.golang.org/doc/go1.23#new-unique-package
4-
// but we want this to run on 1.22 and earlier and rolled our own not multi threaded.
3+
// We might have used the upcoming unique https://tip.golang.org/doc/go1.23#new-unique-package
4+
// but we want this to run on 1.22 and earlier and rolled our own, not multi threaded.
55
package token
66

77
import (
@@ -284,7 +284,7 @@ func Init() { //nolint:funlen // we need all this.
284284
// Multi character non identity tokens.
285285
assocC2(LTEQ, "<=", 'l')
286286
assocC2(GTEQ, ">=", 'g')
287-
assocC2(EQ, "==", '_')
287+
assocC2(EQ, "==", 'q')
288288
assocC2(NOTEQ, "!=", 'n')
289289
assocC2(INCR, "++", 'i')
290290
assocC2(DECR, "--", 'd')

token/token_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ func TestSingleCharTokens(t *testing.T) {
121121
if tok2 != tok {
122122
t.Errorf("TokenByType[%v] returned %v, expected %v", tt.expected, tok2, tok)
123123
}
124+
code := tok.Code()
125+
if code != tt.input {
126+
t.Errorf("Token.Code() returned %c, expected %c", code, tt.input)
127+
}
124128
}
125129
}
126130

0 commit comments

Comments
 (0)