5
GLib.Test.add_func ("/VQDR/Exprossion/Token/Value/sanity", () => {
6
var ctx = new Context ();
9
GLib.Test.message ("Context was null.");
11
GLib.assert_not_reached ();
14
if (!(ctx.get_type ().is_a (typeof (Context)))) {
15
GLib.Test.message ("Context is not the right type.");
17
GLib.assert_not_reached ();
20
var v1 = new ConstantValueToken (13,37);
21
var v2 = new VariableValueToken ("my-val", 13);
24
// This should work, but it does not... It is a vala parsing bug...
26
bool value_test = ((v1 is typeof (ConstantValueToken)) ||
27
(v1 is typeof (ValueToken)) ||
28
(v1 is typeof (Token)));
32
Type t1 = v1.get_type ();
33
if (!(t1.is_a (typeof (ConstantValueToken))) ||
34
!(t1.is_a (typeof (ValueToken))) ||
35
!(t1.is_a (typeof (Token)))) {
36
GLib.Test.message ("The ConstastValueToken is not the corret type.");
38
GLib.assert_not_reached ();
41
Type t2 = v2.get_type ();
42
if (!(t2.is_a (typeof (VariableValueToken))) ||
43
!(t2.is_a (typeof (ValueToken))) ||
44
!(t2.is_a (typeof (Token)))) {
45
GLib.Test.message ("The VariableValueToken is not the corret type.");
47
GLib.assert_not_reached ();
53
GLib.Test.add_func ("/VQDR/Exprossion/Token/Value/Constant", () => {
57
var ctx = new Context ();
59
var v1 = new ConstantValueToken (in_val, 1);
61
var root_t = new RootToken (v1);
63
root_t.evaluate (ctx);
65
long out_val = root_t.result_value;
67
if (out_val != in_val) {
68
GLib.Test.message ("The values do not match");
71
} catch (GLib.Error? e) {
72
GLib.Test.message ("An error occured: domain: %s, message: %s", e.domain.to_string (), e.message);
77
GLib.Test.add_func ("/VQDR/Exprossion/Token/Value/ConstantLoop", () => {
81
var ctx = new Context ();
83
for (int i = 0; i <= 10000; i++ ) {
84
var v1 = new ConstantValueToken (i, 1);
86
var root_t = new RootToken (v1);
88
root_t.evaluate (ctx);
90
long out_val = root_t.result_value;
93
GLib.Test.message ("The values do not match");
97
} catch (GLib.Error? e) {
98
GLib.Test.message ("An error occured: domain: %s, message: %s", e.domain.to_string (), e.message);
103
GLib.Test.add_func ("/VQDR/Exprossion/Token/Value/Varuable", () => {
105
var ctx = new Context ();
106
ctx.set_value ("a", 0, 0, 13);
107
ctx.set_value ("not a", 0, 0, 37);
109
// Context variable santy check.
110
if ((ctx.get_value ("a") != 13) || (ctx.get_value ("not a") != 37)) {
111
GLib.Test.message ("The values do not match");
116
var v1 = new VariableValueToken ("a", 1);
117
var v2 = new VariableValueToken ("not a", 1);
119
} catch (GLib.Error? e) {
120
GLib.Test.message ("An error occured: domain: %s, message: %s", e.domain.to_string (), e.message);