diff --git a/comp/src/gb.test/.src/SelfTest/TestCrash.module b/comp/src/gb.test/.src/SelfTest/TestCrash.module index 3c034c750..67ff2e83f 100644 --- a/comp/src/gb.test/.src/SelfTest/TestCrash.module +++ b/comp/src/gb.test/.src/SelfTest/TestCrash.module @@ -3,9 +3,9 @@ Private Const EXPECTED As String = "" "1..1\n" "# This is intended to fail\n" -"# Crash.Main.7: Like this Debug statement, the division by zero error should be captured and converted to a diagnostic\n" -"# Crash.Main.9: #26: Division by zero\n" -"# Crash.Main.9 \n" +"# _Crash.Main.7: Like this Debug statement, the division by zero error should be captured and converted to a diagnostic\n" +"# _Crash.Main.9: #26: Division by zero\n" +"# _Crash.Main.9 \n" "# " Public Sub Main() @@ -13,7 +13,7 @@ Public Sub Main() Dim hHarness As New TestHarness Assert.Setup(6) - hHarness.Run(Application.Path, "Crash") + hHarness.Run(Application.Path, "_Crash") With hHarness.Current Assert.Equals(.ExitCode, 1, "exit code") Assert.Equals(.Planned, 1, "planned 1 test") diff --git a/comp/src/gb.test/.src/SelfTest/TestCrash/Crash.module b/comp/src/gb.test/.src/SelfTest/TestCrash/_Crash.module similarity index 100% rename from comp/src/gb.test/.src/SelfTest/TestCrash/Crash.module rename to comp/src/gb.test/.src/SelfTest/TestCrash/_Crash.module diff --git a/comp/src/gb.test/.src/SelfTest/TestSubtest.module b/comp/src/gb.test/.src/SelfTest/TestSubtest.module new file mode 100644 index 000000000..754339a69 --- /dev/null +++ b/comp/src/gb.test/.src/SelfTest/TestSubtest.module @@ -0,0 +1,26 @@ +' Gambas module file + +Private Const EXPECTED As String = "" +"1..2\n" +"\t1..3\n" +"\tok 1 - Now is around Now\n" +"\tok 2 - Now is a date\n" +"\tok 3 - It is past 1970\n" +"ok 1 - TestMethod1\n" +"\t1..2\n" +"\t\t1..2\n" +"\t\tok 1 - 2 > -1\n" +"\t\tok 2 - 2 is around -1\n" +"\tok 1 - a subtest\n" +"\tok 2 - True\n" +"ok 2 - TestMethod2\n" + +Public Sub Main() + + Dim sOut As String + + Assert.Plan(1) + Exec ["gbx3", "-s", "_Subtest", Application.Path] To sOut + Assert.StringEquals(sOut, EXPECTED, "Subtest printer") + +End diff --git a/comp/src/gb.test/.src/SelfTest/TestSubtest/_Subtest.module b/comp/src/gb.test/.src/SelfTest/TestSubtest/_Subtest.module new file mode 100644 index 000000000..411e03d11 --- /dev/null +++ b/comp/src/gb.test/.src/SelfTest/TestSubtest/_Subtest.module @@ -0,0 +1,37 @@ +' Gambas module file + +Public Sub Main() + + ' TODO: This is a template for how the TestHarness should call test methods! + Assert.Plan(2) + + Assert.Subtest("TestMethod1") + TestMethod1() + Assert.Finish() + + Assert.Subtest("TestMethod2") + TestMethod2() + Assert.Finish() + +End + +Public Sub TestMethod1() + + Assert.Plan(3) + Assert.Approximate(Now, Now, 1e-1, "Now is around Now") + Assert.IsType(Now, gb.Date, "Now is a date") + Assert.GreaterEqual(Now, Date(1970), "It is past 1970") + +End + +Public Sub TestMethod2() + + Assert.Plan(2) + + Assert.Subtest("a subtest", 2) + Assert.Greater(2, -1, "2 > -1") + Assert.Approximate(2, -1, 10, "2 is around -1") + Assert.Finish() + Assert.Ok(True, "True") + +End