drewbourne / mockolate

fake chocolate, mock objects and test spies for AS3
http://mockolate.org/
MIT License
146 stars 26 forks source link

fix to random mockolate/flemit gettype error #56

Closed jbarrus closed 12 years ago

jbarrus commented 12 years ago

The problem was a weak event listener getting garbage collected. If you add System.gc() before returning the dispatcher, the event listener will never be called.

On a side note, what is the point of _preparingClassRecipes? It is not cleared out once the recipes are added to _preparedClassRecipes. The line below will never do anything with the last .without() statement because _preparedClassRecipes will always be a subset of _preparingClassRecipes.

This was tested on a suite with more than 2,000 tests and over 100 classes mocked.

var classRecipesToPrepare:ClassRecipes = classRecipes.without(_preparingClassRecipes).without(_preparedClassRecipes);
drewbourne commented 12 years ago

WRT that line, I started with tracking just the prepared ClassRecipes, then realised I needed to also track the ClassRecipes while they are preparing. I'd like to update it so that the _preparingClassRecipes collection has only those ClassRecipes that are preparing and the _preparedClassRecipes contains only those ClassRecipes that have had a proxy class generated.

Thanks for finding the solution to this issue.