]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add ErrorReporter tests
authorFlorian Brosch <flo.brosch@gmail.com>
Tue, 12 Jul 2011 23:00:20 +0000 (01:00 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 29 Jul 2011 00:45:25 +0000 (02:45 +0200)
tests/Makefile.am
tests/libvaladoc/errorreporter.vala [new file with mode: 0644]
tests/testrunner.sh

index 3303350851b9f3a9210a01f047e710740bdcf7d1..fa3e37f05f4eb1cdfa61545f37d054157a9d175b 100644 (file)
@@ -15,6 +15,7 @@ noinst_PROGRAMS = \
 TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT) $(srcdir)/testrunner.sh
 
 TESTS = \
+       libvaladoc/errorreporter.vala \
        $(NULL)
 
 check-TESTS: $(TESTS)
diff --git a/tests/libvaladoc/errorreporter.vala b/tests/libvaladoc/errorreporter.vala
new file mode 100644 (file)
index 0000000..93ec7b4
--- /dev/null
@@ -0,0 +1,48 @@
+
+using Valadoc;
+
+void main () {
+       var reporter = new ErrorReporter ();
+       assert (reporter.warnings == 0);
+       assert (reporter.errors == 0);
+
+       // simple errors:
+       reporter.simple_error ("error 1 %d %s", 1, "foo");
+       assert (reporter.warnings == 0);
+       assert (reporter.errors == 1);
+
+       reporter.simple_error ("error 2");
+       assert (reporter.warnings == 0);
+       assert (reporter.errors == 2);
+
+
+       // simple warnings:
+       reporter.simple_warning ("warning 1 %d %s", 1, "foo");
+       assert (reporter.warnings == 1);
+       assert (reporter.errors == 2);
+
+       reporter.simple_warning ("warning 2");
+       assert (reporter.warnings == 2);
+       assert (reporter.errors == 2);
+
+
+       // errors:
+       reporter.error ("file", 1, 1, 1, "line", "error, complex, 1 %d %s", 1, "foo");
+       assert (reporter.warnings == 2);
+       assert (reporter.errors == 3);
+
+       reporter.error ("file", 1, 1, 1, "line", "error, complex, 2");
+       assert (reporter.warnings == 2);
+       assert (reporter.errors == 4);
+
+
+       // warnngs:
+       reporter.warning ("file", 1, 1, 1, "line", "warning, complex, 1 %d %s", 1, "foo");
+       assert (reporter.warnings == 3);
+       assert (reporter.errors == 4);
+
+       reporter.warning ("file", 1, 1, 1, "line", "warning, complex, 2");
+       assert (reporter.warnings == 4);
+       assert (reporter.errors == 4);
+}
+
index 531dbd5b6b0a4e9462ceaede5ab555521e384481..70fe8b433f1e7966198f6b1d8234ed091cfdd522 100755 (executable)
@@ -27,11 +27,12 @@ topsrcdir=$srcdir/..
 vapidir=$topsrcdir/vapi
 
 export G_DEBUG=fatal_warnings
+export PKG_CONFIG_PATH=../../src/libvaladoc
 
 VALAC=valac
-VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -g -X -O0 -X -pipe -X -lm -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast"
+VALAFLAGS="--vapidir ../../src/libvaladoc --pkg valadoc-1.0 --pkg gee-1.0 --disable-warnings --main main --save-temps -X -g -X -O0 -X -pipe -X -lm -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast -X -L../../src/libvaladoc/.libs -X -I../../src/libvaladoc"
 VAPIGEN=$topbuilddir/vapigen/vapigen
-VAPIGENFLAGS="--vapidir $vapidir"
+VAPIGENFLAGS=
 
 function testheader() {
        if [ "$1" = "Packages:" ]; then