<commit_before>/**
 * Created with JetBrains PhpStorm.
 * User: francis
 * Date: 9/25/13
 * Time: 1:21 PM
 */


$(document).ready(function () {

  module("Queries");

  var obj = {
    firstName: "Francis",
    lastName: "Asante",
    username: "kofrasa",
    title: "Software Engineer",
    degree: "Computer Science",
    jobs: 6,
    date: {
      year: 2013,
      month: 9,
      day: 25
    },
    languages: {
      spoken: ["english"],
      programming: ["C", "Python", "Scala", "Java", "Javascript", "Bash", "C#"]
    },
    circles: {
      school: ["Kobby", "Henry", "Kanba", "Nana", "Albert", "Yayra", "Linda", "Sophia"],
      work: ["Kobby", "KT", "Evans", "Robert", "Ehi", "Ebo", "KO"],
      family: ["Richard", "Roseline", "Michael", "Rachel"]
    },
    projects: {
      "C": ["word_grid", "student_record", "calendar"],
      "Java": ["Easy Programming Language", "SurveyMobile"],
      "Python": ["Kasade", "Code Jam", "Flaskapp", "FlaskUtils"],
      "Scala": [],
      "Javascript": ["mingo", "Backapp", "BackboneApp", "Google Election Maps"]
    }
  };

  test("simple comparisons tests", function () {
    var queries = [
      [{firstName: "Francis"}, "can check for equality"],,
      [{lastName: /^a.+e/i}, "can check against regex"],
      [{username: {$not: "mufasa"}}, "can apply $not to direct values"],
      [{username: {$not: { $ne: "kofrasa"}}}, "can apply $not to sub queries"],
      [{jobs: {$gt: 1, $gte: 6, $lte: 6, $lt: 10}}, "can compare with >, >=, <, <="],
      [{middlename: {$exists: false}}, "can check if value does not exists"],
      [{projects: {$exists: true}}, "can check if value exists"],
      [{"projects.C.1": "student_record" }, "can compare value inside array at index"],
      [{"circles.school": {$in: ["Henry"]}}, "can check that value is in array"],
      [{"circles.family": {$nin: ["Pamela"]}}, "can check that value is not in array"],
      [{"languages.programming": {$size: 7 }}, "can determine size of array"],
      [{"date.month": {$mod: [8, 1]}}, "can check modulo of values"],
      [{"languages.spoken": {$not: {$all: ["english", "french"]}}}, "can check that all values exists in array"]
    ];

    _.each(queries, function (q) {
      ok(Mingo.compile(q[0]).test(obj), q[1]);
    });
  });


  test("conjunctions tests", function () {
    var queries = [
      [{$and: [{firstName: "Francis"},{lastName: /^a.+e/i}]}, "can use conjunction true AND true"],
      [{$and: [{firstName: "Francis"},{lastName: "Amoah"}]}, false, "can use conjunction true AND false"],
      [{$and: [{firstName: "Enoch"},{lastName: "Asante"}]}, false, "can use conjunction false AND true"],
      [{$and: [{firstName: "Enoch"},{age: {$exists: true}}]}, false, "can use conjunction false AND false"],
      // or
      [{$or: [{firstName: "Francis"},{lastName: /^a.+e/i}]}, "can use conjunction true OR true"],
      [{$or: [{firstName: "Francis"},{lastName: "Amoah"}]}, "can use conjunction true OR false"],
      [{$or: [{firstName: "Enoch"},{lastName: "Asante"}]}, "can use conjunction false OR true"],
      [{$or: [{firstName: "Enoch"},{age: {$exists: true}}]}, false, "can use conjunction false OR false"],<commit_msg>added test to match value in array<commit_after>/**
 * Created with JetBrains PhpStorm.
 * User: francis
 * Date: 9/25/13
 * Time: 1:21 PM
 */


$(document).ready(function () {

  module("Queries");

  var obj = {
    firstName: "Francis",
    lastName: "Asante",
    username: "kofrasa",
    title: "Software Engineer",
    degree: "Computer Science",
    jobs: 6,
    date: {
      year: 2013,
      month: 9,
      day: 25
    },
    languages: {
      spoken: ["english"],
      programming: ["C", "Python", "Scala", "Java", "Javascript", "Bash", "C#"]
    },
    circles: {
      school: ["Kobby", "Henry", "Kanba", "Nana", "Albert", "Yayra", "Linda", "Sophia"],
      work: ["Kobby", "KT", "Evans", "Robert", "Ehi", "Ebo", "KO"],
      family: ["Richard", "Roseline", "Michael", "Rachel"]
    },
    projects: {
      "C": ["word_grid", "student_record", "calendar"],
      "Java": ["Easy Programming Language", "SurveyMobile"],
      "Python": ["Kasade", "Code Jam", "Flaskapp", "FlaskUtils"],
      "Scala": [],
      "Javascript": ["mingo", "Backapp", "BackboneApp", "Google Election Maps"]
    }
  };

  test("simple comparisons tests", function () {
    var queries = [
      [{firstName: "Francis"}, "can check for equality"],,
      [{lastName: /^a.+e/i}, "can check against regex"],
      [{username: {$not: "mufasa"}}, "can apply $not to direct values"],
      [{username: {$not: { $ne: "kofrasa"}}}, "can apply $not to sub queries"],
      [{jobs: {$gt: 1, $gte: 6, $lte: 6, $lt: 10}}, "can compare with >, >=, <, <="],
      [{middlename: {$exists: false}}, "can check if value does not exists"],
      [{projects: {$exists: true}}, "can check if value exists"],
      [{"projects.C.1": "student_record" }, "can compare value inside array at index"],
      [{"circles.school": {$in: ["Henry"]}}, "can check that value is in array"],
      [{"circles.family": {$nin: ["Pamela"]}}, "can check that value is not in array"],
      [{"languages.programming": {$size: 7 }}, "can determine size of array"],
      [{"projects.Python": "Flaskapp"}, "can match elements in array"],
      [{"date.month": {$mod: [8, 1]}}, "can check modulo of values"],
      [{"languages.spoken": {$not: {$all: ["english", "french"]}}}, "can check that all values exists in array"]
    ];

    _.each(queries, function (q) {
      ok(Mingo.compile(q[0]).test(obj), q[1]);
    });
  });


  test("conjunctions tests", function () {
    var queries = [
      [{$and: [{firstName: "Francis"},{lastName: /^a.+e/i}]}, "can use conjunction true AND true"],
      [{$and: [{firstName: "Francis"},{lastName: "Amoah"}]}, false, "can use conjunction true AND false"],
      [{$and: [{firstName: "Enoch"},{lastName: "Asante"}]}, false, "can use conjunction false AND true"],
      [{$and: [{firstName: "Enoch"},{age: {$exists: true}}]}, false, "can use conjunction false AND false"],
      // or
      [{$or: [{firstName: "Francis"},{lastName: /^a.+e/i}]}, "can use conjunction true OR true"],
      [{$or: [{firstName: "Francis"},{lastName: "Amoah"}]}, "can use conjunction true OR false"],
      [{$or: [{firstName: "Enoch"},{lastName: "Asante"}]}, "can use conjunction false OR true"],
      [{$or: [{firstName: "Enoch"},{age: {$exists: true}}]}, false, "can use conjunction false OR false"],
{'fraction_non_alphanumeric': 0.2246320681642138, 'fraction_numerical': 0.00836560805577072, 'mean_word_length': 3.5368938861560086, 'pattern_counts': {'":': 23, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '714944', 'n_tokens_mistral': 2296, 'n_tokens_neox': 2154, 'n_words': 650}