<commit_before>describe("ide.query", function () {

  var orig_codeEditor, orig_map;
  before(function() {
    orig_codeEditor = ide.codeEditor;
    ide.codeEditor = {};
    orig_map = ide.map;
    ide.map = {
      bboxfilter: { isEnabled: function() { return false; } },
      getBounds: function() { return L.latLngBounds([1,2],[3,4]); },
      getCenter: function() { return L.latLng([5,6]); }
    };
  });
  after(function() {
    ide.map = orig_map;
    ide.codeEditor = orig_codeEditor;
  });

  // expand {{parameters}} in ql query
  it("expand {{parameters}} in ql query", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // simple expansion
        inp: '{{parameter=foo}};{{parameter}}',
        outp: ';foo'
      },
      { // simple non-expansion
        inp: '{{parameter1=foo}};{{parameter2}}',
        outp: ';'
      },
      { // multiple expansion
        inp: '{{parameter=foo}};{{parameter}}{{parameter}}',
        outp: ';foofoo'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery(true,false)
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
  // expand {{parameters}} in xml query
  it("expand {{parameters}} in xml", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // simple expansion
        inp: '{{parameter=foo}}<xml>{{parameter}}</xml>',
        outp: '<xml>foo</xml>'
      },
      { // simple non-expansion
        inp: '{{parameter1=foo}}<xml>{{parameter2}}</xml>',
        outp: '<xml></xml>'
      },
      { // multiple expansion
        inp: '{{parameter=foo}}<xml>{{parameter}}{{parameter}}</xml>',
        outp: '<xml>foofoo</xml>'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery(true,false)
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
  // expand {{bbox}}
  it("expand {{bbox}}", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // ql query
        inp: '({{bbox}})',
        outp: '(1,2,3,4)'
      },
      { // xml query
        inp: '<bbox-query {{bbox}}/>',
        outp: '<bbox-query s="1" w="2" n="3" e="4"/>'
      },
      { // xml query global bbox
        inp: '<osm-script bbox="{{bbox}}"/>',
        outp: '<osm-script bbox="1,2,3,4"/>'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery(true,false)
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
  // expand {{center}}
  it("expand {{center}}", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // ql query
        inp: '({{center}})',
        outp: '(5,6)'
      },
      { // xml query
        inp: '<around {{center}}/>',
        outp: '<around lat="5" lon="6"/>'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery(true,false)
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
<commit_msg>update tests<commit_after>describe("ide.query", function () {

  var orig_codeEditor, orig_map;
  before(function() {
    orig_codeEditor = ide.codeEditor;
    ide.codeEditor = {};
    orig_map = ide.map;
    ide.map = {
      bboxfilter: { isEnabled: function() { return false; } },
      getBounds: function() { return L.latLngBounds([1,2],[3,4]); },
      getCenter: function() { return L.latLng([5,6]); }
    };
  });
  after(function() {
    ide.map = orig_map;
    ide.codeEditor = orig_codeEditor;
  });

  // expand {{parameters}} in ql query
  it("expand {{parameters}} in ql query", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // simple expansion
        inp: '{{parameter=foo}};{{parameter}}',
        outp: ';foo'
      },
      { // simple non-expansion
        inp: '{{parameter1=foo}};{{parameter2}}',
        outp: ';'
      },
      { // multiple expansion
        inp: '{{parameter=foo}};{{parameter}}{{parameter}}',
        outp: ';foofoo'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery()
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
  // expand {{parameters}} in xml query
  it("expand {{parameters}} in xml", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // simple expansion
        inp: '{{parameter=foo}}<xml>{{parameter}}</xml>',
        outp: '<xml>foo</xml>'
      },
      { // simple non-expansion
        inp: '{{parameter1=foo}}<xml>{{parameter2}}</xml>',
        outp: '<xml></xml>'
      },
      { // multiple expansion
        inp: '{{parameter=foo}}<xml>{{parameter}}{{parameter}}</xml>',
        outp: '<xml>foofoo</xml>'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery()
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
  // expand {{bbox}}
  it("expand {{bbox}}", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // ql query
        inp: '({{bbox}})',
        outp: '(1,2,3,4)'
      },
      { // xml query
        inp: '<bbox-query {{bbox}}/>',
        outp: '<bbox-query s="1" w="2" n="3" e="4"/>'
      },
      { // xml query global bbox
        inp: '<osm-script bbox="{{bbox}}"/>',
        outp: '<osm-script bbox="1,2,3,4"/>'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery()
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });
  // expand {{center}}
  it("expand {{center}}", function () {
    sinon.stub(ide,"setQuery");
    var examples = [
      { // ql query
        inp: '({{center}})',
        outp: '(5,6)'
      },
      { // xml query
        inp: '<around {{center}}/>',
        outp: '<around lat="5" lon="6"/>'
      },
    ];
    for (var i=0; i<examples.length; i++) {
      ide.codeEditor.getValue = function() {return examples[i].inp };
      expect(
        ide.getQuery()
      ).to.be.eql(
        examples[i].outp
      );
    }
    ide.setQuery.restore();
  });

{'fraction_non_alphanumeric': 0.2080385368056601, 'fraction_numerical': 0.009032063826584374, 'mean_word_length': 2.125117591721543, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 34}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6676674', 'n_tokens_mistral': 2314, 'n_tokens_neox': 2303, 'n_words': 413}