import pytest
from .exemplar_generators import EXEMPLAR_PRIMITIVE_GENERATORS


@pytest.mark.parametrize("g", EXEMPLAR_PRIMITIVE_GENERATORS)
def test_spawn_primitive_generators(g):
    """
    Test that primitive generators can be spawned and the spawned versions produce the same elements.
    """
    num_items = 50
    seed = 12345
    g.reset(seed)

    # Let g generate a few items
    items_g_pre_spawn = list(g.generate(num_items))

    # Spawn g and let both generate a few more items
    h = g.spawn()
    items_g_post_spawn = list(g.generate(num_items))
    items_h_post_spawn = list(h.generate(num_items))

    # Reset h and re-generate the full list of items
    h.reset(seed)
    items_h_all = list(h.generate(2*num_items))

    # Verify that the items generated by h after spawning
    # as well as the full sets of items are identical.
    assert items_h_post_spawn == items_g_post_spawn
    assert items_h_all == items_g_pre_spawn + items_g_post_spawn
Add test that spawns of primitive generators produce the same elements as the original
Add test that spawns of primitive generators produce the same elements as the original
