]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add more "declaration" tests for genie to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 5 Nov 2021 10:08:23 +0000 (11:08 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 14 Nov 2021 11:42:01 +0000 (12:42 +0100)
tests/Makefile.am
tests/genie/class-field.gs [new file with mode: 0644]
tests/genie/class-init.gs [new file with mode: 0644]
tests/genie/class-signal.gs [new file with mode: 0644]
tests/genie/constant.gs [new file with mode: 0644]
tests/genie/exception.gs [new file with mode: 0644]
tests/genie/interface.gs [new file with mode: 0644]

index 34968c15785b2dc27c7f1e92aa3350002871e1ab..175e085ba1a5c8a48925703f569d41f8148e7b85 100644 (file)
@@ -1212,7 +1212,11 @@ TESTS = \
        version/since-method.test \
        version/since-parameter.test \
        genie/class.gs \
+       genie/class-field.gs \
+       genie/class-init.gs \
        genie/class-property.gs \
+       genie/class-signal.gs \
+       genie/constant.gs \
        genie/control-flow-if-do.gs \
        genie/control-flow-if-else.gs \
        genie/control-flow-if-else-if.gs \
@@ -1222,6 +1226,7 @@ TESTS = \
        genie/control-flow-if-less-than.gs \
        genie/enum.gs \
        genie/enum-with-keyword-values.gs \
+       genie/exception.gs \
        genie/function.gs \
        genie/function-returns-closure.gs \
        genie/function-with-argument.gs \
@@ -1229,6 +1234,7 @@ TESTS = \
        genie/indentation-with-spaces.gs \
        genie/init.gs \
        genie/init-int.gs \
+       genie/interface.gs \
        genie/literal-boolean-assignment.gs \
        genie/literal-boolean.gs \
        genie/literal-character.gs \
diff --git a/tests/genie/class-field.gs b/tests/genie/class-field.gs
new file mode 100644 (file)
index 0000000..f6d93ac
--- /dev/null
@@ -0,0 +1,10 @@
+init
+       var a = new Test()
+       assert( a.a == "a" )
+       assert( a.b == "b" )
+       assert( a.c == "c" )
+
+class Test
+       a:string = "a"
+       b:class string = "b"
+       c:static string = "c"
diff --git a/tests/genie/class-init.gs b/tests/genie/class-init.gs
new file mode 100644 (file)
index 0000000..edbe01b
--- /dev/null
@@ -0,0 +1,18 @@
+init
+       var a = new Test()
+
+def nothing()
+       pass
+
+class Test:Object
+       init
+               nothing()
+
+       init class
+               nothing()
+
+       init static
+               nothing()
+
+       final
+               nothing()
diff --git a/tests/genie/class-signal.gs b/tests/genie/class-signal.gs
new file mode 100644 (file)
index 0000000..718bbe1
--- /dev/null
@@ -0,0 +1,11 @@
+init
+       var a = new Test()
+       a.foo.connect( test )
+       assert( a.foo(23) )
+       a.foo.disconnect( test )
+
+def test( a:int ):bool
+       return a == 23
+
+class Test
+       event foo( a:int ):bool
diff --git a/tests/genie/constant.gs b/tests/genie/constant.gs
new file mode 100644 (file)
index 0000000..9b4d445
--- /dev/null
@@ -0,0 +1,4 @@
+init
+       assert( TEST == 23 )
+
+const TEST:int = 23
diff --git a/tests/genie/exception.gs b/tests/genie/exception.gs
new file mode 100644 (file)
index 0000000..eb52d22
--- /dev/null
@@ -0,0 +1,7 @@
+init
+       e:TestError = new TestError.BAD( "not so good" )
+
+exception TestError
+       FAIL
+       BAD
+       WORSE
diff --git a/tests/genie/interface.gs b/tests/genie/interface.gs
new file mode 100644 (file)
index 0000000..cb90d5c
--- /dev/null
@@ -0,0 +1,10 @@
+init
+       var a = new Test()
+       assert( a.test(42) )
+
+interface ITest:Object
+       def abstract test( a:int ):bool
+
+class Test:Object implements ITest
+       def test( a:int ):bool
+               return a == 42