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