From 99c44c11d427fa85b7069ec644a640c1880bfab6 Mon Sep 17 00:00:00 2001 From: Thomas Nilefalk Date: Mon, 10 Jun 2024 15:43:44 +0200 Subject: [PATCH] [tests] Add a non-server-driver version of get_project test --- tests/test_get_project_new/.gitignore | 8 +++ tests/test_get_project_new/Makefile | 19 +++++++ tests/test_get_project_new/browsing.c | 81 +++++++++++++++++++++++++++ tests/test_get_project_new/expected | 7 +++ tests/test_get_project_new/index.c | 40 +++++++++++++ tests/test_get_project_new/source.c | 5 ++ 6 files changed, 160 insertions(+) create mode 100644 tests/test_get_project_new/.gitignore create mode 100644 tests/test_get_project_new/Makefile create mode 100644 tests/test_get_project_new/browsing.c create mode 100644 tests/test_get_project_new/expected create mode 100644 tests/test_get_project_new/index.c create mode 100644 tests/test_get_project_new/source.c diff --git a/tests/test_get_project_new/.gitignore b/tests/test_get_project_new/.gitignore new file mode 100644 index 000000000..d8bb594da --- /dev/null +++ b/tests/test_get_project_new/.gitignore @@ -0,0 +1,8 @@ +CXrefs +.c-xrefrc +*buffer +*.output +output +output.tmp +log +*.log diff --git a/tests/test_get_project_new/Makefile b/tests/test_get_project_new/Makefile new file mode 100644 index 000000000..78e24ac3f --- /dev/null +++ b/tests/test_get_project_new/Makefile @@ -0,0 +1,19 @@ +include ../Makefile.boilerplate + + +ARGUMENTS = -xrefactory-II -olcxgetprojectname $(CURDIR)/index.c + +$(TEST): CXrefs + $(COMMAND) > output.tmp + $(NORMALIZE) output.tmp | grep -v -w progress > output + $(VERIFY) + +trace debug: EXTRA+=--extra="-trace -log=log" +trace: $(TEST) + +CXrefs: .c-xrefrc + echo CXREF + $(CXREF) -create + +clean: + rm -rf CXrefs output* .c-xrefrc diff --git a/tests/test_get_project_new/browsing.c b/tests/test_get_project_new/browsing.c new file mode 100644 index 000000000..caa8817ff --- /dev/null +++ b/tests/test_get_project_new/browsing.c @@ -0,0 +1,81 @@ +#include + +/* + Follow instructions in commentaries to check C-Xrefactory source + browser. +*/ + + +void browsing() { + struct ilist {int i; struct ilist *next;} *il; + struct dlist {double d; struct dlist *next;} *dl; + + int i,j,k; + + // put cursor somewhere on 'i' variable and press F6. Then using + // F3 and F4 inspect all its references. Finally pop references by + // pressing F5. + for(i=0; i<10; i++) printf("i == %d\n", i ); + + // put cursor on following usages of 'i' and 'j' and check scope + // resolution by pressing F6 followed by F5. + { int i; + i = i + 1; + j = j + 1; + } + + // structure records can be browsed as well, browse 'next' or 'i' + // records for example. + il = il-> next ; + + il-> i = 0; + + // list all usages of this 'i' by pressing C-F6 (control F6); + // Note: not all environments support inputting "control F6" + i = 0; + /* + 'F3' and 'F4' inspect previous-next reference. + in created (right) window: + 'mouse-button12' goes to selected reference. + 'mouse-button3' pops up menu. + always: + 'F7' closes C-Xrefactory window. + */ + + + // browse 'next' symbol from following line to check resolution + // inside used macros +#define LISTLEN(ll,res) {res=0; for(; ll!=NULL; ll=ll-> next ) res++;} + + LISTLEN(dl, k); + + // ambiguity handling: put cursor on 'next' symbol and list all + // its usages with C-F6 +#define LISTLOOP(ll,ii) for(ll=ii; ll!=NULL; ll=ll-> next ) + /* + In the created (left) window: + - select one symbol + o - toggle to other browser window + also: + 'mouse-button12' select/unselect symbol. + 'mouse-button3' pops up menu. + + As usually 'F7' closes new windows. + */ + + LISTLOOP(il, NULL) {} + LISTLOOP(dl, NULL) {} + + +} + +// put cursor on the 'include' keyword and move to the included file +// by pressing F6, then return back using F5. + +#include + +/* + Presentation of C-Xrefactory browser is over, F7 will close + C-Xrefactory window and (probably multiple) F5 will bring you back + to index. +*/ diff --git a/tests/test_get_project_new/expected b/tests/test_get_project_new/expected new file mode 100644 index 000000000..2b6343ccb --- /dev/null +++ b/tests/test_get_project_new/expected @@ -0,0 +1,7 @@ +>Prescanning classes, please wait. +>C-xrefactory project: CURDIR +>CURDIR/browsing.c +>CURDIR/index.c +>CURDIR/source.c +>Generating 'CURDIR/CXrefs' + diff --git a/tests/test_get_project_new/index.c b/tests/test_get_project_new/index.c new file mode 100644 index 000000000..e19592df6 --- /dev/null +++ b/tests/test_get_project_new/index.c @@ -0,0 +1,40 @@ +/* + + Welcome to the C-Xrefactory exercise project! + + 1.) The basic hot-keys you need to know are: F6 which brings you to + the definition of a symbol, and F5 which brings you back. + + 2.) With this knowledges you can browse demonstration files. Put + cursor on a function name, say 'completions', and press F6 to go to + completion's examples. + + At the first invocation C-Xrefactory will ask you for creation of a + new project. You should answer 'yes' (create new project). + C-xrefactory will then ask a few questions, if you do not know + the answer, press to select default value. + +*/ + + +void completions(); +void browsing(); +void ideCompileAndRun(); + + +// refactorings +void addRemoveParameter(); +void extractFunction(); +void renameSymbol(); + + + + + +/* + Under Emacs/XEmacs, you can get help on any of C-Xrefactory + functions by typing 'C-h k' key combination (i.e. 'control' + together with 'h' key, followed by 'k' key) and select the function + from 'C-xref' menu with mouse. + +*/ diff --git a/tests/test_get_project_new/source.c b/tests/test_get_project_new/source.c new file mode 100644 index 000000000..83f76247e --- /dev/null +++ b/tests/test_get_project_new/source.c @@ -0,0 +1,5 @@ +int single_int_on_line_1_col_4; +int single_int_on_line_2_col_5; + +single_int_on_line_1_col_4 = 3; + single_int_on_line_2_col_5 = 5;