Add generator test

As @seuros commented in #2016, I added a test for generator.
Thank you!