import { describe, it, expect } from 'vitest';
import { handle as EQ } from './0x14_EQ.js';
describe('EQ (0x14)', () => {
it('returns 1 when values are equal', () => {
const frame = createFrame([42n, 42n]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([1n]);
expect(frame.pc).toBe(1);
expect(frame.gasRemaining).toBe(997n);
});
it('returns 0 when values are not equal', () => {
const frame = createFrame([10n, 20n]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([0n]);
});
it('handles zero equality', () => {
const frame = createFrame([0n, 0n]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([1n]);
});
it('handles zero inequality', () => {
const frame = createFrame([0n, 1n]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([0n]);
});
it('handles max uint256 equality', () => {
const MAX = (1n << 256n) - 1n;
const frame = createFrame([MAX, MAX]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([1n]);
});
it('handles large value comparison', () => {
const val = 0xDEADBEEFn;
const frame = createFrame([val, val]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([1n]);
});
it('returns StackUnderflow with insufficient stack', () => {
const frame = createFrame([42n]);
expect(EQ(frame)).toEqual({ type: 'StackUnderflow' });
});
it('returns OutOfGas when insufficient gas', () => {
const frame = createFrame([42n, 42n], 2n);
expect(EQ(frame)).toEqual({ type: 'OutOfGas' });
});
it('preserves stack below compared values', () => {
const frame = createFrame([100n, 200n, 42n, 42n]);
expect(EQ(frame)).toBeNull();
expect(frame.stack).toEqual([100n, 200n, 1n]);
});
});