...
Source file
src/go/types/token_test.go
1
2
3
4
5
6
7
8 package types
9
10 import (
11 "go/token"
12 "testing"
13 )
14
15 var assignOps = map[token.Token]token.Token{
16 token.ADD_ASSIGN: token.ADD,
17 token.SUB_ASSIGN: token.SUB,
18 token.MUL_ASSIGN: token.MUL,
19 token.QUO_ASSIGN: token.QUO,
20 token.REM_ASSIGN: token.REM,
21 token.AND_ASSIGN: token.AND,
22 token.OR_ASSIGN: token.OR,
23 token.XOR_ASSIGN: token.XOR,
24 token.SHL_ASSIGN: token.SHL,
25 token.SHR_ASSIGN: token.SHR,
26 token.AND_NOT_ASSIGN: token.AND_NOT,
27 }
28
29 func TestZeroTok(t *testing.T) {
30
31 var zero token.Token
32 if token.ILLEGAL != zero {
33 t.Errorf("%s == %d; want 0", token.ILLEGAL, zero)
34 }
35 }
36
37 func TestAssignOp(t *testing.T) {
38
39 for i := 0; i < 256; i++ {
40 tok := token.Token(i)
41 got := assignOp(tok)
42 want := assignOps[tok]
43 if got != want {
44 t.Errorf("for assignOp(%s): got %s; want %s", tok, got, want)
45 }
46 }
47 }
48
View as plain text