*** Settings ***
Documentation    Integration tests for PureGraph execution and ordering
Library          Collections
Library          ${CURDIR}/pure_graph_lib.py

*** Keywords ***
Set Double And Increment Registry
    ${double}=    Evaluate    lambda x: x * 2
    ${increment}=    Evaluate    lambda x: x + 1
    ${registry}=    Create Dictionary    double=${double}    increment=${increment}
    Set Function Registry    ${registry}

Set Empty Registry
    ${empty}=    Create Dictionary
    Set Function Registry    ${empty}

*** Test Cases ***
PureGraph Topological Order
    [Documentation]    Verify topological ordering of graph nodes respects start/end boundaries
    @{nodes}=    Create List    alpha    beta
    Create Linear Graph With Non Functional Nodes    ${nodes}
    Compute Topological Order
    ${topo}=    Get Topological Order
    @{expected}=    Create List    start    alpha    beta    end
    Lists Should Be Equal    ${expected}    ${topo}

PureGraph Execute With Functions
    [Documentation]    Verify function execution applies transformations sequentially in declaration order
    @{node_names}=    Create List    double    increment
    @{func_names}=    Create List    double    increment
    Create Linear Graph With Function Nodes    ${node_names}    ${func_names}
    Set Double And Increment Registry
    ${result}=    Execute Graph    ${1}
    Should Be Equal As Integers    ${result}    3

PureGraph Execute With Missing Function
    [Documentation]    Verify missing function nodes are skipped gracefully without error
    Create Graph With Missing Function    missing_fn
    Set Empty Registry
    ${result}=    Execute Graph    5
    Should Be Equal As Integers    ${result}    5

PureGraph Execute With Non-Functional Nodes
    [Documentation]    Verify non-functional (inert) nodes do not change the value
    @{nodes}=    Create List    alpha    beta
    Create Linear Graph With Non Functional Nodes    ${nodes}
    Set Empty Registry
    ${result}=    Execute Graph    7
    Should Be Equal As Integers    ${result}    7
