#Requires AutoHotkey v2.0 class TestRunner { __New() { this.tests := [] this.passed := 0 this.failed := 0 } Add(name, callback) { this.tests.Push({ name: name, callback: callback }) } Run() { output := "" output .= "============================`n" output .= " AHK v2 TEST RUNNER`n" output .= "============================`n`n" for test in this.tests { try { test.callback.Call() this.passed++ output .= "✓ PASS " test.name "`n" } catch Error as err { this.failed++ output .= "✗ FAIL " test.name "`n" output .= " " err.Message "`n" if (err.Line) output .= " Line: " err.Line "`n" output .= "`n" } } output .= "`n" output .= "============================`n" output .= "Tests : " this.tests.Length "`n" output .= "Passed: " this.passed "`n" output .= "Failed: " this.failed "`n" output .= "============================" MsgBox(output, "AHK v2 Tests") return this.failed == 0 } }