[vala/wip/valadate: 69/71] Test is now abstract class without GObject dependancy



commit 627fa24967309ab022a77d27daa85edb16b30dbe
Author: Chris Daley <chebizarro gmail com>
Date:   Mon May 1 08:50:22 2017 -0700

    Test is now abstract class without GObject dependancy

 tests/valatests.vala      |    2 +-
 valadate/test.vala        |   12 ++++++------
 valadate/testadapter.vala |   21 +++++++++------------
 valadate/testcase.vala    |   27 +++++++--------------------
 valadate/testreport.vala  |    2 +-
 valadate/testsuite.vala   |   25 +++++++------------------
 6 files changed, 31 insertions(+), 58 deletions(-)
---
diff --git a/tests/valatests.vala b/tests/valatests.vala
index d686eb7..41739bb 100644
--- a/tests/valatests.vala
+++ b/tests/valatests.vala
@@ -21,7 +21,7 @@ public class Vala.Tests : Valadate.TestSuite {
 
        private const string BUGZILLA_URL = "http://bugzilla.gnome.org/";;
 
-       construct {
+       public Tests () {
                try {
                        var testdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
                        var running_test = Environment.get_variable ("V_RUNNING_TEST");
diff --git a/valadate/test.vala b/valadate/test.vala
index 9e5816a..7c56ce7 100644
--- a/valadate/test.vala
+++ b/valadate/test.vala
@@ -24,7 +24,7 @@
  * The Test interface is implemented by TestCase and TestSuite.
  * It is the base interface for all runnable Tests.
  */
-public interface Valadate.Test : Object {
+public abstract class Valadate.Test {
        /**
         * Runs the Tests and collects the results in a TestResult
         *
@@ -34,11 +34,11 @@ public interface Valadate.Test : Object {
        /**
         * The name of the test
         */
-       public abstract string name { get; set; }
+       public string name { get; set; }
        /**
         * The label of the test
         */
-       public abstract string label { get; set; }
+       public string label { get; set; }
        /**
         * Returns the number of tests that will be run by this test
         * TestSuites should return the total number of tests that will
@@ -53,11 +53,11 @@ public interface Valadate.Test : Object {
        /**
         * The #TestStatus of the test
         */
-       public abstract TestStatus status { get; set; default = TestStatus.NOT_RUN; }
+       public TestStatus status { get; set; default = TestStatus.NOT_RUN; }
 
-       public abstract double time { get; set; }
+       public double time { get; set; }
 
-       public abstract Test? parent { get; set; }
+       public Test? parent { get; set; }
 
        public abstract Test get (int index);
 
diff --git a/valadate/testadapter.vala b/valadate/testadapter.vala
index e88b1cd..ba73ea2 100644
--- a/valadate/testadapter.vala
+++ b/valadate/testadapter.vala
@@ -20,24 +20,19 @@
  *     Chris Daley <chebizarro gmail com>
  */
 
-public class Valadate.TestAdapter : Object, Test {
-
-       public string name { get; set; }
-       public string label { get; set; }
-       public double time { get; set; }
+public class Valadate.TestAdapter : Test {
 
        public int timeout { get; set; }
 
-       public TestStatus status { get; set; default = TestStatus.NOT_RUN; }
        public string status_message { get; set; }
 
-       public int count {
+       public override int count {
                get {
                        return 1;
                }
        }
 
-       public int size {
+       public override int size {
                get {
                        return count;
                }
@@ -45,12 +40,14 @@ public class Valadate.TestAdapter : Object, Test {
 
        public TestCase.TestMethod test;
 
-       public Test? parent { get; set; }
-
-       public new Test get (int index) {
+       public override Test get (int index) {
                return this;
        }
 
+       public override void set (int index, Test test) {
+               
+       }
+
        public TestAdapter (string name, int timeout) {
                this.name = name;
                this.timeout = timeout;
@@ -90,7 +87,7 @@ public class Valadate.TestAdapter : Object, Test {
                this.test = (owned)testmethod;
        }
 
-       public void run (TestResult result) {
+       public override void run (TestResult result) {
                if (status == TestStatus.SKIPPED)
                        return;
                var p = parent as TestCase;
diff --git a/valadate/testcase.vala b/valadate/testcase.vala
index 713bec6..522078f 100644
--- a/valadate/testcase.vala
+++ b/valadate/testcase.vala
@@ -24,24 +24,17 @@
  *     Julien Peeters <contact julienpeeters fr>
  */
 
-public abstract class Valadate.TestCase : Object, Test {
+public abstract class Valadate.TestCase : Test {
        /**
         * The TestMethod delegate represents a {@link Valadate.Test} method
         * that can be added to a TestCase and run
         */
        public delegate void TestMethod () throws Error;
-       /**
-        * the name of the TestCase
-        */
-       public string name { get; set; }
-       /**
-        * the label of the TestCase
-        */
-       public string label { get; set; }
+
        /**
         * Returns the number of {@link Valadate.Test}s that will be run by this TestCase
         */
-       public int count {
+       public override int count {
                get {
                        int testcount = 0;
                        _tests.foreach ((t) => {
@@ -51,7 +44,7 @@ public abstract class Valadate.TestCase : Object, Test {
                }
        }
 
-       public int size {
+       public override int size {
                get {
                        int testcount = 0;
                        _tests.foreach ((t) => {
@@ -61,12 +54,6 @@ public abstract class Valadate.TestCase : Object, Test {
                }
        }
 
-       public Test? parent {get;set;}
-
-       public TestStatus status {get;set;default=TestStatus.NOT_RUN;}
-       public string status_message {get;set;}
-       public double time {get;set;}
-
        public string bug_base {get;set;}
 
        private List<Test> _tests = new List<Test> ();
@@ -74,11 +61,11 @@ public abstract class Valadate.TestCase : Object, Test {
        private Test current_test;
        private TestResult current_result;
 
-       public new Test get (int index) {
+       public override Test get (int index) {
                return _tests.nth_data ((uint)index);
        }
 
-       public new void set (int index, Test test) {
+       public override void set (int index, Test test) {
                test.parent = this;
                _tests.insert_before (_tests.nth (index), test);
                var t = _tests.nth_data ((uint)index++);
@@ -98,7 +85,7 @@ public abstract class Valadate.TestCase : Object, Test {
                _tests.append (adapter);
        }
 
-       public virtual void run (TestResult result) {
+       public override void run (TestResult result) {
                if (status != TestStatus.NOT_RUN)
                        return;
                current_result = result;
diff --git a/valadate/testreport.vala b/valadate/testreport.vala
index d164d59..9f5d0b4 100644
--- a/valadate/testreport.vala
+++ b/valadate/testreport.vala
@@ -89,7 +89,7 @@ public class Valadate.TestReport {
        private void new_testcase () throws Error {
                if (subprocess) {
                        stderr.printf ("%s<%s>",XML_DECL,ROOT_TAG);
-                       stderr.printf (TESTCASE_START,test.parent.get_type ().name (), test.label);
+                       stderr.printf (TESTCASE_START, Type.from_instance (test.parent).name (), test.label);
                        start_time = get_monotonic_time ();
                } else {
                        var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTCASE_XML, ROOT_TAG);
diff --git a/valadate/testsuite.vala b/valadate/testsuite.vala
index 3b8310c..f5ccace 100644
--- a/valadate/testsuite.vala
+++ b/valadate/testsuite.vala
@@ -20,21 +20,13 @@
  *     Chris Daley <chebizarro gmail com>
  */
 
-public class Valadate.TestSuite : Object, Test {
+public class Valadate.TestSuite : Test {
 
        private List<Test> _tests = new List<Test> ();
        /**
-        * the name of the TestSuite
-        */
-       public string name { get; set; }
-       /**
-        * the label of the TestSuite
-        */
-       public string label { get; set; }
-       /**
         * Iterator (not the actual number of Tests that will be run)
         */
-       public int size {
+       public override int size {
                get {
                        return (int)_tests.length ();
                }
@@ -43,7 +35,7 @@ public class Valadate.TestSuite : Object, Test {
         * Returns the number of {@link Valadate.Test}s that will be run by
         * this TestSuite
         */
-       public int count {
+       public override int count {
                get {
                        int testcount = 0;
                        _tests.foreach ((t) => {
@@ -52,7 +44,6 @@ public class Valadate.TestSuite : Object, Test {
                        return testcount;
                }
        }
-       public Test? parent { get; set; }
        /**
         * Returns a {@link GLib.List} of {@link Valadate.Test}s that will be
         * run by this TestSuite
@@ -63,8 +54,6 @@ public class Valadate.TestSuite : Object, Test {
                }
        }
 
-       public TestStatus status { get; set; default=TestStatus.NOT_RUN;}
-       public double time { get; set; }
        public int skipped { get; set; }
        public int errors { get; set; }
        public int failures { get; set; }
@@ -73,7 +62,7 @@ public class Valadate.TestSuite : Object, Test {
         * TestSuite's name
         */
        public TestSuite (string? name = null) {
-               this.name = name ?? this.get_type ().name ();
+               this.name = name ?? Type.from_instance (this).name ();
                this.label = name;
        }
        /**
@@ -86,7 +75,7 @@ public class Valadate.TestSuite : Object, Test {
        /**
         * Runs all of the tests in the Suite
         */
-       public void run (TestResult result) {
+       public override void run (TestResult result) {
 
                if (status != TestStatus.NOT_RUN)
                        return;
@@ -96,11 +85,11 @@ public class Valadate.TestSuite : Object, Test {
                });
        }
 
-       public new Test get (int index) {
+       public override Test get (int index) {
                return _tests.nth_data ((uint)index);
        }
 
-       public new void set (int index, Test test) {
+       public override void set (int index, Test test) {
                test.parent = this;
                _tests.insert_before (_tests.nth (index), test);
                var t = _tests.nth_data ((uint)index++);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]