-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
167 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package asmble.ast | ||
|
||
import asmble.SpecTestUnit | ||
import asmble.TestBase | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
@RunWith(Parameterized::class) | ||
class StackTest(val unit: SpecTestUnit) : TestBase() { | ||
|
||
@Test | ||
fun testStack() { | ||
// If it's not a module expecting an error, we'll try to walk the stack on each function | ||
unit.script.commands.mapNotNull { it as? Script.Cmd.Module }.forEach { mod -> | ||
mod.module.funcs.filter { it.instructions.isNotEmpty() }.forEach { func -> | ||
debug { "Func: ${func.type}" } | ||
var indexCount = 0 | ||
Stack.walkStrict(mod.module, func) { stack, insn -> | ||
debug { " After $insn (next: ${func.instructions.getOrNull(++indexCount)}, " + | ||
"unreach depth: ${stack.unreachableUntilNextEndCount})" } | ||
debug { " " + stack.current } | ||
} | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
// Only tests that shouldn't fail | ||
@JvmStatic @Parameterized.Parameters(name = "{0}") | ||
fun data() = SpecTestUnit.allUnits.filterNot { it.shouldFail }//.filter { it.name == "loop" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters