]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add [Profile] method test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 24 Nov 2021 20:26:03 +0000 (21:26 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 29 Nov 2021 12:07:21 +0000 (13:07 +0100)
tests/Makefile.am
tests/methods/profile.vala [new file with mode: 0644]

index 7fab0a41b3cc99ad376de94d71df94ef5ec0d985..9b4feb1cd3fa04d72ac246a7231e2095f0baa3a4 100644 (file)
@@ -245,6 +245,7 @@ TESTS = \
        methods/printf-invalid.test \
        methods/printf-constructor.vala \
        methods/printf-constructor-invalid.test \
+       methods/profile.vala \
        methods/varargs-delegate.vala \
        methods/varargs-delegate-without-target.vala \
        methods/varargs-gvalue.vala \
diff --git a/tests/methods/profile.vala b/tests/methods/profile.vala
new file mode 100644 (file)
index 0000000..a99b377
--- /dev/null
@@ -0,0 +1,19 @@
+[Profile]
+void foo () {
+       Thread.usleep (4000);
+}
+
+[Profile]
+int bar (bool b) {
+       Thread.usleep (4000);
+       if (b) {
+               return 42;
+       }
+       return 23;
+}
+
+void main () {
+       foo ();
+       assert (bar (false) == 23);
+       assert (bar (true) == 42);
+}