return val;
}
+enum l_lsl_data_type l_lsl_value_rtype(struct l_lsl_value *v) {
+ return v->type;
+}
+
+char *l_lsl_value_rstr(struct l_lsl_value *v) {
+ return v->data.str_val;
+}
+
+i32 l_lsl_value_rint(struct l_lsl_value *v) {
+ return v->data.int_val;
+}
+
+
+
lrts_bool l_lsl_isnum(char c) {
return c >= '0' && c <= '9';
}
void l_lsl_value_free(struct l_lsl_vm *v,
struct l_lsl_value *val);
+/* value io */
+
+/* gets the type of a value */
+enum l_lsl_data_type l_lsl_value_rtype(struct l_lsl_value *v);
+
+/* reads string value of a value
+ * beware no type checking is performed */
+char *l_lsl_value_rstr(struct l_lsl_value *v);
+
+/* reads the int value of a value
+ * beware no type checking is performed */
+i32 l_lsl_value_rint(struct l_lsl_value *v);
+
/*
* gets the next token returns tone's length in token_len
* the result token is placed into an internal string buffer and should not be modified
int t_lsl_vlue_assert_int(struct l_lsl_value *expected,
struct l_lsl_value *actual) {
- T_ASSERT(expected->data.int_val == actual->data.int_val,
+ T_ASSERT(
+ l_lsl_value_rint(expected)
+ == l_lsl_value_rint(actual),
("Unexpected int value. Expected %d got %d\n", expected->data.int_val,
actual->data.int_val));
int t_lsl_vlue_assert_str(struct l_lsl_value *expected,
struct l_lsl_value *actual) {
- T_ASSERT(u_strncmp(expected->data.str_val, actual->data.str_val, 256) == 0,
+ T_ASSERT(u_strncmp(
+ l_lsl_value_rstr(expected),
+ l_lsl_value_rstr(actual), 256) == 0,
("Unexpected str value. Expected '%s' got '%s'\n", expected->data.str_val,
actual->data.str_val));
return 0;
}
T_ASSERT(res != LRTS_NULL, ("Invalid result value\n"))
- T_ASSERT(res->type == expect_value.type, ("Unexpected return value\n"));
+ T_ASSERT(l_lsl_value_rtype(res) == l_lsl_value_rtype(&expect_value),
+ ("Unexpected return value\n"));
if (assert_val(&expect_value, res) != 0) {
return 1;