Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scope automatically evaluates an expression if the mouse pointer is hovered over it. But before this change it only evaluated words. E.g. if the mouse was hovered over "structa->item1" then scope would have evaluated "structa" or "item1" depending on the exact position of the mouse pointer. With this change it will instead evaluate the value of "structa" if the mouse pointer is over "structa". If the mouse pointer is over "item1" then the expression "structa->item1" will be evaluated.
- Loading branch information
1 parent
e18cc0c
commit 648224a
Showing
6 changed files
with
499 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <check.h> | ||
|
||
#include <gtk/gtk.h> | ||
#include "geany.h" | ||
|
||
TCase *utils_create_tests(void); | ||
|
||
Suite * | ||
my_suite(void) | ||
{ | ||
Suite *s = suite_create("Scope"); | ||
suite_add_tcase(s, utils_create_tests()); | ||
return s; | ||
} | ||
|
||
int | ||
main(void) | ||
{ | ||
int nf; | ||
Suite *s = my_suite(); | ||
SRunner *sr = srunner_create(s); | ||
srunner_run_all(sr, CK_NORMAL); | ||
nf = srunner_ntests_failed(sr); | ||
srunner_free(sr); | ||
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <check.h> | ||
#include "../src/common.h" | ||
#include "../src/utils.h" | ||
|
||
typedef struct S_EXPR_TEST_ITEM | ||
{ | ||
const gchar *input; | ||
guint peek_index; | ||
const gchar *expected; | ||
}EXPR_TEST_ITEM; | ||
|
||
EXPR_TEST_ITEM expr_test_items [] = | ||
{ | ||
{ " variable ", sizeof(" var")-1, "variable" }, | ||
{ " (variable) ", sizeof(" (var")-1, "variable" }, | ||
{ "struct.item", sizeof("str")-1, "struct" }, | ||
{ "struct.item", sizeof("str")-1, "struct" }, | ||
{ "struct.item", sizeof("struct.it")-1, "struct.item" }, | ||
{ "struct->item", sizeof("str")-1, "struct" }, | ||
{ "struct->item", sizeof("struct->it")-1, "struct->item" }, | ||
{ "&(struct->item)", sizeof("&(str")-1, "struct" }, | ||
{ "&(struct->item)", sizeof("&(struct->it")-1, "struct->item" }, | ||
{ "foobar(item)", sizeof("foobar(it")-1, "item" }, | ||
{ "sizeof(item)", sizeof("sizeof(it")-1, "sizeof(item)" }, | ||
{ "array[5]", sizeof("arr")-1, "array" }, | ||
{ "array[5]", sizeof("array[")-1, "array[5]" }, | ||
{ "*pointer", sizeof("*poi")-1, "pointer" }, | ||
{ "*pointer", 0, "*pointer" }, | ||
{ "&variable", sizeof("&var")-1, "variable" }, | ||
{ "&variable", 0, "&variable" }, | ||
{ "foo variable", sizeof("foo var")-1, "variable" }, | ||
{ "variable foo", sizeof("var")-1, "variable" }, | ||
{ "int var_a, var_b;", sizeof("int var")-1, "var_a" }, | ||
{ "int var_a, var_b;", sizeof("int var_a, va")-1, "var_b" }, | ||
{ "foo(var_a, var_b);", sizeof("foo(var")-1, "var_a" }, | ||
{ "foo(var_a, var_b);", sizeof("foo(var_a, va")-1, "var_b" }, | ||
{ "array[index].item", sizeof("array[index].i")-1, "array[index].item" }, | ||
{ "array[index]->item", sizeof("array[index]->i")-1, "array[index]->item" }, | ||
{ NULL, 0, NULL }, | ||
}; | ||
|
||
START_TEST(test_parser_for_evaluate) | ||
{ | ||
EXPR_TEST_ITEM *test_item; | ||
guint index = 0; | ||
gchar *expr, *chunk; | ||
|
||
test_item = &(expr_test_items[index]); | ||
while (test_item->input != NULL) | ||
{ | ||
chunk = g_strdup(test_item->input); | ||
expr = utils_evaluate_expr_from_string (chunk, test_item->peek_index); | ||
ck_assert_ptr_ne(expr, NULL); | ||
if (g_strcmp0(expr, test_item->expected) != 0) | ||
{ | ||
ck_abort_msg("Index #%lu: Input: '%s', Peek-Ind.: %lu, Result: '%s' != '%s' (expected)", | ||
index, test_item->input, test_item->peek_index, expr, test_item->expected); | ||
} | ||
g_free(chunk); | ||
g_free(expr); | ||
|
||
index++; | ||
test_item = &(expr_test_items[index]); | ||
} | ||
} | ||
END_TEST; | ||
|
||
TCase *utils_create_tests(void) | ||
{ | ||
TCase *tc_utils = tcase_create("utils"); | ||
tcase_add_test(tc_utils, test_parser_for_evaluate); | ||
return tc_utils; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.