20
20
var v1 = new ConstantValueToken (13,37);
21
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
23
Type t1 = v1.get_type ();
33
if (!(t1.is_a (typeof (ConstantValueToken))) ||
34
!(t1.is_a (typeof (ValueToken))) ||
35
!(t1.is_a (typeof (Token)))) {
24
if (!(t1.is_a (typeof (ConstantValueToken)) &&
25
t1.is_a (typeof (ValueToken)) &&
26
t1.is_a (typeof (Token)))) {
36
27
GLib.Test.message ("The ConstastValueToken is not the corret type.");
38
29
GLib.assert_not_reached ();
41
32
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", () => {
33
if (!((t2.is_a (typeof (VariableValueToken))) &&
34
(t2.is_a (typeof (ValueToken))) &&
35
(t2.is_a (typeof (Token))))) {
36
GLib.Test.message ("The VariableValueToken is not the corret type.");
38
GLib.assert_not_reached ();
43
GLib.Test.add_func ("/VQDR/Expression/token/Value/Factory", () => {
44
var v3 = ValueToken.init_value_token (13L, 37);
45
var v4 = ValueToken.init_value_token ("foo", 12);
46
Type t4 = v4.get_type ();
47
Type t3 = v3.get_type ();
50
if (!(t3.is_a (typeof (ConstantValueToken))) &&
51
t3.is_a (typeof (ValueToken)) &&
52
t3.is_a (typeof (Token))) {
53
GLib.Test.message ("The ConstastValueToken is not the corret type.");
55
GLib.assert_not_reached ();
59
if (!((t4.is_a (typeof (VariableValueToken))) &&
60
(t4.is_a (typeof (ValueToken))) &&
61
(t4.is_a (typeof (Token))))) {
62
GLib.Test.message ("The VariableValueToken is not the corret type.");
64
GLib.assert_not_reached ();
68
GLib.Test.add_func ("/VQDR/Expression/Token/Value/Constant", () => {
63
78
root_t.evaluate (ctx);
65
long out_val = root_t.result_value;
80
long out_val = root_t.result_value.number;
67
82
if (out_val != in_val) {
68
GLib.Test.message ("The values do not match");
83
GLib.Test.message ("The values do not match: Expected %li, got %li.\n",
71
87
} catch (GLib.Error? e) {
103
GLib.Test.add_func ("/VQDR/Exprossion/Token/Value/Varuable", () => {
119
GLib.Test.add_func ("/VQDR/Expression/Token/Value/Varuable", () => {
105
121
var ctx = new Context ();
106
122
ctx.set_value ("a", 0, 0, 13);
107
123
ctx.set_value ("not a", 0, 0, 37);
109
125
// Context variable santy check.
110
if ((ctx.get_value ("a") != 13) || (ctx.get_value ("not a") != 37)) {
126
if ((ctx.get_value ("a").number != 13) || (ctx.get_value ("not a").number != 37)) {
111
127
GLib.Test.message ("The values do not match");
113
129
GLib.Test.fail ();
116
132
var v1 = new VariableValueToken ("a", 1);
117
133
var v2 = new VariableValueToken ("not a", 1);
135
print (v1.result_string + "\n");
136
print (v2.result_string + "\n");
119
137
} catch (GLib.Error? e) {
120
138
GLib.Test.message ("An error occured: domain: %s, message: %s", e.domain.to_string (), e.message);
121
139
GLib.Test.fail ();