import SwiftUI
import Testing
@testable import Forji

struct LanguageColorTests {

    // MARK: - Determinism

    @Test func sameLanguageReturnsSameColor() {
        let color1 = colorForLanguage("Swift")
        let color2 = colorForLanguage("Swift")
        #expect(color1 == color2)
    }

    @Test func differentLanguagesReturnDifferentColors() {
        let swift = colorForLanguage("Swift")
        let python = colorForLanguage("Python")
        let rust = colorForLanguage("Rust")
        // At least some should differ (extremely unlikely all 3 hash to same hue)
        let allSame = (swift == python) && (python == rust)
        #expect(!allSame)
    }

    // MARK: - Edge cases

    @Test func emptyStringDoesNotCrash() {
        let color = colorForLanguage("")
        // Should return a valid color, not crash
        _ = color
    }

    @Test func caseMatters() {
        let lower = colorForLanguage("swift")
        let upper = colorForLanguage("Swift")
        #expect(lower != upper)
    }

    @Test func nonAsciiLanguageNames() {
        // Should handle non-ASCII without crashing
        let color = colorForLanguage("Ren\u{2019}Py")
        _ = color
    }

    @Test func longLanguageName() {
        let color = colorForLanguage(String(repeating: "x", count: 10000))
        _ = color
    }
}
