""" Example test file used to demonstrate HissCheck. Contains a deliberate mix of shallow, partial, and solid tests. """ import math # ── The code under test (inline for demo simplicity) ────────────────────── def divide(a: float, b: float) -> float: if b == 0: raise ValueError("Cannot divide by zero") return a / b def celsius_to_fahrenheit(c: float) -> float: return c * 9 / 5 + 32 class Stack: def __init__(self): self._data = [] def push(self, item): self._data.append(item) def pop(self): if not self._data: raise IndexError("pop from empty stack") return self._data.pop() def peek(self): return self._data[-1] if self._data else None def is_empty(self): return len(self._data) == 0 # ── Tests ────────────────────────────────────────────────────────────────── class TestDivide: # SHALLOW: only checks the function exists and is callable def test_divide_exists(self): assert callable(divide) # SHALLOW: only checks the return is not None def test_divide_returns_something(self): result = divide(10, 2) assert result is not None # SOLID: verifies correct arithmetic def test_divide_basic(self): assert divide(10, 2) == 5.0 assert divide(9, 3) == 3.0 assert divide(-6, 2) == -3.0 # SOLID: verifies the documented error case def test_divide_by_zero_raises(self): import pytest with pytest.raises(ValueError, match="Cannot divide by zero"): divide(1, 0) # PARTIAL: tests a happy path but misses edge cases like negative temps def test_celsius_happy_path(self): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 class TestStack: # SHALLOW: only checks the type def test_stack_is_instance(self): s = Stack() assert isinstance(s, Stack) # SHALLOW: checks is_empty exists via hasattr def test_stack_has_is_empty(self): s = Stack() assert hasattr(s, "is_empty") # SOLID: verifies LIFO order with multiple elements def test_stack_lifo_order(self): s = Stack() for item in [1, 2, 3]: s.push(item) assert s.pop() == 3 assert s.pop() == 2 assert s.pop() == 1 # SOLID: verifies the edge case of popping from an empty stack def test_stack_pop_empty_raises(self): import pytest s = Stack() with pytest.raises(IndexError): s.pop() # PARTIAL: tests peek returns something but doesn't verify the value def test_stack_peek_not_none(self): s = Stack() s.push(42) assert s.peek() is not None # SOLID: full peek behaviour including empty-stack case def test_stack_peek_correct_value(self): s = Stack() assert s.peek() is None # empty stack s.push(7) assert s.peek() == 7 # peek sees top s.push(99) assert s.peek() == 99 # peek updates after push s.pop() assert s.peek() == 7 # peek restores after pop