[vala/0.48] tests: Add more "statement" tests for genie to increase coverage



commit 7609f9974d516dcaeda2ff7122cc2e984b30c5f7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Nov 6 15:35:12 2021 +0100

    tests: Add more "statement" tests for genie to increase coverage

 tests/Makefile.am                 | 11 +++++++++++
 tests/genie/case.gs               |  6 ++++++
 tests/genie/do-while.gs           |  8 ++++++++
 tests/genie/for-downto.gs         |  3 +++
 tests/genie/for-in.gs             |  4 ++++
 tests/genie/for-to.gs             |  3 +++
 tests/genie/initializer-list.gs   |  7 +++++++
 tests/genie/print.gs              |  2 ++
 tests/genie/sizeof.gs             |  3 +++
 tests/genie/try-except-finally.gs | 13 +++++++++++++
 tests/genie/typeof.gs             |  3 +++
 tests/genie/while.gs              |  6 ++++++
 12 files changed, 69 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3e7452c85..df6b1c059 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1150,6 +1150,7 @@ TESTS = \
        version/since-local-variable.test \
        version/since-method.test \
        version/since-parameter.test \
+       genie/case.gs \
        genie/class.gs \
        genie/class-field.gs \
        genie/class-init.gs \
@@ -1163,9 +1164,13 @@ TESTS = \
        genie/control-flow-if.gs \
        genie/control-flow-if-identity.gs \
        genie/control-flow-if-less-than.gs \
+       genie/do-while.gs \
        genie/enum.gs \
        genie/enum-with-keyword-values.gs \
        genie/exception.gs \
+       genie/for-downto.gs \
+       genie/for-in.gs \
+       genie/for-to.gs \
        genie/function.gs \
        genie/function-returns-closure.gs \
        genie/function-with-argument.gs \
@@ -1173,6 +1178,7 @@ TESTS = \
        genie/indentation-with-spaces.gs \
        genie/init.gs \
        genie/init-int.gs \
+       genie/initializer-list.gs \
        genie/interface.gs \
        genie/literal-boolean-assignment.gs \
        genie/literal-boolean.gs \
@@ -1219,8 +1225,13 @@ TESTS = \
        genie/preparser.gs \
        genie/preparser-not.gs \
        genie/preparser-or-expression.gs \
+       genie/print.gs \
+       genie/sizeof.gs \
        genie/struct.gs \
        genie/struct-after-class.gs \
+       genie/try-except-finally.gs \
+       genie/typeof.gs \
+       genie/while.gs \
        $(LINUX_TESTS) \
        $(NULL)
 
diff --git a/tests/genie/case.gs b/tests/genie/case.gs
new file mode 100644
index 000000000..405587627
--- /dev/null
+++ b/tests/genie/case.gs
@@ -0,0 +1,6 @@
+init
+       a:int = 13
+       case a
+               when 13
+               when 23, 42
+               default
diff --git a/tests/genie/do-while.gs b/tests/genie/do-while.gs
new file mode 100644
index 000000000..6ffb22757
--- /dev/null
+++ b/tests/genie/do-while.gs
@@ -0,0 +1,8 @@
+init
+       do
+               break
+       while true
+
+       do
+               continue
+       while false
diff --git a/tests/genie/for-downto.gs b/tests/genie/for-downto.gs
new file mode 100644
index 000000000..1a7163717
--- /dev/null
+++ b/tests/genie/for-downto.gs
@@ -0,0 +1,3 @@
+init
+       for i:int = 42 downto 23
+               assert( i >= 23)
diff --git a/tests/genie/for-in.gs b/tests/genie/for-in.gs
new file mode 100644
index 000000000..890e1b1ff
--- /dev/null
+++ b/tests/genie/for-in.gs
@@ -0,0 +1,4 @@
+init
+       a:string[] = { "a", "b", "c" }
+       for s:string in a
+               assert( s != "d" )
diff --git a/tests/genie/for-to.gs b/tests/genie/for-to.gs
new file mode 100644
index 000000000..771bc305b
--- /dev/null
+++ b/tests/genie/for-to.gs
@@ -0,0 +1,3 @@
+init
+       for i:int = 0 to 23
+               assert( i < 42)
diff --git a/tests/genie/initializer-list.gs b/tests/genie/initializer-list.gs
new file mode 100644
index 000000000..baa02457f
--- /dev/null
+++ b/tests/genie/initializer-list.gs
@@ -0,0 +1,7 @@
+init
+       s:string[] = { "a", "b", "c" }
+
+       assert( s.length == 3 )
+       assert( s[0] == "a" )
+       assert( s[1] == "b" )
+       assert( s[2] == "c" )
diff --git a/tests/genie/print.gs b/tests/genie/print.gs
new file mode 100644
index 000000000..8c82e3e1e
--- /dev/null
+++ b/tests/genie/print.gs
@@ -0,0 +1,2 @@
+init
+       print( "%s = %i + %.4f", "a", 42, 3.1415 )
diff --git a/tests/genie/sizeof.gs b/tests/genie/sizeof.gs
new file mode 100644
index 000000000..db7d659e5
--- /dev/null
+++ b/tests/genie/sizeof.gs
@@ -0,0 +1,3 @@
+init
+       a:ulong = sizeof( uint32 )
+       assert( a == 4 )
diff --git a/tests/genie/try-except-finally.gs b/tests/genie/try-except-finally.gs
new file mode 100644
index 000000000..038995c58
--- /dev/null
+++ b/tests/genie/try-except-finally.gs
@@ -0,0 +1,13 @@
+def test() raises IOError, Error
+       raise new IOError.FAILED( "failed" )
+
+init
+       a:int = 0
+       try
+               a++
+               test()
+       except e:Error
+               a++
+       finally
+               a++
+       assert( a == 3 )
diff --git a/tests/genie/typeof.gs b/tests/genie/typeof.gs
new file mode 100644
index 000000000..0069d1b49
--- /dev/null
+++ b/tests/genie/typeof.gs
@@ -0,0 +1,3 @@
+init
+       a:Type = typeof( int )
+       assert( a == Type.INT )
diff --git a/tests/genie/while.gs b/tests/genie/while.gs
new file mode 100644
index 000000000..aed846938
--- /dev/null
+++ b/tests/genie/while.gs
@@ -0,0 +1,6 @@
+init
+       while true do
+               break
+
+       while false
+               assert_not_reached()


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