[vala/staging] tests: Add "integer/float literal" tests to increase coverage



commit 9a6dd63bbf18f50d70c1a38b2b1f887771eabf15
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Sep 28 17:36:50 2021 +0200

    tests: Add "integer/float literal" tests to increase coverage

 tests/Makefile.am                             |  2 +
 tests/basic-types/float-literals.c-expected   | 40 +++++++++++++++++++
 tests/basic-types/float-literals.vala         | 14 +++++++
 tests/basic-types/integer-literals.c-expected | 56 +++++++++++++++++++++++++++
 tests/basic-types/integer-literals.vala       | 26 +++++++++++++
 5 files changed, 138 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cb1ac9fe8..d42298f6f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,9 +40,11 @@ AM_TESTS_ENVIRONMENT = \
 
 TESTS = \
        basic-types/gassert.vala \
+       basic-types/integer-literals.vala \
        basic-types/integers.vala \
        basic-types/integers-boxed-cast.vala \
        basic-types/escape-chars.vala \
+       basic-types/float-literals.vala \
        basic-types/floats.vala \
        basic-types/floats-boxed-cast.vala \
        basic-types/boolean.vala \
diff --git a/tests/basic-types/float-literals.c-expected b/tests/basic-types/float-literals.c-expected
new file mode 100644
index 000000000..baa5423a1
--- /dev/null
+++ b/tests/basic-types/float-literals.c-expected
@@ -0,0 +1,40 @@
+/* basic_types_float_literals.c generated by valac, the Vala compiler
+ * generated from basic_types_float_literals.vala, do not modify */
+
+#include <glib.h>
+#include <float.h>
+#include <math.h>
+
+static void _vala_main (void);
+
+static void
+_vala_main (void)
+{
+       {
+               gfloat foo = 0.0F;
+               gfloat bar = 0.0F;
+               foo = 23.42F;
+               bar = 47.11f;
+       }
+       {
+               gdouble foo = 0.0;
+               gdouble bar = 0.0;
+               foo = 23.42;
+               bar = 47.11;
+       }
+       {
+               gdouble foo = 0.0;
+               gdouble bar = 0.0;
+               foo = 23.42;
+               bar = 47.11;
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main ();
+       return 0;
+}
+
diff --git a/tests/basic-types/float-literals.vala b/tests/basic-types/float-literals.vala
new file mode 100644
index 000000000..b4bba83a4
--- /dev/null
+++ b/tests/basic-types/float-literals.vala
@@ -0,0 +1,14 @@
+void main () {
+       {
+               float foo = 23.42F;
+               float bar = 47.11f;
+       }
+       {
+               double foo = 23.42D;
+               double bar = 47.11d;
+       }
+       {
+               double foo = 23.42;
+               double bar = 47.11;
+       }
+}
diff --git a/tests/basic-types/integer-literals.c-expected b/tests/basic-types/integer-literals.c-expected
new file mode 100644
index 000000000..c534fbe7f
--- /dev/null
+++ b/tests/basic-types/integer-literals.c-expected
@@ -0,0 +1,56 @@
+/* basic_types_integer_literals.c generated by valac, the Vala compiler
+ * generated from basic_types_integer_literals.vala, do not modify */
+
+#include <glib.h>
+
+static void _vala_main (void);
+
+static void
+_vala_main (void)
+{
+       {
+               guint foo = 0U;
+               guint bar = 0U;
+               foo = 23U;
+               bar = 42U;
+       }
+       {
+               gint foo = 0;
+               gint bar = 0;
+               foo = 23;
+               bar = 42;
+       }
+       {
+               gulong foo = 0UL;
+               gulong bar = 0UL;
+               foo = 23UL;
+               bar = 42UL;
+       }
+       {
+               glong foo = 0L;
+               glong bar = 0L;
+               foo = 23L;
+               bar = 42L;
+       }
+       {
+               guint64 foo = 0ULL;
+               guint64 bar = 0ULL;
+               foo = 23ULL;
+               bar = 42ULL;
+       }
+       {
+               gint64 foo = 0LL;
+               gint64 bar = 0LL;
+               foo = 23LL;
+               bar = 42LL;
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main ();
+       return 0;
+}
+
diff --git a/tests/basic-types/integer-literals.vala b/tests/basic-types/integer-literals.vala
new file mode 100644
index 000000000..60deedbd8
--- /dev/null
+++ b/tests/basic-types/integer-literals.vala
@@ -0,0 +1,26 @@
+void main () {
+       {
+               uint foo = 23U;
+               uint bar = 42u;
+       }
+       {
+               int foo = 23;
+               int bar = 42;
+       }
+       {
+               ulong foo = 23UL;
+               ulong bar = 42ul;
+       }
+       {
+               long foo = 23L;
+               long bar = 42l;
+       }
+       {
+               uint64 foo = 23ULL;
+               uint64 bar = 42ull;
+       }
+       {
+               int64 foo = 23LL;
+               int64 bar = 42ll;
+       }
+}


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