summaryrefslogtreecommitdiff
path: root/src/tests/eolian_js
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2016-03-16 16:08:45 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2016-03-18 17:47:09 -0300
commita6025b5d27f98b8595a1eb33f8f24fe998af8b90 (patch)
treec5d1bdc305ae5d8879fd352ca82ea05c789f334a /src/tests/eolian_js
parent1422e62f302f2f2f0995b19f98d6f971e39a921f (diff)
efl js: Finish Eina_Iterator binding
Diffstat (limited to 'src/tests/eolian_js')
-rwxr-xr-xsrc/tests/eolian_js/eolian_js_suite.js127
-rw-r--r--src/tests/eolian_js/eolian_js_test_test_object_impl.c122
-rw-r--r--src/tests/eolian_js/test_object.eo42
3 files changed, 291 insertions, 0 deletions
diff --git a/src/tests/eolian_js/eolian_js_suite.js b/src/tests/eolian_js/eolian_js_suite.js
index 9c66dba..66e5596 100755
--- a/src/tests/eolian_js/eolian_js_suite.js
+++ b/src/tests/eolian_js/eolian_js_suite.js
@@ -252,6 +252,8 @@ startTest("struct_values", function() {
252 assert(ret.valueEnum === suite.Test.EnumEx.FOURTH); 252 assert(ret.valueEnum === suite.Test.EnumEx.FOURTH);
253}); 253});
254 254
255// Events //
256
255startTest("event_simple", function() { 257startTest("event_simple", function() {
256 var v = false; 258 var v = false;
257 var obj = new TestObject(null); 259 var obj = new TestObject(null);
@@ -332,6 +334,8 @@ startTest("event_stringarg", function() {
332 assert(v); 334 assert(v);
333}); 335});
334 336
337// Array //
338
335// // TODO: disabled. Not implemented yet 339// // TODO: disabled. Not implemented yet
336// startTest("integral_array", function() { 340// startTest("integral_array", function() {
337// var obj = new TestObject(null); 341// var obj = new TestObject(null);
@@ -431,6 +435,8 @@ startTest("method_array_of_structs", function() {
431 assert(s.valueEnum === suite.Test.EnumEx.THIRD); 435 assert(s.valueEnum === suite.Test.EnumEx.THIRD);
432}); 436});
433 437
438// List //
439
434startTest("list_in_list_out", function() { 440startTest("list_in_list_out", function() {
435 var obj = new TestObject(null); 441 var obj = new TestObject(null);
436 var newList = obj.checkMethodListWith42(); 442 var newList = obj.checkMethodListWith42();
@@ -524,6 +530,8 @@ startTest("method_list_of_structs", function() {
524 assert(s.valueEnum === suite.Test.EnumEx.THIRD); 530 assert(s.valueEnum === suite.Test.EnumEx.THIRD);
525}); 531});
526 532
533// Accessor //
534
527startTest("method_accessor_of_objects", function() { 535startTest("method_accessor_of_objects", function() {
528 var obj = new TestObject(null); 536 var obj = new TestObject(null);
529 var acc = obj.checkMethodAccessorOfObjects(null); 537 var acc = obj.checkMethodAccessorOfObjects(null);
@@ -606,6 +614,125 @@ startTest("method_accessor_of_structs", function() {
606 assert(s.valueEnum === suite.Test.EnumEx.THIRD); 614 assert(s.valueEnum === suite.Test.EnumEx.THIRD);
607}); 615});
608 616
617// Iterator //
618
619startTest("method_iterator_of_objects", function() {
620 var obj = new TestObject(null);
621 var it = obj.checkMethodIteratorOfObjects(null);
622 assert(it != null);
623 it = obj.checkMethodIteratorOfObjects(it);
624 assert(it != null);
625 var idx = 0;
626 for (var n = it.next(); !n.done; n = it.next()) {
627 var v = n.value;
628 assert(v != null);
629 var expectedValue = 1234;
630 v.checkMethodIntegralInA(expectedValue);
631 var actualValue = v.checkMethodIntegralOutA();
632 assert(actualValue == expectedValue, actualValue + " == " + expectedValue);
633 idx++;
634 }
635 assert(idx == 2, idx + " == 2");
636});
637
638startTest("method_iterator_of_strings", function() {
639 var obj = new TestObject(null);
640 var it = obj.checkMethodIteratorOfStrings(null);
641 assert(it != null);
642 it = obj.checkMethodIteratorOfStrings(it);
643 assert(it != null);
644 var cmp = ["foo", "bar"];
645 var idx = 0;
646 for (var n = it.next(); !n.done; n = it.next()) {
647 var v = n.value;
648 assert(v === cmp[idx], idx+": "+v+" === "+cmp[idx]);
649 idx++;
650 }
651 assert(idx == 2, idx + " == 2");
652});
653
654startTest("method_iterator_of_ints", function() {
655 var obj = new TestObject(null);
656 var it = obj.checkMethodIteratorOfInts(null);
657 assert(it != null);
658 it = obj.checkMethodIteratorOfInts(it);
659 assert(it != null);
660 var cmp = [42, 24];
661 var idx = 0;
662 for (var n = it.next(); !n.done; n = it.next()) {
663 var v = n.value;
664 assert(v === cmp[idx], idx+": "+v+" === "+cmp[idx]);
665 idx++;
666 }
667 assert(idx == 2, idx + " == 2");
668});
669
670startTest("method_iterator_of_bools", function() {
671 var obj = new TestObject(null);
672 var it = obj.checkMethodIteratorOfBools(null);
673 assert(it != null);
674 it = obj.checkMethodIteratorOfBools(it);
675 assert(it != null);
676 var cmp = [true, false];
677 var idx = 0;
678 for (var n = it.next(); !n.done; n = it.next()) {
679 var v = n.value;
680 assert(v === cmp[idx], idx+": "+v+" === "+cmp[idx]);
681 idx++;
682 }
683 assert(idx == 2, idx + " == 2");
684});
685
686startTest("method_iterator_of_doubles", function() {
687 var obj = new TestObject(null);
688 var it = obj.checkMethodIteratorOfDoubles(null);
689 assert(it != null);
690 it = obj.checkMethodIteratorOfDoubles(it);
691 assert(it != null);
692 var cmp = [42.0, 24.0];
693 var idx = 0;
694 for (var n = it.next(); !n.done; n = it.next()) {
695 var v = n.value;
696 assert(v === cmp[idx], idx+": "+v+" === "+cmp[idx]);
697 idx++;
698 }
699 assert(idx == 2, idx + " == 2");
700});
701
702startTest("method_iterator_of_enums", function() {
703 var obj = new TestObject(null);
704 var it = obj.checkMethodIteratorOfEnums(null);
705 assert(it != null);
706 it = obj.checkMethodIteratorOfEnums(it);
707 assert(it != null);
708 var cmp = [suite.Test.EnumEx.THIRD, suite.Test.EnumEx.FIRST];
709 var idx = 0;
710 for (var n = it.next(); !n.done; n = it.next()) {
711 var v = n.value;
712 assert(v === cmp[idx], idx+": "+v+" === "+cmp[idx]);
713 idx++;
714 }
715 assert(idx == 2, idx + " == 2");
716});
717
718startTest("method_iterator_of_structs", function() {
719 var obj = new TestObject(null);
720 var it = obj.checkMethodIteratorOfStructs(null);
721 assert(it != null);
722 it = obj.checkMethodIteratorOfStructs(it);
723 assert(it != null);
724 var cmp = [[42, suite.Test.EnumEx.THIRD], [24, suite.Test.EnumEx.FIRST]];
725 var idx = 0;
726 for (var n = it.next(); !n.done; n = it.next()) {
727 var v = n.value;
728 assert(v != null);
729 assert(v.valueInt === cmp[idx][0], idx+": "+v.valueInt+" === "+cmp[idx][0]);
730 assert(v.valueEnum === cmp[idx][1], idx+": "+v.valueEnum+" === "+cmp[idx][1]);
731 idx++;
732 }
733 assert(idx == 2, idx + " == 2");
734});
735
609// Combinations of complex types // 736// Combinations of complex types //
610 737
611// FIXME 738// FIXME
diff --git a/src/tests/eolian_js/eolian_js_test_test_object_impl.c b/src/tests/eolian_js/eolian_js_test_test_object_impl.c
index aecfbbf..34981a1 100644
--- a/src/tests/eolian_js/eolian_js_test_test_object_impl.c
+++ b/src/tests/eolian_js/eolian_js_test_test_object_impl.c
@@ -587,6 +587,128 @@ _test_object_method_accessor_of_structs_check(Eo* obj EINA_UNUSED,
587 return eina_array_accessor_new(arr); 587 return eina_array_accessor_new(arr);
588} 588}
589 589
590// Iterator //
591
592EOLIAN static Eina_Iterator *
593_test_object_method_iterator_of_objects_check(Eo* obj,
594 Test_Object_Data *pd EINA_UNUSED,
595 Eina_Iterator *i_in)
596{
597 fprintf(stdout, "_test_object_method_iterator_of_objects_check(%p)\n", i_in);
598 fflush(stdout);
599 if (i_in) return i_in;
600 Eina_Array *arr = eina_array_new(2);
601 eina_array_push(arr, obj);
602 eina_array_push(arr, obj);
603 return eina_array_iterator_new(arr);
604}
605
606EOLIAN static Eina_Iterator *
607_test_object_method_iterator_of_strings_check(Eo* obj EINA_UNUSED,
608 Test_Object_Data *pd EINA_UNUSED,
609 Eina_Iterator *i_in)
610{
611 fprintf(stdout, "_test_object_method_iterator_of_strings_check(%p)\n", i_in);
612 fflush(stdout);
613 if (i_in) return i_in;
614 Eina_Array *arr = eina_array_new(2);
615 eina_array_push(arr, "foo");
616 eina_array_push(arr, "bar");
617 return eina_array_iterator_new(arr);
618}
619
620EOLIAN static Eina_Iterator *
621_test_object_method_iterator_of_ints_check(Eo* obj EINA_UNUSED,
622 Test_Object_Data *pd EINA_UNUSED,
623 Eina_Iterator *i_in)
624{
625 fprintf(stdout, "_test_object_method_iterator_of_ints_check(%p)\n", i_in);
626 fflush(stdout);
627 if (i_in) return i_in;
628 Eina_Array *arr = eina_array_new(2);
629 int *v = malloc(sizeof(int));
630 *v = 42;
631 eina_array_push(arr, v);
632 v = malloc(sizeof(int));
633 *v = 24;
634 eina_array_push(arr, v);
635 return eina_array_iterator_new(arr);
636}
637
638EOLIAN static Eina_Iterator *
639_test_object_method_iterator_of_bools_check(Eo* obj EINA_UNUSED,
640 Test_Object_Data *pd EINA_UNUSED,
641 Eina_Iterator *i_in)
642{
643 fprintf(stdout, "_test_object_method_iterator_of_bools_check(%p)\n", i_in);
644 fflush(stdout);
645 if (i_in) return i_in;
646 Eina_Array *arr = eina_array_new(2);
647 Eina_Bool *v = malloc(sizeof(Eina_Bool));
648 *v = EINA_TRUE;
649 eina_array_push(arr, v);
650 v = malloc(sizeof(Eina_Bool));
651 *v = EINA_FALSE;
652 eina_array_push(arr, v);
653 return eina_array_iterator_new(arr);
654}
655
656EOLIAN static Eina_Iterator *
657_test_object_method_iterator_of_doubles_check(Eo* obj EINA_UNUSED,
658 Test_Object_Data *pd EINA_UNUSED,
659 Eina_Iterator *i_in)
660{
661 fprintf(stdout, "_test_object_method_iterator_of_doubles_check(%p)\n", i_in);
662 fflush(stdout);
663 if (i_in) return i_in;
664 Eina_Array *arr = eina_array_new(2);
665 double *v = malloc(sizeof(double));
666 *v = 42.0;
667 eina_array_push(arr, v);
668 v = malloc(sizeof(double));
669 *v = 24.0;
670 eina_array_push(arr, v);
671 return eina_array_iterator_new(arr);
672}
673
674EOLIAN static Eina_Iterator *
675_test_object_method_iterator_of_enums_check(Eo* obj EINA_UNUSED,
676 Test_Object_Data *pd EINA_UNUSED,
677 Eina_Iterator *i_in)
678{
679 fprintf(stdout, "_test_object_method_iterator_of_enums_check(%p)\n", i_in);
680 fflush(stdout);
681 if (i_in) return i_in;
682 Eina_Array *arr = eina_array_new(2);
683 Test_Enum_Ex *v = malloc(sizeof(Test_Enum_Ex));
684 *v = TEST_ENUM_EX_THIRD;
685 eina_array_push(arr, v);
686 v = malloc(sizeof(Test_Enum_Ex));
687 *v = TEST_ENUM_EX_FIRST;
688 eina_array_push(arr, v);
689 return eina_array_iterator_new(arr);
690}
691
692EOLIAN static Eina_Iterator *
693_test_object_method_iterator_of_structs_check(Eo* obj EINA_UNUSED,
694 Test_Object_Data *pd EINA_UNUSED,
695 Eina_Iterator *i_in)
696{
697 fprintf(stdout, "_test_object_method_iterator_of_structs_check(%p)\n", i_in);
698 fflush(stdout);
699 if (i_in) return i_in;
700 Eina_Array *arr = eina_array_new(2);
701 Test_Struct_Ex *v = malloc(sizeof(Test_Struct_Ex));
702 v->value_int = 42;
703 v->value_enum = TEST_ENUM_EX_THIRD;
704 eina_array_push(arr, v);
705 v = malloc(sizeof(Test_Struct_Ex));
706 v->value_int = 24;
707 v->value_enum = TEST_ENUM_EX_FIRST;
708 eina_array_push(arr, v);
709 return eina_array_iterator_new(arr);
710}
711
590// Combinations of complex types 712// Combinations of complex types
591 713
592EOLIAN static Eina_List * 714EOLIAN static Eina_List *
diff --git a/src/tests/eolian_js/test_object.eo b/src/tests/eolian_js/test_object.eo
index 81043fe..4cbfbdc 100644
--- a/src/tests/eolian_js/test_object.eo
+++ b/src/tests/eolian_js/test_object.eo
@@ -251,6 +251,48 @@ class Test.Object (Eo.Base) {
251 } 251 }
252 return: accessor<Test.Struct_Ex> *; 252 return: accessor<Test.Struct_Ex> *;
253 } 253 }
254 method_iterator_of_objects_check {
255 params {
256 @in i_in: iterator<Test.Object *> *;
257 }
258 return: iterator<Test.Object *> *;
259 }
260 method_iterator_of_strings_check {
261 params {
262 @in i_in: iterator<const(char) *> *;
263 }
264 return: iterator<const(char) *> *;
265 }
266 method_iterator_of_ints_check {
267 params {
268 @in i_in: iterator<int> *;
269 }
270 return: iterator<int> *;
271 }
272 method_iterator_of_bools_check {
273 params {
274 @in i_in: iterator<bool> *;
275 }
276 return: iterator<bool> *;
277 }
278 method_iterator_of_doubles_check {
279 params {
280 @in i_in: iterator<double> *;
281 }
282 return: iterator<double> *;
283 }
284 method_iterator_of_enums_check {
285 params {
286 @in i_in: iterator<Test.Enum_Ex> *;
287 }
288 return: iterator<Test.Enum_Ex> *;
289 }
290 method_iterator_of_structs_check {
291 params {
292 @in i_in: iterator<Test.Struct_Ex> *;
293 }
294 return: iterator<Test.Struct_Ex> *;
295 }
254 method_array_of_arrays_of_ints_check { 296 method_array_of_arrays_of_ints_check {
255 params { 297 params {
256 @in a_in: array<array<int> *> *; 298 @in a_in: array<array<int> *> *;