-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.vala
67 lines (56 loc) · 1.94 KB
/
test.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Ex;
void on_incremented (int val, int inc) {
stdout.printf ("incremented to %d by %d\n", val, inc);
}
void throw_err() throws Ex.Error {
throw new Ex.Error.FAILED ("something went wrong");
}
public int main (string[] args) {
var foo = new Ex.Foo ("foo's name");
foo.incremented.connect (on_incremented);
stdout.printf ("foo name: %s\n", foo.get_name ());
stdout.printf ("foo inc 1: %d\n", foo.increment (1));
stdout.printf ("foo inc 10: %d\n", foo.increment (10));
stdout.printf ("foo counter: %d\n", foo.get_counter ());
var bar = new Ex.Bar ("bar's name");
bar.incremented.connect (on_incremented);
stdout.printf ("bar name: %s\n", bar.get_name ());
stdout.printf ("bar inc 1: %d\n", bar.increment (1));
stdout.printf ("bar inc 10: %d\n", bar.increment (10));
stdout.printf ("bar counter: %d\n", bar.get_counter ());
stdout.printf ("bar number: %f\n", bar.get_number ());
stdout.printf ("bar number (property): %f\n", bar.number);
bar.set_number (10.0);
stdout.printf ("bar number: %f\n", bar.get_number ());
stdout.printf ("bar number (property): %f\n", bar.number);
bar.number = 20.0;
stdout.printf ("bar number: %f\n", bar.get_number ());
stdout.printf ("bar number (property): %f\n", bar.number);
var s = new Ex.RString ("something");
stdout.printf ("rstring: %s\n", s.get ());
var s2 = s.copy ();
s2.set ("something else");
stdout.printf ("rstring 2: %s\n", s2.get ());
var ss = new Ex.SharedRString ("something");
stdout.printf ("shared rstring: %s\n", ss.get ());
var ss2 = ss.ref ();
stdout.printf ("shared rstring 2: %s\n", ss2.get ());
try {
throw_err();
assert_not_reached();
} catch (Ex.Error e) {
assert_error(e, Ex.Error.quark(), Ex.Error.FAILED);
}
var loop = new MainLoop();
var cancellable = new GLib.Cancellable();
foo.check_async.begin(cancellable, (obj, res) => {
try {
foo.check_async.end(res);
} catch (GLib.Error e) {
assert_not_reached();
}
loop.quit();
});
loop.run();
return 0;
}