package ai.nektron.grownet.tests;

import ai.nektron.grownet.debug.GrowNetTraceMain;
import ai.nektron.grownet.debug.TraceRunSummary;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TraceRunnerEquivalenceTests {

    @Test
    void singleNeuronScenarioMatchesWithTraceOnAndOff() throws Exception {
        assertTraceOnOffEquivalent("single_neuron", 1);
    }

    @Test
    void twoLayerScenarioMatchesWithTraceOnAndOff() throws Exception {
        assertTraceOnOffEquivalent("two_layer", 1);
    }

    @Test
    void growthScenarioMatchesWithTraceOnAndOff() throws Exception {
        assertTraceOnOffEquivalent("growth", 1);
    }

    private static void assertTraceOnOffEquivalent(String scenarioName, int tickCount) throws Exception {
        TraceRunSummary withoutTrace = GrowNetTraceMain.runSummaryForTest(
                "--lang", "java",
                "--scenario", scenarioName,
                "--ticks", String.valueOf(tickCount),
                "--value", "0.42"
        );
        TraceRunSummary withTrace = GrowNetTraceMain.runSummaryForTest(
                "--lang", "java",
                "--trace",
                "--trace-format", "jsonl",
                "--scenario", scenarioName,
                "--ticks", String.valueOf(tickCount),
                "--value", "0.42"
        );
        assertEquals(withoutTrace, withTrace);
    }
}
