mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
core/vm: add remaining tests from the EIP
This commit is contained in:
parent
891ae31ad2
commit
81546c64c7
1 changed files with 25 additions and 26 deletions
|
|
@ -977,19 +977,19 @@ func TestOpCLZ(t *testing.T) {
|
||||||
evm := NewEVM(BlockContext{}, nil, params.TestChainConfig, Config{})
|
evm := NewEVM(BlockContext{}, nil, params.TestChainConfig, Config{})
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
|
||||||
inputHex string
|
inputHex string
|
||||||
want uint64 // expected CLZ result
|
want uint64 // expected CLZ result
|
||||||
}{
|
}{
|
||||||
{"zero", "0x0", 256},
|
{"0x0", 256},
|
||||||
{"one", "0x1", 255},
|
{"0x1", 255},
|
||||||
{"all-ones (256 bits)", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0},
|
{"0x6ff", 245}, // 0x6ff = 0b11011111111 (11 bits), so 256-11 = 245
|
||||||
{"low-40-bits", "0xffffffffff", 216}, // 40 bits, so 256-40 = 216
|
{"0xffffffffff", 216}, // 40 bits, so 256-40 = 216
|
||||||
{"low-11-bits", "0x6ff", 245}, // 0x6ff = 0b11011111111 (11 bits), so 256-11 = 245
|
{"0x4000000000000000000000000000000000000000000000000000000000000000", 1},
|
||||||
|
{"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1},
|
||||||
|
{"0x8000000000000000000000000000000000000000000000000000000000000000", 0},
|
||||||
|
{"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
// prepare a fresh stack and PC
|
// prepare a fresh stack and PC
|
||||||
stack := newstack()
|
stack := newstack()
|
||||||
pc := uint64(0)
|
pc := uint64(0)
|
||||||
|
|
@ -1010,6 +1010,5 @@ func TestOpCLZ(t *testing.T) {
|
||||||
if got := result.Uint64(); got != tc.want {
|
if got := result.Uint64(); got != tc.want {
|
||||||
t.Fatalf("clz(%q) = %d; want %d", tc.inputHex, got, tc.want)
|
t.Fatalf("clz(%q) = %d; want %d", tc.inputHex, got, tc.want)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue