resourceloader: Move add() outside loop to optimise sortDependencies()
Follows-up CR of
dec800968.
As being a set, repeatedly calling unresolved.add() with the same
module name is not useful. This removes that needless overhead
by moving the statement from inside the loop to before it.
This does mean it is now before the first call to has(), but this
change does not affect its behaviour. Tests confirm that.
Aside from optimising the loop, this also ends up reducing the level
of recursion required to detect self-dependencies (eg. A > A).
At first I thought that self-dependencies were not detectable
right now, but the recursion made this work previously as well.
I've added a test case to confirm this going forward, and updated
the existing test cases to consistently use ABC in examples.
Change-Id: I9f4d0a18750f8e5778e0bf3c693b1d83a4ec4312