' Gambas test file Private $aSkipAllEvents As New String[] '' Test parsing of SkipAll plans Public Sub SkipAll() Dim sTAP As String = "" "1..2\n" "Test Run\n" " 1..1\n" " ok 1\n" "ok 1\n" "Test Skip\n" " 1..0 # skipped\n" "ok 2\n" Dim hTAP As Stream Dim hParser As New TapParser As "SkipAllParser" Test.Plan(4) hTAP = Open String sTAP For Read hParser.Parse(hTAP) Test.Plan(3 + 1) Assert.Equals($aSkipAllEvents.Count, 3, "Event count is correct") Assert.Equals($aSkipAllEvents[0], "Plan 1..2") Assert.Equals($aSkipAllEvents[1], "Plan 1..1") Assert.Equals($aSkipAllEvents[2], "Skip") Close #hTAP End Public Sub SkipAllParser_Plan((Start) As Integer, (End) As Integer, (SkipAll) As Boolean) $aSkipAllEvents.Add(IIf(SkipAll, "Skip", Subst$("Plan &1..&2", Start, {End}))) End Private $aSubtestEvents As New String[] '' Test the order of events from the parser. Public Sub Subtests() Dim sTAP As String = "" "# This tests subtest parsing and order of events\n" "This line is ignored.\n" "Test Subtest\n" " ok 1 - good\n" " ok 2 - better\n" " not ok 3 - acceptable # TODO this was expected\n" " 1..3\n" "ok 1 - Subtest\n" "\n" "Test Another\n" " 1..1\n" " not ok 1 - failed\n" "not ok 2 - Another\n" Dim hTAP As Stream Dim hParser As New TapParser As "SubtestsParser" hTAP = Open String sTAP For Read hParser.Parse(hTAP) Test.Plan(15 + 1) Assert.Equals($aSubtestEvents.Count, 15, "Event count is correct") Assert.Equals($aSubtestEvents[00], "Diag") Assert.Equals($aSubtestEvents[01], "Else") Assert.Equals($aSubtestEvents[02], "Begin") Assert.Equals($aSubtestEvents[03], "Ok") Assert.Equals($aSubtestEvents[04], "Ok") Assert.Equals($aSubtestEvents[05], "NotOk") Assert.Equals($aSubtestEvents[06], "Plan") Assert.Equals($aSubtestEvents[07], "End") Assert.Equals($aSubtestEvents[08], "Ok") Assert.Equals($aSubtestEvents[09], "Else") Assert.Equals($aSubtestEvents[10], "Begin") Assert.Equals($aSubtestEvents[11], "Plan") Assert.Equals($aSubtestEvents[12], "NotOk") Assert.Equals($aSubtestEvents[13], "End") Assert.Equals($aSubtestEvents[14], "NotOk") Close #hTAP End Public Sub SubtestsParser_Plan((Start) As Integer, (End) As Integer, (SkipAll) As Boolean) $aSubtestEvents.Push("Plan") End Public Sub SubtestsParser_Assert((Ok) As Boolean, (Id) As Long, (Description) As String, (Directive) As Integer, (Comment) As String) $aSubtestEvents.Push(IIf(Ok, "Ok", "NotOk")) End Public Sub SubtestsParser_Diagnostic((Comment) As String) $aSubtestEvents.Push("Diag") End Public Sub SubtestsParser_Else((Line) As String) $aSubtestEvents.Push("Else") End Public Sub SubtestsParser_BeginSubtest((Description) As String) $aSubtestEvents.Push("Begin") End Public Sub SubtestsParser_EndSubtest() $aSubtestEvents.Push("End") End '' Examine the object hierarchy returned by TestRunner, by running the Subtests test externally. Public Sub Runner() Dim hStats As TestStats = TestRunner.Run(Application.Path, "TParser.Subtests") Test.Plan(7) Assert.NotNull(hStats, "Stats object is not null") Assert.Equals(hStats.Planned, 1) Assert.Equals(hStats.Passed, 1) Dim hMethod As TestAssertion = hStats.Subtests[0] Assert.Ok(hMethod.Success) Assert.Equals(hMethod.Subtests.Count, 16) Assert.Equals(hMethod.Subtests[0].Description, "- Event count is correct") Assert.Equals(hMethod.Subtests[0].Subtests.Count, 0) End