julissammateo / js-test-driver

Automatically exported from code.google.com/p/js-test-driver
0 stars 0 forks source link

Coverage inserting LCOV causes a syntax error #426

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Please see the complete files bellow (sorry for long data, but I think it 
can be useful)

What is the expected output? What do you see instead?
I should not be getting this:

(...)
--tests all --verbose
line 239:9 mismatched input 'float' expecting Identifier
line 239:49 missing RPAREN at ';'
line 240:62 no viable alternative at input 'float'
line 246:5 mismatched input ')' expecting RBRACE
line 251:21 no viable alternative at input ':'
line 251:30 missing Identifier at '('
(...)
Chrome 25.0.1364.97 Windows: Run 70 tests (Passed: 69; Fails: 0; Errors 1) 
(130.00 ms)
    error loading file: /test/src/main/webapp/js/libs/filters/MetricRangeSlider.js:251: Uncaught SyntaxError: Unexpected token ;
  Firefox 12.0 Windows: Run 70 tests (Passed: 69; Fails: 0; Errors 1) (276.00 ms)
    error loading file: /test/src/main/webapp/js/libs/filters/MetricRangeSlider.js:251: missing } after property list
Tests failed: Tests failed. See log for details.
(...)

What version of the product are you using? On what operating system?
coverage 1.3.2 and coverage 1.3.5

Please provide any additional information below.
The problem is in line:

updateDefaultPanel:LCOV_18h[251]++; function() {

as you can see, LCOV_18h[251]++; is placed on the wrong place. I suppose it 
should be:
updateDefaultPanel: function() {
LCOV_18h[251]++;

The following lines are a small context of the problem line:

var view = {
            globalRangeMinValueLabel:null,
            globalRangeMaxValueLabel:null,
            slidersBlock: null,
            sliders: [],
            rows: [],
            createSlidersBlock: function() {
                view.slidersBlock = $('<div class="metricRangeSlider_slidersBlock"></div>');
                defaultPanel.append(view.slidersBlock);
            },
            switchToEditPanel: function() {
                modelForEdition = $.extend(true, {}, model);
                editPanel.find(".ui-state-error").removeClass("ui-state-error");
                view.editPanel.updateValues();
                defaultPanel.hide();
                editPanel.show();
            },
            switchToDefaultPanel: function() {              
                if(changesInEditPanel) {
                    $.extend(true, model, modelForEdition);
                    modelForEdition = {};

                    adjustRangesFromGlobalRange();
                    view.updateDefaultPanel();
                    view.updateDefaultPanel();

                    view.editPanel.setDataChangesDiscardedState();

                    myObj.onSelectionChange({cql: myObj.getCql(), sld: myObj.getSld()});
                }

                editPanel.hide();
                defaultPanel.show();
            },
            createEditButton: function() {
                if(config.allowEdit) {
                    defaultPanel.append(
                        $('<div class="metricRangeSlider_buttonContainer"></div>').append($('<button></button>').button(
                                {
                                    icons: {primary: "ui-icon-wrench"},
                                    text: false
                                }).click(function() {
                                    view.switchToEditPanel();
                                }).on("mouseover", function() {
                                    topLayoutElement.addClass("metricRangeSlider_defaultPanel_over");
                                }).on("mouseout", function() {
                                    topLayoutElement.removeClass("metricRangeSlider_defaultPanel_over");
                                })
                        ));
                }
            },
            createGlobalRangeBar: function() {
                view.globalRangeMinValueLabel = $('<span class="metricRengeslider_globalRangeMinValueLabel"></span>');
                view.globalRangeMaxValueLabel = $('<span class="metricRengeslider_globalRangeMaxValueLabel"></span>');
                defaultPanel.append($('<div class="metricRangeslider_globalRangeBar"></div>').append(view.globalRangeMinValueLabel).append(view.globalRangeMaxValueLabel));
            },
            createSliders: function() {
                var arrayLength = model.ranges.length;
                for ( var i = 0; i < arrayLength; i++) {
                    view.sliders[i] = view.createSlider(i);
                    view.slidersBlock.append(view.sliders[i]);
                }
            },
            updateSlider: function(sliderIndex) {
                if(view.sliders[sliderIndex] !== undefined) {                   
                    $(view.sliders[sliderIndex].children()[0]).slider("values", 0, model.ranges[sliderIndex].min);
                    $(view.sliders[sliderIndex].children()[0]).slider("values", 1, model.ranges[sliderIndex].max);

                    $(view.sliders[sliderIndex].children()[0]).find("span").each(function(index, value) {
                        var label = (index === 0) ? model.ranges[sliderIndex].min : model.ranges[sliderIndex].max;
                        $(this).html(label);
                    });

                    $(view.sliders[sliderIndex].children()[0]).slider("option", "min", model.globalRange.min);
                    $(view.sliders[sliderIndex].children()[0]).slider("option", "max", model.globalRange.max);
                }
                else {
                    view.sliders[sliderIndex] = view.createSlider(sliderIndex);
                    view.slidersBlock.append(view.sliders[sliderIndex]);
                }
            },
            createSlider: function(rangeIndex) {
                var sliderDiv = $("<div></div>");

                sliderDiv.slider({
                    range: true,
                    min: model.globalRange.min,
                    max: model.globalRange.max,
                    values: [model.ranges[rangeIndex].min, model.ranges[rangeIndex].max],
                    slide: function(event, ui) {
                        $(ui.handle).find("span").html(ui.value).show();
                        model.ranges[rangeIndex].min = ui.values[0];
                        model.ranges[rangeIndex].max = ui.values[1];
                    },
                    stop: function(event, ui) {
                        $(this).find("span").hide();
                        console.log("metricRangeSlider filter stoped sliding... ", "cql: ",  myObj.getCql(), " sld: ", myObj.getSld());
                        myObj.onSelectionChange({cql: myObj.getCql(), sld: myObj.getSld()});
                    }
                });

                sliderDiv.find("a").each(function(index, value) {
                    var label = (index === 0) ? model.ranges[rangeIndex].min : model.ranges[rangeIndex].max;
                    var float = (index === 0) ? "left" : "right";
                    $(this).append($('<span style="display: none; float: ' + float + '; padding: 2px; top: -22px; border: 1px solid #AAAAAA; position: relative; background-color: #EEEEEE">'+label+'</span>)'));
                    $(this).on("mouseover", function() {
                        $(this).find("span").show();
                    }).on("mouseout", function() {
                        $(this).find("span").hide();
                    });
                });

                return $('<div class="metricRangeSlider_sliderContainer"></div>').append(sliderDiv);
            },
            updateDefaultPanel:function() {
                // limites globais
                view.globalRangeMinValueLabel.html(model.globalRange.min);
                view.globalRangeMaxValueLabel.html(model.globalRange.max);

                // intervalos
                var arrayLength = model.ranges.length;
                for ( var i = 0; i < arrayLength; i++) {
                    // slider
                    view.updateSlider(i);

                    // seleção
                    $(view.rows[i].children()[0]).attr("checked", model.ranges[i].selected);

                    // cor
                    $($(view.rows[i].children()[1])).find("div").attr("style", "background-color: " + model.ranges[i].color);
                }
            },
            createRow: function() {
                var row = $('<div class="metricRangeSlider_defaultPanelRow"></div>');
                row.append($('<div class="metricRangeSlider_defaultPanelCol0"></div>'));
                row.append($('<div class="metricRangeSlider_defaultPanelCol0"></div>'));
                row.append($('<div class="metricRangeSlider_defaultPanelCol1"></div>'));

                return row;
            },
            assignRangeSelectionBehaviour: function(rangeIndex, input) {
                input.click(function() {
                    if($(this).attr("checked")) {
                        model.ranges[rangeIndex].selected = true;
                    }
                    else {
                        model.ranges[rangeIndex].selected = false;
                    };

                    console.log("range selection behaviour: ", " cql: ", myObj.getCql(), " sld: ", myObj.getSld());
                    myObj.onSelectionChange({cql: myObj.getCql(), sld: myObj.getSld()});
                });
            },
            createRangesRows: function() {
                var arrayLength = model.ranges.length;
                for ( var i = 0; i < arrayLength; i++) {
                    view.rows[i] = view.createRow();
                    view.slidersBlock.append(view.rows[i]);

                    var input = $('<input type="checkbox"></input>');
                    view.assignRangeSelectionBehaviour(i, input);
                    $(view.rows[i].children()[0]).append(input);

                    if(model.ranges[i].selected === true) {
                        $($(view.rows[i].children()[0]).children()[0]).attr("checked", true);
                    }

                    $(view.rows[i].children()[1]).append($('<div class="metricRangeSlider_rangeColor" style="background-color: '+ model.ranges[i].color +'"></div>'));

                    view.sliders[i] = view.createSlider(i);

                    $(view.rows[i].children()[2]).append($(view.sliders[i]));
                }
            },
            editPanel: {
                rangeLimitsValidarionRule: {test: function(n) {
                    return !isNaN(parseFloat(n)) && isFinite(n);
                }},
                globalRangesFields: {min: null, max: null},
                rangesFields:[],
                confirmButton: null,
                cancelButton: null,
                uiMessageContainer: null,
                setDataChangedState: function() {
                    changesInEditPanel = true;
                    view.editPanel.confirmButton.button("option", "disabled", false);
                },
                setDataChangesDiscardedState: function() {
                    changesInEditPanel = false;
                    view.editPanel.confirmButton.button("option", "disabled", true);
                },
                updateValues: function() {
                    view.editPanel.globalRangesFields.min.val(model.globalRange.min);
                    view.editPanel.globalRangesFields.max.val(model.globalRange.max);

                    var arrayLength = model.ranges.length;
                    for ( var i = 0; i < arrayLength; i++) {
                        view.editPanel.rangesFields[i].min.val(model.ranges[i].min);
                        view.editPanel.rangesFields[i].max.val(model.ranges[i].max);
                        view.editPanel.rangesFields[i].label.val(model.ranges[i].label);

                        var minInclusionLabel = (model.ranges[i].inclusion[0]) ? "&#8804;" : "&#60;";
                        view.editPanel.rangesFields[i].minInclusion.find("span").html(minInclusionLabel);

                        var maxInclusionLabel = (model.ranges[i].inclusion[1]) ? "&#8804;" : "&#60;";
                        view.editPanel.rangesFields[i].maxInclusion.find("span").html(maxInclusionLabel);

                        $(view.editPanel.rangesFields[i].rangeColor).minicolors("value", model.ranges[i].color);
                    }
                },
                createLayoutRow: function() {
                    var row = $('<div class="metricRangeSlider_layoutRow"></div>')
                    .append($('<div class="metricRangeSlider_collSize0 metricRangeSlider_alignCenter"></div>')).
                    append($('<div class="metricRangeSlider_collSize1 metricRangeSlider_alignRight"></div>')).
                    append($('<div class="metricRangeSlider_collSize0 metricRangeSlider_alignCenter"></div>')).
                    append($('<div class="metricRangeSlider_collSize2 metricRangeSlider_alignCenter"></div>')).
                    append($('<div class="metricRangeSlider_collSize0 metricRangeSlider_alignCenter"></div>')).
                    append($('<div class="metricRangeSlider_collSize1 metricRangeSlider_alignRight"></div>'));

                    return row;
                },
                createEditPanelButtonBar: function() {
                    var buttonBar = $('<div class="metricRangeSlider_editPanelButtonBar"></div>');
                    view.editPanel.cancelButton = $('<button>'+i18nInstance.getMessage('ossgis.product.metricRangeSlider.editPanel.buttons.label.cancel')+'</button>').button().click(function() {
                        view.editPanel.setDataChangesDiscardedState();
                        view.switchToDefaultPanel();
                    });
                    buttonBar.append(view.editPanel.cancelButton);

                    view.editPanel.confirmButton = $('<button>'+i18nInstance.getMessage('ossgis.product.metricRangeSlider.editPanel.buttons.label.confirm')+'</button>').button({disabled: true}).click(function() {
                        view.switchToDefaultPanel();
                    });
                    buttonBar.append(view.editPanel.confirmButton);

                    editPanel.append(buttonBar);
                },
                createUiMessageContainer: function() {
                    view.editPanel.uiMessageContainer = $('<div class="metricRangeSlider_uiMessageContainer"></div>');

                    editPanel.append(view.editPanel.uiMessageContainer);
                },
                showMessage: function(stringMessage, stringType) {
                    view.editPanel.uiMessageContainer.html("");

                    view.editPanel.uiMessageContainer.html(stringMessage);

                    view.editPanel.uiMessageContainer.show();
                },
                addHorizontalRule: function() {
                    var row = $('<div class="metricRangeSlider_layoutSpacer"></div>');

                    editPanel.append(row);
                },
                createGlobalRangeFields: function() {
                    var row = view.editPanel.createLayoutRow();

                    view.editPanel.globalRangesFields.min = $('<input class="ui-widget ui-state-default ui-corner-all metricRangeSlider_alignRight" value='+model.globalRange.min+'></input>');
                    $(row.children()[1]).append($('<div style="text-align: left;">Min:</div>')).append(view.editPanel.globalRangesFields.min);

                    view.editPanel.globalRangesFields.max = $('<input class="ui-widget ui-state-default ui-corner-all metricRangeSlider_alignLeft" value='+model.globalRange.max+'></input>');
                    $(row.children()[5]).append($('<div">Max:</div>')).append(view.editPanel.globalRangesFields.max);

                    view.editPanel.assignGlobalFieldsBehaviour();

                    editPanel.append(row);                  
                },
                validatePanel: function() {
                    var globalRangesValid = true;
                    var rangesValid = true;
                    var overlapingRangesValid = true;

                    if(modelForEdition.globalRange.minValidated === false || modelForEdition.globalRange.maxValidated === false) {
                        globalRangesValid = false;

                        // por favor corrija os campos de limite do intervalo global assinalados. Apenas números são aceites
                    }

                    var arrayLength = modelForEdition.ranges.length;
                    for ( var i = 0; i < arrayLength; i++) {
                        if(modelForEdition.ranges[i].minValidated === false || modelForEdition.ranges[i].maxValidated === false) {
                            rangesValid = false;

                            // por favor corrija o vaores inseridos nos limites assinalados. Apenas números são aceites.
                        }
                    }

                    if(globalRangesValid && rangesValid) {
                        view.editPanel.setDataChangedState();
                    }
                    else {
                        view.editPanel.setDataChangesDiscardedState();
                    }

                    return (globalRangesValid && rangesValid);
                },
                assignRangeFiledsBehaviour: function(rangeFieldsObj, index) {                   
                    rangeFieldsObj.min.on("keyup", function() {

                        if(view.editPanel.rangeLimitsValidarionRule.test($(this).val())) {
                            modelForEdition.ranges[index].min = parseFloat($(this).val());
                            modelForEdition.ranges[index].minValidated = true;
                            $(this).removeClass("ui-state-error");

                            console.log(modelForEdition);
                        }
                        else {
                            modelForEdition.ranges[index].minValidated = false;
                            $(this).addClass("ui-state-error");
                        }

                        view.editPanel.validatePanel();

                    });

                    rangeFieldsObj.max.on("keyup", function() {

                        if(view.editPanel.rangeLimitsValidarionRule.test($(this).val())) {
                            modelForEdition.ranges[index].max = parseFloat($(this).val());
                            modelForEdition.ranges[index].maxValidated = true;
                            $(this).removeClass("ui-state-error");
                        }
                        else {
                            modelForEdition.ranges[index].maxValidated = false;
                            $(this).addClass("ui-state-error");
                        }

                        view.editPanel.validatePanel();

                    });
                },
                assignGlobalFieldsBehaviour: function() {
                    view.editPanel.globalRangesFields.min.on("keyup", function() {                          
                        if(view.editPanel.rangeLimitsValidarionRule.test($(this).val())) {
                            modelForEdition.globalRange.min = parseFloat($(this).val());
                            modelForEdition.globalRange.minValidated = true;
                            $(this).removeClass("ui-state-error");
                        }
                        else {
                            modelForEdition.globalRange.minValidated = false;
                            $(this).addClass("ui-state-error");
                        }

                        view.editPanel.validatePanel();
                    });

                    view.editPanel.globalRangesFields.max.on("keyup", function() {                                                  
                        if(view.editPanel.rangeLimitsValidarionRule.test($(this).val())) {
                            modelForEdition.globalRange.max = parseFloat($(this).val());
                            modelForEdition.globalRange.maxValidated = true;
                            $(this).removeClass("ui-state-error");
                        }
                        else {
                            modelForEdition.globalRange.maxValidated = false;
                            $(this).addClass("ui-state-error");
                        }

                        view.editPanel.validatePanel();

                    });
                },
                assignRangeInclusionBehaviour: function(rowFieldsObj, rangeIndex) {
                    rowFieldsObj.minInclusion.click(function() {
                        view.editPanel.setDataChangedState();

                        switch (modelForEdition.ranges[rangeIndex].inclusion[0]) {
                        case true:
                            this.childNodes[0].innerHTML = "&#60;";
                            modelForEdition.ranges[rangeIndex].inclusion[0] = false;
                            break;

                        default:
                            this.childNodes[0].innerHTML = "&#8804;";
                            modelForEdition.ranges[rangeIndex].inclusion[0] = true;
                            break;
                        }

                    });

                    rowFieldsObj.maxInclusion.click(function() {
                        view.editPanel.setDataChangedState();

                        switch (modelForEdition.ranges[rangeIndex].inclusion[1]) {
                        case true:
                            this.childNodes[0].innerHTML = "&#60;";
                            modelForEdition.ranges[rangeIndex].inclusion[1] = false;
                            break;

                        default:
                            this.childNodes[0].innerHTML = "&#8804;";
                            modelForEdition.ranges[rangeIndex].inclusion[1] = true;
                            break;
                        }
                    });

                    switch (model.ranges[rangeIndex].inclusion[0]) {
                    case true:
                        rowFieldsObj.minInclusion.children()[0].innerHTML = "&#8804;";
                        break;

                    default:
                        rowFieldsObj.minInclusion.children()[0].innerHTML = "&#60;";
                    break;
                    }

                    switch (model.ranges[rangeIndex].inclusion[1]) {
                    case true:
                        rowFieldsObj.maxInclusion.children()[0].innerHTML = "&#8804;";
                        break;

                    default:
                        rowFieldsObj.maxInclusion.children()[0].innerHTML = "&#60;";
                    break;
                    }
                },
                assignColorPickerBehaviour: function(rangeIndex, colorPickerContainer) {
                    $(colorPickerContainer).minicolors({
                        animationSpeed: 100,
                        animationEasing: 'swing',
                        change: function(hex, opacity) {
                            modelForEdition.ranges[rangeIndex].color = hex;
                            view.editPanel.setDataChangedState();
                        },
                        changeDelay: 0,
                        control: 'hue',
                        defaultValue: '',
                        hide: null,
                        hideSpeed: 100,
                        inline: false,
                        letterCase: 'lowercase',
                        opacity: false,
                        position: 'default',
                        show: null,
                        showSpeed: 100,
                        swatchPosition: 'left',
                        textfield: false,
                        theme: 'default'
                    });

                    $(colorPickerContainer).minicolors("value", model.ranges[rangeIndex].color);
                },
                assignLabelInputBehaviour: function(rowFieds, i) {
                    rowFieds.label.on("keyup", function() {
                        if($(this).val() !== modelForEdition.ranges[i].label) {
                            modelForEdition.ranges[i].label =  $(this).val();
                            view.editPanel.setDataChangedState();
                        }
                    });
                },
                createRangesBars: function() {
                    var arrayLength = model.ranges.length;
                    for ( var i = 0; i < arrayLength; i++) {
                        var rowFields = {
                                min: $('<input class="ui-widget ui-state-default ui-corner-all metricRangeSlider_alignRight" value="'+ model.ranges[i].min+'"></input>'),
                                max: $('<input class="ui-widget ui-state-default ui-corner-all metricRangeSlider_alignLeft" value="'+ model.ranges[i].max+'"></input>'), 
                                label: $('<input class="ui-widget ui-state-default ui-corner-all metricRangeSlider_alignCenter" value="'+ model.ranges[i].label+'"></input>'), 
                                minInclusion: $('<button><</button>').button(), 
                                maxInclusion: $('<button><</button>').button(),
                                rangeColor: $('<div id="colorPicker" style="width: 20px; height: 20px"></div>')
                        };

                        rowFields.minInclusion.attr("style", "margin-left: 3px;").find("span").attr("style", "padding: 0px");
                        rowFields.maxInclusion.attr("style", "margin-left: 3px;").find("span").attr("style", "padding: 0px");

                        view.editPanel.assignRangeInclusionBehaviour(rowFields, i);
                        view.editPanel.assignRangeFiledsBehaviour(rowFields, i);
                        view.editPanel.assignLabelInputBehaviour(rowFields, i);

                        view.editPanel.rangesFields.push(rowFields);

                        var row = view.editPanel.createLayoutRow();

                        $(row.children()[0]).append(rowFields.rangeColor);

                        view.editPanel.assignColorPickerBehaviour(i, rowFields.rangeColor);

                        $(row.children()[1]).append(rowFields.min);

                        $(row.children()[2]).append(rowFields.minInclusion);

                        $(row.children()[3]).append(rowFields.label);

                        $(row.children()[4]).append(rowFields.maxInclusion);

                        $(row.children()[5]).append(rowFields.max);

                        editPanel.append(row);
                    }
                }
            },
            createEditPanel: function() {
                view.editPanel.createEditPanelButtonBar();
                view.editPanel.createGlobalRangeFields();
                view.editPanel.addHorizontalRule();
                view.editPanel.createRangesBars();
                view.editPanel.createUiMessageContainer();
            },
            createDefaultPanel: function() {
                view.createEditButton();
                view.createGlobalRangeBar();
                view.createSlidersBlock(); // cria o contentor para sliders embora inclua os rows
                view.createRangesRows();

                view.updateDefaultPanel();
            }
    };

Original issue reported on code.google.com by mail.rol...@gmail.com on 8 Mar 2013 at 12:55

GoogleCodeExporter commented 8 years ago
Problem solved. I was using a reserved word - float:

var float = (index === 0) ? "left" : "right";

Original comment by mail.rol...@gmail.com on 18 Mar 2013 at 12:29