summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-04-22 20:31:11 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-04-22 20:31:11 +0200
commitb9c1cc2800ad0462e8b9e8785c79a49ace40f72f (patch)
treeb00928b6600f12ad777b8a209e098e3874a74597
parent010ae10d60e78a26eef86d77c09966e3df9546d0 (diff)
Eolian: add methods and properties scope support tests
-rw-r--r--src/tests/eolian/data/scope.eo24
-rw-r--r--src/tests/eolian/eolian_suite.c30
2 files changed, 54 insertions, 0 deletions
diff --git a/src/tests/eolian/data/scope.eo b/src/tests/eolian/data/scope.eo
new file mode 100644
index 0000000..a0c0448
--- /dev/null
+++ b/src/tests/eolian/data/scope.eo
@@ -0,0 +1,24 @@
1class Simple {
2 properties {
3 protected a {
4 get {
5 }
6 }
7 b {
8 get {
9 }
10 }
11 public c {
12 get {
13 }
14 }
15 }
16 methods {
17 foo {
18 }
19 protected bar {
20 }
21 public foobar {
22 }
23 }
24};
diff --git a/src/tests/eolian/eolian_suite.c b/src/tests/eolian/eolian_suite.c
index 7534e57..2f292e5 100644
--- a/src/tests/eolian/eolian_suite.c
+++ b/src/tests/eolian/eolian_suite.c
@@ -16,6 +16,35 @@ struct _Eolian_Test_Case
16 void (*build)(TCase *tc); 16 void (*build)(TCase *tc);
17}; 17};
18 18
19START_TEST(eolian_scope)
20{
21 Eolian_Function fid = NULL;
22 const char *class_name = "Simple";
23
24 eolian_init();
25 /* Parsing */
26 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/scope.eo"));
27
28 /* Property scope */
29 fail_if(!(fid = eolian_class_function_find_by_name(class_name, "a", EOLIAN_PROPERTY)));
30 fail_if(eolian_function_scope_get(fid) != EOLIAN_SCOPE_PROTECTED);
31 fail_if(!(fid = eolian_class_function_find_by_name(class_name, "b", EOLIAN_PROPERTY)));
32 fail_if(eolian_function_scope_get(fid) != EOLIAN_SCOPE_PUBLIC);
33 fail_if(!(fid = eolian_class_function_find_by_name(class_name, "c", EOLIAN_PROPERTY)));
34 fail_if(eolian_function_scope_get(fid) != EOLIAN_SCOPE_PUBLIC);
35
36 /* Method scope */
37 fail_if(!(fid = eolian_class_function_find_by_name(class_name, "foo", EOLIAN_METHOD)));
38 fail_if(eolian_function_scope_get(fid) != EOLIAN_SCOPE_PUBLIC);
39 fail_if(!(fid = eolian_class_function_find_by_name(class_name, "bar", EOLIAN_METHOD)));
40 fail_if(eolian_function_scope_get(fid) != EOLIAN_SCOPE_PROTECTED);
41 fail_if(!(fid = eolian_class_function_find_by_name(class_name, "foobar", EOLIAN_METHOD)));
42 fail_if(eolian_function_scope_get(fid) != EOLIAN_SCOPE_PUBLIC);
43
44 eolian_shutdown();
45}
46END_TEST
47
19START_TEST(eolian_simple_parsing) 48START_TEST(eolian_simple_parsing)
20{ 49{
21 Eolian_Function fid = NULL; 50 Eolian_Function fid = NULL;
@@ -111,6 +140,7 @@ END_TEST
111static void eolian_parsing_test(TCase *tc) 140static void eolian_parsing_test(TCase *tc)
112{ 141{
113 tcase_add_test(tc, eolian_simple_parsing); 142 tcase_add_test(tc, eolian_simple_parsing);
143 tcase_add_test(tc, eolian_scope);
114} 144}
115 145
116static const Eolian_Test_Case etc[] = { 146static const Eolian_Test_Case etc[] = {