#!/usr/bin/env python3
import pytest
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent))

from sdk.code_iter import DICT, LFSR, END
from kernels.dot_product_code import dot_product_code

def test_unsupported_dict_raises():
    # DICT: opcode 0x04, ref (u32), length (u64)
    prog = bytes([DICT]) + (42).to_bytes(4,'little') + (100).to_bytes(8,'little') + bytes([END])
    with pytest.raises(NotImplementedError, match="DICT requires basis mapping"):
        dot_product_code(prog, lambda *_: 0.0)

def test_unsupported_lfsr_raises():
    # LFSR: opcode 0x05, seed (u64), length (u64), tapmask (u64)
    prog = bytes([LFSR]) + (1337).to_bytes(8,'little') + (1000).to_bytes(8,'little') + (0xB400).to_bytes(8,'little') + bytes([END])
    with pytest.raises(NotImplementedError, match="LFSR requires lfsr_dot"):
        dot_product_code(prog, lambda *_: 0.0)
