Skip to main content

same_graph

Function same_graph 

Source
pub fn same_graph<A: IVm>(
    actual: &Any<A>,
    expected: &Any<A>,
) -> Result<(), String>
Expand description

Whether two graphs are the same value, and, where they are not, the first difference found, with the path to it.

Leaves compare as Object.is does, numbers by their bits (NaN, -0), everything else by ==. Arrays compare by their elements. Objects compare by their Object::own_entries, pairwise and in order, so a duplicated raw slot (an object spread’s overwrite) equals the interpreter’s normalized object while the right entries in the wrong observable order still fail.

Sharing is compared too: the two graphs are walked together, and an actual container must map to exactly one expected container and the reverse, so [shared, shared] is not two equal copies. Any == is identity on a container, so the pairs seen live in a list searched with it, and no hash of an Any is needed.