summaryrefslogtreecommitdiff
path: root/tests/delegates/error-pos.vala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/delegates/error-pos.vala')
-rw-r--r--tests/delegates/error-pos.vala47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/delegates/error-pos.vala b/tests/delegates/error-pos.vala
new file mode 100644
index 000000000..2e9301a68
--- /dev/null
+++ b/tests/delegates/error-pos.vala
@@ -0,0 +1,47 @@
+errordomain FooError {
+ BAR;
+}
+
+[CCode (error_pos = 1.8, instance_pos = 1.9)]
+delegate string FooFunc (int i) throws FooError;
+
+class Bar {
+ [CCode (error_pos = 0.8)]
+ public string foo (int i) throws FooError {
+ assert (this is Bar);
+ return "%i".printf (i);
+ }
+
+ [CCode (error_pos = 0.8)]
+ public string faz (int i) throws FooError {
+ assert (this is Bar);
+ throw new FooError.BAR ("%i".printf (i));
+ }
+}
+
+void foo (FooFunc f) {
+ try {
+ assert (f (23) == "23");
+ } catch {
+ assert_not_reached ();
+ }
+}
+
+void main () {
+ try {
+ var bar = new Bar ();
+ assert (bar.foo (42) == "42");
+ foo (bar.foo);
+ } catch {
+ assert_not_reached ();
+ }
+
+ try {
+ var bar = new Bar ();
+ bar.faz (42);
+ } catch (FooError.BAR e) {
+ assert (e.message == "42");
+ } catch {
+ assert_not_reached ();
+ }
+}