CFC-Servers / GLuaTest

An exciting and nimble unit testing framework for GLua projects
https://discord.gg/epJK9Xx3pc
GNU General Public License v3.0
51 stars 2 forks source link

Add stub.returnsSequence #30

Closed brandonsturgeon closed 1 year ago

brandonsturgeon commented 1 year ago

This PR adds a new method on stubs. It lets you tell a stub to return a sequence of values as it's called.

stub( net, "ReadString" ).returnsSequence( { "first", "second", "third", "fourth", "fifth", [50] = "fiftieth" }, "" )

Would effectively translate to:

print( net.ReadString() )
> first
print( net.ReadString() )
> second
print( net.ReadString() )
> third
print( net.ReadString() )
> fourth
print( net.ReadString() )
> fifth
print( net.ReadString() )
> ""

... 44 calls later

print( net.ReadString() )
> fiftieth

print( net.ReadString() )
> ""

I tested this reasonably well, so I'm just gonna merge it and fix issues that pop up with it 🙃