Use Iterable(Node) instead of ExampleGroup

This commit is contained in:
Michael Miller 2021-08-16 20:27:21 -06:00
parent aa81f1d948
commit 3803d4582c
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -1,5 +1,4 @@
require "./example" require "./example"
require "./example_group"
require "./node" require "./node"
module Spectator module Spectator
@ -13,7 +12,7 @@ module Spectator
# Creates a new iterator. # Creates a new iterator.
# The *group* is the example group to iterate through. # The *group* is the example group to iterate through.
def initialize(@group : ExampleGroup) def initialize(@group : Iterable(Node))
iter = @group.each.as(Iterator(Node)) iter = @group.each.as(Iterator(Node))
@stack = [iter] @stack = [iter]
end end
@ -55,7 +54,7 @@ module Spectator
# Get the iterator from the top of the stack. # Get the iterator from the top of the stack.
# Advance the iterator and check what the next item is. # Advance the iterator and check what the next item is.
case (item = top.next) case (item = top.next)
when ExampleGroup when Iterable(Node)
# If the next thing is a group, # If the next thing is a group,
# we need to traverse its branch. # we need to traverse its branch.
# Push its iterator onto the stack and return. # Push its iterator onto the stack and return.