gtk+-3.0: Fix gtk_widget_adjust_size_* bindings
[vala-lang.git] / tests / errors / errors.vala
blobd56f3f230846a454bf82c438007a007967a9943f
1 using GLib;
3 errordomain Maman.BarError {
4 FOO,
5 BAR
8 class Maman.Bar : Object {
9 public void foo () throws BarError {
10 stdout.printf (" 6");
12 throw new BarError.FOO (" 8");
14 stdout.printf (" BAD");
17 public int bad () throws BarError {
18 stdout.printf (" 5");
20 foo ();
22 stdout.printf (" BAD");
24 return 0;
27 public void good () throws BarError {
28 stdout.printf (" 4");
31 public void error_cast_check (GLib.Error e) {}
33 public void run () {
34 stdout.printf (" 2");
36 try {
37 stdout.printf (" 3");
39 good ();
41 int i = bad ();
43 good ();
45 stdout.printf (" BAD");
46 } catch (BarError e) {
47 stdout.printf (" 7");
49 stdout.printf ("%s", e.message);
51 stdout.printf (" 9");
54 stdout.printf (" 10");
57 static void test_generic_catch () {
58 try {
59 throw new BarError.FOO ("error message");
60 } catch (Error e) {
61 return;
64 assert_not_reached ();
67 static void test_try_without_error () {
68 try {
69 } catch (Error e) {
70 assert_not_reached ();
74 public static int main () {
75 stdout.printf ("Exception Test: 1");
77 var bar = new Bar ();
78 bar.run ();
80 stdout.printf (" 11\n");
82 test_generic_catch ();
84 return 0;
88 void main () {
89 Maman.Bar.main ();