HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //lib/go-1.22/src/go/types/token_test.go
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file checks invariants of token.Token ordering that we rely on
// since package go/token doesn't provide any guarantees at the moment.

package types

import (
	"go/token"
	"testing"
)

var assignOps = map[token.Token]token.Token{
	token.ADD_ASSIGN:     token.ADD,
	token.SUB_ASSIGN:     token.SUB,
	token.MUL_ASSIGN:     token.MUL,
	token.QUO_ASSIGN:     token.QUO,
	token.REM_ASSIGN:     token.REM,
	token.AND_ASSIGN:     token.AND,
	token.OR_ASSIGN:      token.OR,
	token.XOR_ASSIGN:     token.XOR,
	token.SHL_ASSIGN:     token.SHL,
	token.SHR_ASSIGN:     token.SHR,
	token.AND_NOT_ASSIGN: token.AND_NOT,
}

func TestZeroTok(t *testing.T) {
	// zero value for token.Token must be token.ILLEGAL
	var zero token.Token
	if token.ILLEGAL != zero {
		t.Errorf("%s == %d; want 0", token.ILLEGAL, zero)
	}
}

func TestAssignOp(t *testing.T) {
	// there are fewer than 256 tokens
	for i := 0; i < 256; i++ {
		tok := token.Token(i)
		got := assignOp(tok)
		want := assignOps[tok]
		if got != want {
			t.Errorf("for assignOp(%s): got %s; want %s", tok, got, want)
		}
	}
}