From d1ed4d4845de7fe1c2c47ce3de332b62646ce11d Mon Sep 17 00:00:00 2001 From: giulianobelinassi Date: Fri, 12 May 2017 11:43:04 -0300 Subject: [PATCH] Outputing the function counter to XML. Now, globalFunctions tag appears in the header of the xml output file. --- lib/kuniri/parser/output_format.rb | 5 +++++ lib/kuniri/parser/xml_output_format.rb | 5 +++++ spec/parser/xmlSchemaValidate/class_data.xsd | 9 +++++++++ spec/parser/xmlSchemaValidate/fullCodeTwo.xsd | 11 ++++++++++- .../parser/xmlSchemaValidate/fullCodeWithComments.xsd | 11 ++++++++++- spec/parser/xmlSchemaValidate/simpleFunction.xsd | 9 +++++++++ spec/parser/xml_builder_engine_spec.rb | 2 ++ spec/parser/xml_output_format_spec.rb | 4 ++++ tests/cli_test.sh | 1 + 9 files changed, 55 insertions(+), 2 deletions(-) diff --git a/lib/kuniri/parser/output_format.rb b/lib/kuniri/parser/output_format.rb index 3697618..6f68495 100644 --- a/lib/kuniri/parser/output_format.rb +++ b/lib/kuniri/parser/output_format.rb @@ -81,6 +81,7 @@ def handle_cond_loop_and_block(singleElement) def handle_global_functions(singleElement) funcs = singleElement.global_functions len = funcs.length + function_counter_generate(len) generate_global_functions(funcs) if len.positive? end @@ -117,6 +118,10 @@ def function_behaviour_generate(_pElementName, _pFunction) raise NotImplementedError end + def function_counter_generate(_pCounterLabel, _numberOfFunctons) + raise NotImplementedError + end + def global_variable_generate(_pGlobalVariable) raise NotImplementedError end diff --git a/lib/kuniri/parser/xml_output_format.rb b/lib/kuniri/parser/xml_output_format.rb index 4c69e6d..b782369 100644 --- a/lib/kuniri/parser/xml_output_format.rb +++ b/lib/kuniri/parser/xml_output_format.rb @@ -61,6 +61,11 @@ def function_behaviour_generate(pElementName, pFunction) end end + def function_counter_generate(pNumberOfFunctions) + @outputEngine.send('globalFunctions', + counter: pNumberOfFunctions) + end + # @see OutputFormat def parameters_generate(pParameters) if pParameters.is_a?Hash diff --git a/spec/parser/xmlSchemaValidate/class_data.xsd b/spec/parser/xmlSchemaValidate/class_data.xsd index d2dd049..b73a354 100644 --- a/spec/parser/xmlSchemaValidate/class_data.xsd +++ b/spec/parser/xmlSchemaValidate/class_data.xsd @@ -2,6 +2,15 @@ + + + + + + + + + diff --git a/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd b/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd index b9a0c2c..c9b5c7c 100644 --- a/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +++ b/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd @@ -6,7 +6,16 @@ - + + + + + + + + + + diff --git a/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd b/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd index 4d8914c..92217de 100644 --- a/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +++ b/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd @@ -6,7 +6,16 @@ - + + + + + + + + + + diff --git a/spec/parser/xmlSchemaValidate/simpleFunction.xsd b/spec/parser/xmlSchemaValidate/simpleFunction.xsd index b1dc8f8..d75315b 100644 --- a/spec/parser/xmlSchemaValidate/simpleFunction.xsd +++ b/spec/parser/xmlSchemaValidate/simpleFunction.xsd @@ -2,6 +2,15 @@ + + + + + + + + + diff --git a/spec/parser/xml_builder_engine_spec.rb b/spec/parser/xml_builder_engine_spec.rb index bd80c3f..683ab19 100644 --- a/spec/parser/xml_builder_engine_spec.rb +++ b/spec/parser/xml_builder_engine_spec.rb @@ -214,6 +214,7 @@ it "Full global function" do @builder.kuniri do + globalFunctions :counter => "1" functionData :name => "xpto", :visibility => "global" do parameterData :name => "two" conditionalData :type => "if", :expression => "y == x" @@ -223,6 +224,7 @@ output = [@basicHeader, '', + ' ', ' ', ' ', ' ', diff --git a/spec/parser/xml_output_format_spec.rb b/spec/parser/xml_output_format_spec.rb index 3920b98..2e62ef4 100644 --- a/spec/parser/xml_output_format_spec.rb +++ b/spec/parser/xml_output_format_spec.rb @@ -310,6 +310,10 @@ expect(@handler.elements[4].attributes['name']).to eq('globalVariable') end + it 'Verify if the global function counter is correct' do + expect(@handler.elements[8].attributes['counter']).to eq('0') + end + #TODO: FINISH THIS TEST, AFTER FIX THE GLOBAL VARIABLE BUG after :each do diff --git a/tests/cli_test.sh b/tests/cli_test.sh index 05cfe4c..53f06de 100644 --- a/tests/cli_test.sh +++ b/tests/cli_test.sh @@ -24,6 +24,7 @@ create_test_file() { cat <expected_result.xml +